monarch-initiative / ontogpt

LLM-based ontological extraction tools, including SPIRES
https://monarch-initiative.github.io/ontogpt/
BSD 3-Clause "New" or "Revised" License
603 stars 75 forks source link

ModuleNotFoundError: No module named 'ontogpt.templates.fairlyz_study' #409

Closed pbuendia closed 3 months ago

pbuendia commented 3 months ago

Please help me troubleshoot this error. How do I add my custom template/schema?

After following the guidelines here: https://monarch-initiative.github.io/ontogpt/custom/

I am getting: ModuleNotFoundError: No module named 'ontogpt.templates.fairlyz_study'

I am running: ontogpt extract -t fairlyz_study.yaml -i example.txt

with file fairlyz_study.yaml starting with: id: http://w3id.org/ontogpt/fairlyz_study name: fairlyz_study title: FAIRLYZ Study Template

In the guide it says: Running that command (or any other command including your custom schema) will install it for future use with OntoGPT.

Traceback (most recent call last): File "/home/adminlo/.local/bin/ontogpt", line 8, in sys.exit(main()) File "/home/adminlo/.local/lib/python3.10/site-packages/click/core.py", line 1157, in call return self.main(args, kwargs) File "/home/adminlo/.local/lib/python3.10/site-packages/click/core.py", line 1078, in main rv = self.invoke(ctx) File "/home/adminlo/.local/lib/python3.10/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/home/adminlo/.local/lib/python3.10/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, ctx.params) File "/home/adminlo/.local/lib/python3.10/site-packages/click/core.py", line 783, in invoke return __callback(args, **kwargs) File "/home/adminlo/.local/lib/python3.10/site-packages/ontogpt/cli.py", line 351, in extract template_details = get_template_details(template=template) File "/home/adminlo/.local/lib/python3.10/site-packages/ontogpt/io/template_loader.py", line 37, in get_template_details mod = importlib.import_module(f"ontogpt.templates.{module_name}") File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1004, in _find_and_load_unlocked ModuleNotFoundError: No module named 'ontogpt.templates.fairlyz_study'

caufieldjh commented 3 months ago

Hi @pbuendia - I have not been able to reproduce this error. Can you please ensure that you're working with the most recent version of ontogpt (v0.3.15)?

As a workaround, in the same environment where you're running ontogpt, you can run the following:

gen-pydantic --pydantic-version 2 fairlyz_study.yaml > fairlyz_study.py

Then move both fairlyz_study.yaml and fairlyz_study.py to where the rest of your ontogpt templates are - if you installed from the repo here, that will be src/ontogpt/templates/, or with a pip install in a virtual environment that may be more like /.venv/lib/python3.10/site-packages/ontogpt/templates - either way, that's the step that will make the template available for future use.

pbuendia commented 3 months ago

Thank you! it was the version. I had ontogpt, version 0.3.11 installed.