Skip to content

Commit ed50b79

Browse files
committed
Fix some errors in the v3-v4 migration machinery
1 parent 98f7f25 commit ed50b79

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

fairgraph/client.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ def migrated(self):
205205
result = self.instance_from_full_uri(
206206
"https://kg.ebrains.eu/api/instances/92631f2e-fc6e-4122-8015-a0731c67f66c", release_status="released"
207207
)
208-
if "om-i.org" in result["@type"]:
208+
_type = result["@type"]
209+
if isinstance(_type, list):
210+
_type = _type[0]
211+
if "om-i.org" in _type:
209212
self._migrated = True
210213
else:
211214
self._migrated = False
@@ -411,12 +414,13 @@ def _get_instance(release_status):
411414
elif uri.startswith("https://openminds.om-i.org/instances") or uri.startswith(
412415
"https://openminds.ebrains.eu/instances"
413416
):
414-
if self.migrated and uri.startswith("https://openminds.ebrains.eu"):
415-
payload = [uri.replace("ebrains.eu", "om-i.org")]
416-
elif uri.startswith("https://openminds.om-i.org"):
417-
payload = [uri.replace("om-i.org", "ebrains.eu")]
417+
payload = [uri]
418+
if self.migrated:
419+
if uri.startswith("https://openminds.ebrains.eu"):
420+
payload = [uri.replace("ebrains.eu", "om-i.org")]
418421
else:
419-
payload = [uri]
422+
if uri.startswith("https://openminds.om-i.org"):
423+
payload = [uri.replace("om-i.org", "ebrains.eu")]
420424
response = self._kg_client.instances.get_by_identifiers(
421425
stage=STAGE_MAP[release_status],
422426
payload=payload,

0 commit comments

Comments
 (0)