Skip to content

Commit 005d8d5

Browse files
authored
Merge pull request #241 from superannotateai/fix-upload-annotations
Fix upload annotations
2 parents c2b93ba + ee724fa commit 005d8d5

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

src/superannotate/lib/app/helpers.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,22 +42,29 @@ def get_annotation_paths(folder_path, s3_bucket=None, recursive=False):
4242
return get_s3_annotation_paths(
4343
folder_path, s3_bucket, annotation_paths, recursive
4444
)
45-
return get_local_annotation_paths(folder_path, annotation_paths, recursive)
45+
return get_local_annotation_paths(folder_path, set(annotation_paths), recursive)
4646

4747

4848
def get_local_annotation_paths(
49-
folder_path: Union[str, Path], annotation_paths: List, recursive: bool
49+
folder_path: Union[str, Path], annotation_paths: set, recursive: bool
5050
) -> List[str]:
51-
for path in Path(folder_path).glob("*"):
52-
if recursive and path.is_dir():
53-
get_local_annotation_paths(path, annotation_paths, recursive)
54-
for annotation_path in Path(folder_path).glob("*.json"):
55-
if (
56-
annotation_path.name.endswith(VECTOR_ANNOTATION_POSTFIX)
57-
or annotation_path.name.endswith(PIXEL_ANNOTATION_POSTFIX)
58-
) and str(annotation_path) not in annotation_paths:
59-
annotation_paths.append(str(annotation_path))
60-
return annotation_paths
51+
all_items = [*Path(folder_path).glob("*")]
52+
all_folders = [i for i in all_items if i.is_dir()]
53+
annotation_paths.update(
54+
[
55+
str(i)
56+
for i in all_items
57+
if i.name.endswith((VECTOR_ANNOTATION_POSTFIX, PIXEL_ANNOTATION_POSTFIX))
58+
]
59+
)
60+
if recursive:
61+
for folder in all_folders:
62+
get_local_annotation_paths(
63+
folder_path=folder,
64+
annotation_paths=annotation_paths,
65+
recursive=recursive,
66+
)
67+
return list(annotation_paths)
6168

6269

6370
def get_s3_annotation_paths(folder_path, s3_bucket, annotation_paths, recursive):

src/superannotate/lib/core/usecases/images.py

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2027,9 +2027,7 @@ def validate_limitations(self):
20272027
if response.data.folder_limit.remaining_image_count < 1:
20282028
raise AppValidationException(constances.COPY_FOLDER_LIMIT_ERROR_MESSAGE)
20292029
if response.data.project_limit.remaining_image_count < 1:
2030-
raise AppValidationException(
2031-
constances.COPY_PROJECT_LIMIT_ERROR_MESSAGE
2032-
)
2030+
raise AppValidationException(constances.COPY_PROJECT_LIMIT_ERROR_MESSAGE)
20332031
if (
20342032
response.data.user_limit
20352033
and response.data.user_limit.remaining_image_count < 1
@@ -2736,20 +2734,16 @@ def execute(self):
27362734
failed_annotations.append(annotation)
27372735
yield
27382736

2739-
uploaded_annotations = [
2740-
annotation.path for annotation in uploaded_annotations
2741-
]
2742-
missing_annotations.extend(
2743-
[annotation.path for annotation in self._missing_annotations]
2744-
)
2745-
failed_annotations = [
2746-
annotation.path for annotation in failed_annotations
2747-
]
2748-
self._response.data = (
2749-
uploaded_annotations,
2750-
failed_annotations,
2751-
missing_annotations,
2752-
)
2737+
uploaded_annotations = [annotation.path for annotation in uploaded_annotations]
2738+
missing_annotations.extend(
2739+
[annotation.path for annotation in self._missing_annotations]
2740+
)
2741+
failed_annotations = [annotation.path for annotation in failed_annotations]
2742+
self._response.data = (
2743+
uploaded_annotations,
2744+
failed_annotations,
2745+
missing_annotations,
2746+
)
27532747
self.report_missing_data()
27542748
return self._response
27552749

0 commit comments

Comments
 (0)