Skip to content

Commit

Permalink
manage reruns
Browse files Browse the repository at this point in the history
  • Loading branch information
hrshdhgd committed Jul 15, 2024
1 parent 1133201 commit 7eb1b67
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/koza/io/writer/tsv_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# NOTE - May want to rename to KGXWriter at some point, if we develop writers for other models non biolink/kgx specific

from pathlib import Path
import shutil
from typing import Dict, Iterable, List, Literal, Set, Union

from ordered_set import OrderedSet
Expand All @@ -13,6 +14,8 @@


class TSVWriter(KozaWriter):
_splits_cleanup_done = False

def __init__(
self,
output_dir: Union[str, Path],
Expand Down Expand Up @@ -69,6 +72,9 @@ def write_row(self, record: Dict, record_type: Literal["node", "edge"], split: b

def get_new_fh_path(base_dir, filename, category):
new_dir = base_dir / "splits"
if not self._splits_cleanup_done:
shutil.rmtree(new_dir, ignore_errors=True)
self._splits_cleanup_done = True
new_dir.mkdir(parents=True, exist_ok=True)
return new_dir / filename.replace(record_type + "s", f"{category}_{record_type}s")

Expand Down

0 comments on commit 7eb1b67

Please sign in to comment.