Skip to content

Commit 1d8db9b

Browse files
committed
Merge branch 'handle-expanded-paths' into fairgraph-compat
* handle-expanded-paths: Support the use of expanded paths (e.g., `"https://openminds.om-i.org/props/description"` rather than just `"description"`)
2 parents 451ec50 + ac5ae6f commit 1d8db9b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pipeline/src/base.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,18 @@ def from_jsonld(cls, data, ignore_unexpected_keys=False):
131131
if issubclass(cls, LinkedMetadata):
132132
deserialized_data["id"] = data_copy.pop("@id", None)
133133
for property in cls.properties:
134-
if property.path in data_copy: # todo: use context to resolve uris
134+
found = False
135+
if property.path in data_copy:
135136
value = data_copy.pop(property.path)
137+
found = True
138+
else:
139+
# todo: implement or import a function that does a full JSON-LD expansion
140+
# not just this special case
141+
expanded_path = f"{cls.context['@vocab']}{property.path}"
142+
if expanded_path in data_copy:
143+
value = data_copy.pop(expanded_path)
144+
found = True
145+
if found:
136146
if value:
137147
deserialized_data[property.name] = property.deserialize(value)
138148
else:

0 commit comments

Comments
 (0)