Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'str' object has no attribute 'get' #230

Closed
emanuelecavalleri opened this issue Oct 4, 2023 · 1 comment
Closed

AttributeError: 'str' object has no attribute 'get' #230

emanuelecavalleri opened this issue Oct 4, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@emanuelecavalleri
Copy link
Collaborator

Hello @caufieldjh! I have recently upgraded ontoGPT to its latest version. I've encountered an issue while executing commands such as “ontogpt extract -t gene_protein -i abstract_geneProtein.txt” which results in the following error message:

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.11/bin/ontogpt", line 8, in
sys.exit(main())
^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/click/core.py", line 1157, in call
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontogpt/cli.py", line 336, in extract
results = ke.extract_from_text(text=text, cls=target_class_def, show_prompt=show_prompt)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontogpt/engines/spires_engine.py", line 97, in extract_from_text
extracted_object = self.parse_completion_payload(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontogpt/engines/spires_engine.py", line 559, in parse_completion_payload
return self.ground_annotation_object(raw, cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontogpt/engines/spires_engine.py", line 629, in ground_annotation_object
obj = self.ground_annotation_object(val, rng_cls)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontogpt/engines/spires_engine.py", line 631, in ground_annotation_object
obj = self.normalize_named_entity(val, slot.range) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontogpt/engines/knowledge_engine.py", line 352, in normalize_named_entity
for normalized_id in self.normalize_identifier(obj_id, cls):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontogpt/engines/knowledge_engine.py", line 416, in normalize_identifier
for obj_id in self.map_identifier(input_id, cls):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ontogpt/engines/knowledge_engine.py", line 449, in map_identifier
for mapping in mapper.sssom_mappings([input_id]):
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/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'


Package Versions:
ontogpt: 0.3.3
oaklib: 0.5.20
sssom: 0.3.41

Thanks in advance!
Emanuele

@emanuelecavalleri emanuelecavalleri added the bug Something isn't working label Oct 4, 2023
@caufieldjh
Copy link
Member

Hi @emanuelecavalleri - this is a bug in oaklib that got fixed here: INCATools/ontology-access-kit#663 , but hasn't made it into a released version of that package yet.
In the meantime, there's an easy fix:
Open oaklib's translator_implementation.py (so on your system, "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/oaklib/implementations/translator/translator_implementation.py") with your choice of editor and find the line beginning with NODE_NORMALIZER_ENDPOINT.
It should be around line 26.
In the URL in that line, change the "1.3" to "1.4" so the line then reads:

NODE_NORMALIZER_ENDPOINT = "https://nodenormalization-sri.renci.org/1.4/get_normalized_nodes"

This should clear up that error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants