ontogpt icon indicating copy to clipboard operation
ontogpt copied to clipboard

Unhandled `AttributeError` when node normalization not completed

Open caufieldjh opened this issue 9 months ago • 1 comments

Running the following command:

$ ontogpt -vvv pubmed-annotate -t gocam --get-pmc --limit 1 "27849154"

results in an error:

...
INFO:ontogpt.engines.knowledge_engine:GROUNDING HSN using Gene
INFO:ontogpt.engines.knowledge_engine: Annotators: ['gilda:', 'sqlite:obo:pr'] [will skip: None]
INFO:ontogpt.engines.knowledge_engine:Loading annotator gilda:
DEBUG:gilda.grounder:Looking up the following strings: hsn
DEBUG:gilda.grounder:Filtering 1 entries by organism
DEBUG:gilda.grounder:Comparing HSN with 1 entries
INFO:ontogpt.engines.knowledge_engine:Grounding HSN to hgnc:11148; next step is to normalize
DEBUG:ontogpt.engines.knowledge_engine:ID hgnc:11148 not in prefixes ['HGNC', 'PR', 'UniProtKB']
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): nodenormalization-sri.renci.org:443
DEBUG:urllib3.connectionpool:https://nodenormalization-sri.renci.org:443 "GET /1.3/get_normalized_nodes?curie=hgnc%3A11148&conflate=false HTTP/1.1" 404 22
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): nodenormalization-sri.renci.org:443
DEBUG:urllib3.connectionpool:https://nodenormalization-sri.renci.org:443 "GET /1.3/get_normalized_nodes?curie=hgnc%3A11148&conflate=true HTTP/1.1" 404 22
Traceback (most recent call last):
  File "/home/harry/ontogpt/.venv/bin/ontogpt", line 6, in <module>
    sys.exit(main())
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/harry/ontogpt/src/ontogpt/cli.py", line 542, in pubmed_annotate
    results = ke.extract_from_text(text=text, show_prompt=show_prompt)
  File "/home/harry/ontogpt/src/ontogpt/engines/spires_engine.py", line 97, in extract_from_text
    extracted_object = self.parse_completion_payload(
  File "/home/harry/ontogpt/src/ontogpt/engines/spires_engine.py", line 559, in parse_completion_payload
    return self.ground_annotation_object(raw, cls)
  File "/home/harry/ontogpt/src/ontogpt/engines/spires_engine.py", line 631, in ground_annotation_object
    obj = self.normalize_named_entity(val, slot.range)  # type: ignore
  File "/home/harry/ontogpt/src/ontogpt/engines/knowledge_engine.py", line 352, in normalize_named_entity
    for normalized_id in self.normalize_identifier(obj_id, cls):
  File "/home/harry/ontogpt/src/ontogpt/engines/knowledge_engine.py", line 416, in normalize_identifier
    for obj_id in self.map_identifier(input_id, cls):
  File "/home/harry/ontogpt/src/ontogpt/engines/knowledge_engine.py", line 449, in map_identifier
    for mapping in mapper.sssom_mappings([input_id]):
  File "/home/harry/ontogpt/.venv/lib/python3.9/site-packages/oaklib/implementations/translator/translator_implementation.py", line 62, in sssom_mappings
    equiv_identifiers = data.get("equivalent_identifiers", [])
AttributeError: 'str' object has no attribute 'get'

It looks like something went wrong in assigning a value to the result returned from the node normalizer service, but it probably shouldn't be a str anyway.

caufieldjh avatar Sep 28 '23 19:09 caufieldjh