Skip to content

Commit

Permalink
Fix an error with ParcellationTerminologyVersion (which is embedded, …
Browse files Browse the repository at this point in the history
…not sure why it isn't linked).

Error context:
```
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[11], line 4
      1 import fairgraph.openminds.ephys as ephys
      3 file_170529_1b = [f for f in dataset_version.repository.files if "170529_1b" in f.name][0]
----> 4 recording_info = file_170529_1b.is_location_of.resolve(kg_client, scope="any", follow_links={"recorded_with": {}})

File /srv/main-spack-instance-2402/spack/var/spack/environments/ebrains-24-04/.spack-env/view/lib/python3.8/site-packages/fairgraph/kgquery.py:110, in KGQuery.resolve(self, client, size, from_index, space, scope, use_cache, follow_links)
    108 objects: List[KGObject] = []
    109 for cls in self.classes:
--> 110     query = cls.generate_query(client=client, filters=self.filter, space=space, follow_links=follow_links)
    111     instances = client.query(
    112         query=query,
    113         size=size,
    114         from_index=from_index,
    115         scope=scope,
    116     ).data
    117     objects.extend(cls.from_kg_instance(instance_data, client) for instance_data in instances)

AttributeError: type object 'ParcellationTerminologyVersion' has no attribute 'generate_query'
```
  • Loading branch information
apdavison committed Sep 13, 2024
1 parent f0b45f2 commit 88e0f08
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions fairgraph/kgquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,16 @@ def resolve(
scope = scope or self.preferred_scope
objects: List[KGObject] = []
for cls in self.classes:
query = cls.generate_query(client=client, filters=self.filter, space=space, follow_links=follow_links)
instances = client.query(
query=query,
size=size,
from_index=from_index,
scope=scope,
).data
objects.extend(cls.from_kg_instance(instance_data, client) for instance_data in instances)
if hasattr(cls, "generate_query"):
# if cls is EmbeddedMetadata we cannot query it
query = cls.generate_query(client=client, filters=self.filter, space=space, follow_links=follow_links)
instances = client.query(
query=query,
size=size,
from_index=from_index,
scope=scope,
).data
objects.extend(cls.from_kg_instance(instance_data, client) for instance_data in instances)
for obj in objects:
object_cache[obj.id] = obj

Expand Down

0 comments on commit 88e0f08

Please sign in to comment.