From 13363e923a6fa5538fa157d1e4765ba06c225187 Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Thu, 16 Nov 2023 16:04:19 +0000 Subject: [PATCH 1/5] Added support for foldre structures when importing CSV tags --- darwin/importer/formats/csv_tags_video.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/darwin/importer/formats/csv_tags_video.py b/darwin/importer/formats/csv_tags_video.py index 35f05e230..6fe8bb389 100644 --- a/darwin/importer/formats/csv_tags_video.py +++ b/darwin/importer/formats/csv_tags_video.py @@ -54,6 +54,8 @@ def parse_path(path: Path) -> Optional[List[dt.AnnotationFile]]: annotation_classes = set( [annotation.annotation_class for annotation in annotations] ) + remote_path = "/" + "/".join(filename.split("/")[:-1]) + filename = filename.split("/")[-1] files.append( dt.AnnotationFile( path, @@ -61,7 +63,7 @@ def parse_path(path: Path) -> Optional[List[dt.AnnotationFile]]: annotation_classes, annotations, is_video=True, - remote_path="/", + remote_path=remote_path, ) ) return files From bee6c482bee548900562b0da7c92fc62618745bf Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Mon, 27 Nov 2023 18:46:58 +0000 Subject: [PATCH 2/5] Tolerance for user-entered filepaths beginning with a forwardslash --- darwin/importer/formats/csv_tags_video.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/darwin/importer/formats/csv_tags_video.py b/darwin/importer/formats/csv_tags_video.py index 0c6c76902..52815a128 100644 --- a/darwin/importer/formats/csv_tags_video.py +++ b/darwin/importer/formats/csv_tags_video.py @@ -54,7 +54,10 @@ def parse_path(path: Path) -> Optional[List[dt.AnnotationFile]]: annotation_classes = set( [annotation.annotation_class for annotation in annotations] ) - remote_path = "/" + "/".join(filename.split("/")[:-1]) + split_filename = filename.split("/") + remote_path = "/".join(split_filename[:-1]) + if not remote_path.startswith("/"): + remote_path = "/" + remote_path filename = filename.split("/")[-1] files.append( dt.AnnotationFile( From c02e918d786b426a1310e3ea9d05c1c32326589f Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Mon, 27 Nov 2023 18:51:45 +0000 Subject: [PATCH 3/5] Change to use Pathlib --- darwin/importer/formats/csv_tags_video.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/darwin/importer/formats/csv_tags_video.py b/darwin/importer/formats/csv_tags_video.py index 52815a128..edf49c944 100644 --- a/darwin/importer/formats/csv_tags_video.py +++ b/darwin/importer/formats/csv_tags_video.py @@ -54,11 +54,12 @@ def parse_path(path: Path) -> Optional[List[dt.AnnotationFile]]: annotation_classes = set( [annotation.annotation_class for annotation in annotations] ) - split_filename = filename.split("/") - remote_path = "/".join(split_filename[:-1]) + + filename_path = Path(filename) + remote_path = str(filename_path.parent) if not remote_path.startswith("/"): remote_path = "/" + remote_path - filename = filename.split("/")[-1] + filename = filename_path.name files.append( dt.AnnotationFile( path, From fca7c3a9d4c71c4066efe38b4780317d3273a8ca Mon Sep 17 00:00:00 2001 From: John Wilkie Date: Mon, 27 Nov 2023 18:52:25 +0000 Subject: [PATCH 4/5] Formatting --- darwin/importer/formats/csv_tags_video.py | 1 - 1 file changed, 1 deletion(-) diff --git a/darwin/importer/formats/csv_tags_video.py b/darwin/importer/formats/csv_tags_video.py index edf49c944..15defdf73 100644 --- a/darwin/importer/formats/csv_tags_video.py +++ b/darwin/importer/formats/csv_tags_video.py @@ -54,7 +54,6 @@ def parse_path(path: Path) -> Optional[List[dt.AnnotationFile]]: annotation_classes = set( [annotation.annotation_class for annotation in annotations] ) - filename_path = Path(filename) remote_path = str(filename_path.parent) if not remote_path.startswith("/"): From f7b99678c8c2eb405fd9cfe14456478249c46892 Mon Sep 17 00:00:00 2001 From: John Wilkie <124276291+JBWilkie@users.noreply.github.com> Date: Tue, 28 Nov 2023 10:15:29 +0000 Subject: [PATCH 5/5] Update darwin/importer/formats/csv_tags_video.py Co-authored-by: saurbhc --- darwin/importer/formats/csv_tags_video.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/darwin/importer/formats/csv_tags_video.py b/darwin/importer/formats/csv_tags_video.py index 15defdf73..d972653cd 100644 --- a/darwin/importer/formats/csv_tags_video.py +++ b/darwin/importer/formats/csv_tags_video.py @@ -52,7 +52,7 @@ def parse_path(path: Path) -> Optional[List[dt.AnnotationFile]]: for filename in file_annotation_map: annotations = file_annotation_map[filename] annotation_classes = set( - [annotation.annotation_class for annotation in annotations] + annotation.annotation_class for annotation in annotations ) filename_path = Path(filename) remote_path = str(filename_path.parent)