Skip to content

Commit 0a47ce6

Browse files
committed
Make client.space_info() and client.clean_space() more robust
1 parent 55610c5 commit 0a47ce6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fairgraph/client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def move_to_space(self, uri: str, destination_space: str):
636636
if response.error:
637637
raise Exception(response.error)
638638

639-
def space_info(self, space_name: str, scope: str = "released"):
639+
def space_info(self, space_name: str, scope: str = "released", ignore_errors: bool = False):
640640
"""
641641
Return information about the types and number of instances in a space.
642642
@@ -651,7 +651,12 @@ def space_info(self, space_name: str, scope: str = "released"):
651651
try:
652652
cls = lookup_type(item.identifier)
653653
except KeyError as err:
654-
if "vocab/meta/type/Query" in str(err):
654+
ignore_list = [
655+
"https://core.kg.ebrains.eu/vocab/type/Bookmark",
656+
"https://core.kg.ebrains.eu/vocab/meta/type/Query",
657+
"https://openminds.ebrains.eu/core/URL"
658+
]
659+
if ignore_errors or any(ignore in str(err) for ignore in ignore_list):
655660
pass
656661
else:
657662
raise
@@ -663,7 +668,7 @@ def clean_space(self, space_name):
663668
"""Delete all instances from a given space."""
664669
# todo: check for released instances, they must be unreleased
665670
# before deletion.
666-
space_info = self.space_info(space_name, scope="in progress")
671+
space_info = self.space_info(space_name, scope="in progress", ignore_errors=True)
667672
if sum(space_info.values()) > 0:
668673
print(f"The space '{space_name}' contains the following instances:\n")
669674
for cls, count in space_info.items():

0 commit comments

Comments
 (0)