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

Bug: Error when loading collection that was saved in previous python session #43

Open
ehennestad opened this issue Nov 26, 2024 · 3 comments

Comments

@ehennestad
Copy link

ehennestad commented Nov 26, 2024

I am trying to load a collection from a single json-ld file created from the example in the README.

If I do this from a new python session, I get the following error:

ValueError                                Traceback (most recent call last)
Cell In [1], line 3
      1 import openminds
      2 fp2 = \"/Users/Eivind/Documents/MATLAB/openMINDS_MATLAB/demo/crew_members.jsonld\"
----> 3 collection2 = openminds.Collection().load(\"my_collection.jsonld\")

File ~/Code/EBRAINS/openMINDS/openMINDS_Python/openminds/collection.py:162, in Collection.load(self, *paths)
    160 if \"@type\" in item:
    161     print(lookup_type)
--> 162     cls = lookup_type(item[\"@type\"])
    163     node = cls.from_jsonld(item)
    164 else:
    165     # allow links to metadata instances outside this collection

File ~/Code/EBRAINS/openMINDS/openMINDS_Python/openminds/registry.py:55, in lookup_type(class_type, version)
     53         return registry[\"types\"][version][class_type]
     54     else:
---> 55         raise ValueError(f\"Type '{class_type}' was not found in the registry for version {version}.\")
     56 else:
     57     raise TypeError(\"class type must be a string\")

ValueError: Type 'https://openminds.ebrains.eu/core/Person' was not found in the registry for version latest."

The registry has not been initialised at this point and does not contain any types.

@Peyman-N
Copy link
Member

Hi @ehennestad, could you please import the openMINDS core before loading the collection and check whether the error persists?
import openminds.latest.core

@ehennestad
Copy link
Author

@Peyman-N That works!

Does that mean I have to explicitly import all the models used by a collection with the right version in order to load the collection?

@apdavison
Copy link
Member

Does that mean I have to explicitly import all the models used by a collection with the right version in order to load the collection?

at present, that is the case, but we should fix this, it shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants