Skip to content

Commit

Permalink
🎨 Do not require organism if field is ontology_ud or uid (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnyosun authored Sep 29, 2024
1 parent 729ec13 commit 07999b6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bionty/_bionty.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


def create_or_get_organism_record(
organism: str | Record | None, registry: type[Record]
organism: str | Record | None, registry: type[Record], field: str | None = None
) -> Record | None:
# return None if an Record doesn't have organism field
organism_record = None
Expand Down Expand Up @@ -49,6 +49,11 @@ def create_or_get_organism_record(
organism_record = None

if organism_record is None:
if hasattr(registry, "_ontology_id_field") and field in {
registry._ontology_id_field,
"uid",
}:
return None
raise AssertionError(
f"{registry.__name__} requires to specify a organism name via `organism=` or `bionty.settings.organism=`!"
)
Expand Down

0 comments on commit 07999b6

Please sign in to comment.