Skip to content
Draft
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
2 changes: 2 additions & 0 deletions src/modelseed_api/services/genome_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ def annotate_fasta(
[genome_dict, {"stages": stages}],
)
break
except TypeError as exc:
raise RuntimeError("RAST malformed error response (expected dict, got str). Original: " + str(exc)) from exc
except Exception as exc:
msg = str(exc)
is_transient = any(code in msg for code in _TRANSIENT_5XX)
Expand Down
17 changes: 17 additions & 0 deletions tests/unit/test_genome_annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,20 @@ def call(self, method, params):

with pytest.raises(ValueError, match="no.*functional roles"):
annotate_fasta(">p1\nMKKLVAVLIVSLAVALSALAVA")



class TestAnnotateFastaTypeErrorHandling:
def test_rpc_typeerror_wraps_to_runtimeerror(self, monkeypatch):
class BadErrorClient:
def __init__(self, url, timeout=600):
pass
def call(self, method, params):
raise TypeError(
"argument after ** must be a mapping, not str"
)
monkeypatch.setattr(
"modelseed_api.services.genome_annotator.RPCClient", BadErrorClient,
)
with pytest.raises(RuntimeError, match="malformed error response"):
annotate_fasta(">p1\nMKKLVAVLIVSLAVALSALAVA")