Skip to content

Commit

Permalink
path to csv is constant
Browse files Browse the repository at this point in the history
  • Loading branch information
LoannPeurey committed Nov 27, 2024
1 parent 0c4cb23 commit 83554e1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ChildProject/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@

from . import __version__
from .pipelines.derivations import DERIVATIONS, conversations
from .projects import ChildProject
from .projects import ChildProject, METADATA_FOLDER
from .converters import *
from .tables import IndexTable, IndexColumn, assert_dataframe, assert_columns_presence
from .utils import Segment, intersect_ranges, path_is_parent, TimeInterval, series_to_datetime, find_lines_involved_in_overlap

ANNOTATIONS_CSV = 'annotations.csv'
SETS_CSV = 'sets.csv'

# Create a logger for the module (file)
logger_annotations = logging.getLogger(__name__)
Expand Down Expand Up @@ -290,7 +292,7 @@ def __init__(self, project: ChildProject):

self.project.read()

index_path = os.path.join(self.project.path, "metadata","annotations.csv")
index_path = os.path.join(self.project.path, METADATA_FOLDER,ANNOTATIONS_CSV)
if not os.path.exists(index_path):
open(index_path, "w+").write(",".join([c.name for c in self.INDEX_COLUMNS]))

Expand All @@ -306,7 +308,7 @@ def read(self) -> Tuple[List[str], List[str]]:
"""
table = IndexTable(
"input",
path=os.path.join(self.project.path, "metadata/annotations.csv"),
path=os.path.join(self.project.path, METADATA_FOLDER, ANNOTATIONS_CSV),
columns=self.INDEX_COLUMNS,
)
self.annotations = table.read()
Expand Down Expand Up @@ -426,7 +428,7 @@ def write(self):
] = self.annotations[["time_seek", "range_onset", "range_offset"]].astype(np.int64)
self.annotations = self.annotations.sort_values(['imported_at','set', 'annotation_filename'])
self.annotations.to_csv(
os.path.join(self.project.path, "metadata/annotations.csv"), index=False
os.path.join(self.project.path, METADATA_FOLDER, ANNOTATIONS_CSV), index=False
)

def _check_for_outdated_merged_sets(self, sets: set = None):
Expand Down Expand Up @@ -888,7 +890,7 @@ def derive_annotations(self,
"""
input_processed = self.annotations[self.annotations['set'] == input_set].copy()
assert not input_processed.empty, "Input set {0} does not exist,\
existing sets are in the 'set' column of annotations.csv".format(input_set)
existing sets are in the 'set' column of {1}".format(input_set, ANNOTATIONS_CSV)

assert input_set != output_set, "Input set {0} should be different than output\
set {1}".format(input_set, output_set)
Expand Down

0 comments on commit 83554e1

Please sign in to comment.