Skip to content

Commit

Permalink
fix: catch ETL module import errors (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson authored Sep 15, 2023
1 parent e77c323 commit c6c9a70
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions gene/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
create_db,
)
from gene.database.database import DatabaseException
from gene.etl import HGNC, NCBI, Ensembl # noqa: F401
from gene.etl.exceptions import GeneNormalizerEtlError
from gene.etl.merge import Merge
from gene.schemas import SourceName

logger = logging.getLogger("gene")
Expand Down Expand Up @@ -176,6 +173,14 @@ def _load_source(
start_load = timer()

# used to get source class name from string
try:
from gene.etl import HGNC, NCBI, Ensembl # noqa: F401
from gene.etl.exceptions import GeneNormalizerEtlError
except ModuleNotFoundError as e:
click.echo(
f"Encountered ModuleNotFoundError attempting to import {e.name}. Are ETL dependencies installed?"
)
click.get_current_context().exit()
SourceClass = eval(n.value) # noqa: N806

source = SourceClass(database=db)
Expand Down Expand Up @@ -221,6 +226,15 @@ def _load_merge(db: AbstractDatabase, processed_ids: Set[str]) -> None:
_delete_normalized_data(db)
if not processed_ids:
processed_ids = db.get_all_concept_ids()

try:
from gene.etl.merge import Merge
except ModuleNotFoundError as e:
click.echo(
f"Encountered ModuleNotFoundError attempting to import {e.name}. Are ETL dependencies installed?"
)
click.get_current_context().exit()

merge = Merge(database=db)
click.echo("Constructing normalized records...")
merge.create_merged_concepts(processed_ids)
Expand Down

0 comments on commit c6c9a70

Please sign in to comment.