diff --git a/bionty/_bionty.py b/bionty/_bionty.py index 1209126..b6e1322 100644 --- a/bionty/_bionty.py +++ b/bionty/_bionty.py @@ -14,6 +14,12 @@ from types import ModuleType +class OrganismNotSet(SystemExit): + """The `organism` parameter was not passed or is not globally set.""" + + pass + + def create_or_get_organism_record( organism: str | Record | None, registry: type[Record], field: str | None = None ) -> Record | None: @@ -54,7 +60,7 @@ def create_or_get_organism_record( "uid", }: return None - raise AssertionError( + raise OrganismNotSet( f"{registry.__name__} requires to specify a organism name via `organism=` or `bionty.settings.organism=`!" ) diff --git a/bionty/core/_add_ontology.py b/bionty/core/_add_ontology.py index 955adc7..54d88c9 100644 --- a/bionty/core/_add_ontology.py +++ b/bionty/core/_add_ontology.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Iterable, List, Optional, Set, Tuple, Type, Union +from typing import TYPE_CHECKING, Iterable from lamin_utils import logger