Skip to content

Commit

Permalink
Remove interstitial products
Browse files Browse the repository at this point in the history
  • Loading branch information
caufieldjh committed Sep 17, 2024
1 parent ea0b7e4 commit 78884d7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/kg_bioportal/transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
from kgx.transformer import Transformer as KGXTransformer

from kg_bioportal.downloader import ONTOLOGY_LIST_NAME
from kg_bioportal.robot_utils import (initialize_robot, robot_convert,
robot_relax)
from kg_bioportal.robot_utils import initialize_robot, robot_convert, robot_relax

# TODO: Don't repeat steps if the products already exist
# TODO: Fix KGX hijacking logging
Expand Down Expand Up @@ -248,10 +247,21 @@ def transform(self, ontology_path: str, compress: bool) -> Tuple[bool, int, int]
with tarfile.open(f"{outfilename}.tar.gz", "w:gz") as tar:
tar.add(nodefilename, arcname=f"{ontology_name}_nodes.tsv")
tar.add(edgefilename, arcname=f"{ontology_name}_edges.tsv")

os.remove(nodefilename)
os.remove(edgefilename)

# Remove the owl files
# They may not exist if the transform failed
try:
os.remove(owl_output_path)
except OSError:
pass
try:
os.remove(relaxed_outpath)
except OSError:
pass

except Exception as e:
logging.error(
f"Error transforming {ontology_name} to KGX nodes and edges: {e}"
Expand Down

0 comments on commit 78884d7

Please sign in to comment.