Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 Raise OrganismNotSet instead of AssertionError when organism is not set #144

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion bionty/_bionty.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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=`!"
)

Expand Down
2 changes: 1 addition & 1 deletion bionty/core/_add_ontology.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Loading