diff --git a/src/gocam/cli.py b/src/gocam/cli.py index 9252e96..93a646d 100644 --- a/src/gocam/cli.py +++ b/src/gocam/cli.py @@ -69,7 +69,7 @@ def fetch(model_ids, format): for model_id in model_ids: model = wrapper.fetch_model(model_id) - model_dict = model.model_dump(exclude_none=True, exclude_unset=True) + model_dict = model.model_dump(exclude_none=True, exclude_defaults=True) if format == "json": click.echo(json.dumps(model_dict, indent=2)) diff --git a/src/gocam/translation/minerva_wrapper.py b/src/gocam/translation/minerva_wrapper.py index 07eb06e..6a99fb9 100644 --- a/src/gocam/translation/minerva_wrapper.py +++ b/src/gocam/translation/minerva_wrapper.py @@ -68,7 +68,9 @@ def _annotations_multivalued(obj: Dict) -> Dict[str, List[str]]: def _setattr_with_warning(obj, attr, value): if getattr(obj, attr, None) is not None: - logger.warning(f"Overwriting {attr} for {obj.id if hasattr(obj, 'id') else obj}") + logger.warning( + f"Overwriting {attr} for {obj.id if hasattr(obj, 'id') else obj}" + ) setattr(obj, attr, value) @@ -320,8 +322,6 @@ def _iter_activities_by_fact_subject( for activity, term, evs in _iter_activities_by_fact_subject( fact_property=HAS_INPUT ): - if activity.has_input is None: - activity.has_input = [] activity.has_input.append(MoleculeAssociation(term=term, evidence=evs)) for activity, term, evs in _iter_activities_by_fact_subject( @@ -333,8 +333,6 @@ def _iter_activities_by_fact_subject( for activity, term, evs in _iter_activities_by_fact_subject( fact_property=HAS_OUTPUT ): - if activity.has_output is None: - activity.has_output = [] activity.has_output.append(MoleculeAssociation(term=term, evidence=evs)) for activity, term, evs in _iter_activities_by_fact_subject( @@ -368,8 +366,6 @@ def _iter_activities_by_fact_subject( downstream_activity=object_activity.id, evidence=evs, ) - if not subject_activity.causal_associations: - subject_activity.causal_associations = [] subject_activity.causal_associations.append(rel) annotations = _annotations(obj) diff --git a/tests/test_translation/test_minerva_wrapper.py b/tests/test_translation/test_minerva_wrapper.py index 7e3167d..12f23e1 100644 --- a/tests/test_translation/test_minerva_wrapper.py +++ b/tests/test_translation/test_minerva_wrapper.py @@ -96,6 +96,8 @@ def test_multivalued_input_and_output(): minerva_object = json.load(f) model = mw.minerva_object_to_model(minerva_object) - cs_activity = next(a for a in model.activities if a.molecular_function.term == "GO:0004108") + cs_activity = next( + a for a in model.activities if a.molecular_function.term == "GO:0004108" + ) assert len(cs_activity.has_input) == 3 assert len(cs_activity.has_output) == 2