Skip to content

Fix NameError: import Optional in ankh_transformer_utils#36

Closed
soldatmat wants to merge 1 commit into
mainfrom
fix/ankh-optional-import
Closed

Fix NameError: import Optional in ankh_transformer_utils#36
soldatmat wants to merge 1 commit into
mainfrom
fix/ankh-optional-import

Conversation

@soldatmat

Copy link
Copy Markdown
Collaborator

Problem

enzymeexplorer/src/embeddings_extraction/ankh_transformer_utils.py annotates
checkpoint_dir: Optional[str] in get_model_and_tokenizer() (line 9) but never
imports Optional. Python evaluates that annotation at function-definition time,
so importing the module raises:

NameError: name 'Optional' is not defined

tps_predict_fasta.py imports this module, so the sequence-only prediction
path crashes on import
— the PLM detection step produces nothing, and the
downstream gather_detections_to_csv.py then fails with
AssertionError: ... detections_plm does not exist.

Fix

Add from typing import Optional. One line.

Verification

With the fix, easy_predict_sequence_only.py runs end-to-end on a 2-sequence
FASTA and produces the expected CSV (substrate-class probabilities + isTPS +
ID). Without it, the run fails as above.

🤖 Generated with Claude Code

ankh_transformer_utils.py annotates `checkpoint_dir: Optional[str]` in
get_model_and_tokenizer() but never imports Optional, so the module raises
`NameError: name 'Optional' is not defined` at import time. This breaks the
PLM detection path (tps_predict_fasta.py imports it), so sequence-only
prediction produces no detections and downstream gather_detections_to_csv
fails with `detections_plm does not exist`.

Add `from typing import Optional`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@soldatmat soldatmat closed this Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant