AllenNeuralDynamics / AllenNeuralDynamics/biodata-models

External API dependency in model definitions

Đang mở
#7 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
0
Fork
0
Merge trung bình
2 ngày 3 giờ
Pull request đã merge (30 ngày)
7

Mô tả

It looks like the Emapa service went down today (6/17/26) which caused errors in the metadata-service unit tests
and led to the discovery of a hidden dependency to an external API EMAPA. These API calls are being done silently in the `aind_data_schema_models.mouse_anatomy` module (overriding the `__get_attribute__` method so an external network request is done).

This problem should probably have more visibility though because we should (1) have more observability when external dependencies go down, this shouldn't have been discovered accidentally in a unit test and (2) this design introduces hidden complexity and a hidden dependency in aind-data-schema on an external service.

Here's the error that was found in the tests:
```
src/aind_metadata_service_server/mappers/las2020.py:1279: in get_surgery
targeted_structure = InjectionTargets.INTRAPERITONEAL
/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/aind_data_schema_models/mouse_anatomy.py:105: in __getattribute__
emapa_id = get_emapa_id(original_name)
/opt/hostedtoolcache/Python/3.10.20/x64/lib/python3.10/site-packages/aind_data_schema_models/mouse_anatomy.py:71: in get_emapa_id
results = search_emapa_exact_match(class_name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

class_name = 'peritoneal cavity'

def search_emapa_exact_match(class_name):
"""Pull the exact name match from the EMAPA ontology

Parameters
----------
class_name : str
Name of class

Returns
-------
list

Raises
------
Exception
OLS query failed on any status code other than 200
"""
base_url = "https://www.ebi.ac.uk/ols/api/search"
params = {
"q": class_name,
"ontology": "emapa", # Specify the ontology
"type": "class", # Search for classes
}
response = requests.get(base_url, params=params)
if response.status_code == 200:
results = response.json()
# Extract terms with exact label match
exact_matches = [
{
"iri": entry["iri"],
"label": entry["label"],
}
for entry in results.get("response", {}).get("docs", [])
if entry["label"].lower() == class_name.lower()
]
return exact_matches
else:
> raise Exception(f"OLS query failed: {response.status_code}, {response.text}")
E Exception: OLS query failed: 500, {
E "status" : 500,
E "message" : "Raw search query failed"
E }
```

This design pattern is a bit concerning to me since it is unexpected for an attribute lookup on an "enum" to actually be performing an external API call.

When we switch to Dataverse and the biodata registry, then maybe we can consolidate the business logic in one place.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.