Skip to content

Commit 074e563

Browse files
Potential fixes for 2 code quality findings (#543)
* Apply suggested fix to metpo/pipeline/cross_ontology_search.py from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> * Apply suggested fix to metpo/pipeline/cross_ontology_search.py from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
1 parent 0449535 commit 074e563

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

metpo/pipeline/cross_ontology_search.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
1010
1. retrieves candidate classes from the EBI OLS4 search API (covers ~270 ontologies),
1111
2. re-ranks the candidates by semantic similarity using a LOCAL embedding model
12-
served by Ollama (default: nomic-embed-text, runs on the M5 GPU; no OpenAI, no
12+
served by Ollama (default: nomic-embed-text, runs on local GPU-capable hardware; no OpenAI, no
1313
300GB OLS SQLite, no ChromaDB),
1414
1515
and emits, per match: the external IRI/CURIE, label, definition, ontology, and a
@@ -82,7 +82,11 @@ def embed(text, model, embed_url=DEFAULT_EMBED_URL):
8282
try:
8383
with urllib.request.urlopen(req, timeout=20) as r:
8484
return json.load(r).get("embedding")
85-
except Exception:
85+
except (urllib.error.URLError, TimeoutError, json.JSONDecodeError) as e:
86+
print(
87+
f"warning: embedding request failed for model={model!r} at {embed_url!r}: {e}",
88+
file=sys.stderr,
89+
)
8690
return None
8791

8892

0 commit comments

Comments
 (0)