Skip to content

Commit 83554e1

Browse files
committed
path to csv is constant
1 parent 0c4cb23 commit 83554e1

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ChildProject/annotations.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212

1313
from . import __version__
1414
from .pipelines.derivations import DERIVATIONS, conversations
15-
from .projects import ChildProject
15+
from .projects import ChildProject, METADATA_FOLDER
1616
from .converters import *
1717
from .tables import IndexTable, IndexColumn, assert_dataframe, assert_columns_presence
1818
from .utils import Segment, intersect_ranges, path_is_parent, TimeInterval, series_to_datetime, find_lines_involved_in_overlap
1919

20+
ANNOTATIONS_CSV = 'annotations.csv'
21+
SETS_CSV = 'sets.csv'
2022

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

291293
self.project.read()
292294

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

@@ -306,7 +308,7 @@ def read(self) -> Tuple[List[str], List[str]]:
306308
"""
307309
table = IndexTable(
308310
"input",
309-
path=os.path.join(self.project.path, "metadata/annotations.csv"),
311+
path=os.path.join(self.project.path, METADATA_FOLDER, ANNOTATIONS_CSV),
310312
columns=self.INDEX_COLUMNS,
311313
)
312314
self.annotations = table.read()
@@ -426,7 +428,7 @@ def write(self):
426428
] = self.annotations[["time_seek", "range_onset", "range_offset"]].astype(np.int64)
427429
self.annotations = self.annotations.sort_values(['imported_at','set', 'annotation_filename'])
428430
self.annotations.to_csv(
429-
os.path.join(self.project.path, "metadata/annotations.csv"), index=False
431+
os.path.join(self.project.path, METADATA_FOLDER, ANNOTATIONS_CSV), index=False
430432
)
431433

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

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

0 commit comments

Comments
 (0)