Skip to content

Commit

Permalink
Merge pull request #213 from Knowledge-Graph-Hub/212-foodon-v2024-02-…
Browse files Browse the repository at this point in the history
…21-does-not-convert-to-obojson

Expand repairs in convert_owl
  • Loading branch information
caufieldjh authored Mar 19, 2024
2 parents 02187a4 + 67a14f4 commit 2c57052
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions kg_obo/robot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def convert_owl(robot_path: str, input_owl: str, output: str, robot_env: dict) -
success = True
except sh.ErrorReturnCode_1 as e: # If ROBOT runs but returns an error
print(f"ROBOT encountered an error: {e}")
print(f"Will try to repair...")
print("Will try to repair by removing object properties...")
try:
robot_command('remove',
'--input', input_owl,
Expand All @@ -118,6 +118,7 @@ def convert_owl(robot_path: str, input_owl: str, output: str, robot_env: dict) -
success = True
except sh.ErrorReturnCode_1 as e:
print(f"ROBOT encountered another error: {e}")
print("Will try to repair by removing comments..")
try:
robot_command('remove',
'--input', input_owl,
Expand All @@ -128,7 +129,18 @@ def convert_owl(robot_path: str, input_owl: str, output: str, robot_env: dict) -
success = True
except sh.ErrorReturnCode_1 as e:
print(f"ROBOT encountered yet another error: {e}")
success = False
print("Will try to repair by removing IAO:0000115...")
try:
robot_command('remove',
'--input', input_owl,
'--exclude-term', 'IAO:0000115',
'--output', output,
_env=robot_env,
)
success = True
except sh.ErrorReturnCode_1 as e:
print(f"ROBOT encountered yet a further error: {e}")
return False

# Neutralize invalid prefixes.
print("Replacing any invalid prefixes...")
Expand Down

0 comments on commit 2c57052

Please sign in to comment.