Skip to content

Commit 0ccaa5d

Browse files
authored
Merge pull request #448 from superannotateai/fix_set_annotation_statuses
Fix set annotation statuses
2 parents f3c3686 + 1bd18ff commit 0ccaa5d

File tree

5 files changed

+47
-23
lines changed

5 files changed

+47
-23
lines changed

src/superannotate/lib/app/analytics/aggregators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import copy
22
import json
3+
from dataclasses import dataclass
34
from pathlib import Path
45
from typing import List
56
from typing import Optional
67
from typing import Union
78

89
import lib.core as constances
910
import pandas as pd
10-
from dataclasses import dataclass
1111
from lib.app.exceptions import AppException
1212
from lib.core import ATTACHED_VIDEO_ANNOTATION_POSTFIX
1313
from lib.core import PIXEL_ANNOTATION_POSTFIX

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ def unassign_images(
798798
warnings.warn(warning_msg, DeprecationWarning)
799799
project_name, folder_name = extract_project_folder(project)
800800

801-
response = self.controller.un_assign_items(
801+
response = self.controller.un_assign_images(
802802
project_name=project_name, folder_name=folder_name, image_names=image_names
803803
)
804804
if response.errors:
@@ -2698,6 +2698,8 @@ def set_annotation_statuses(
26982698
)
26992699
if response.errors:
27002700
raise AppException(response.errors)
2701+
else:
2702+
logger.info("Annotation statuses of items changed")
27012703
return response.data
27022704

27032705
def download_annotations(

src/superannotate/lib/core/config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import threading
2-
from typing import Dict
3-
42
from dataclasses import dataclass
53
from dataclasses import field
4+
from typing import Dict
65

76

87
class Session:

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

Lines changed: 41 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class CopyItems(BaseReportableUseCase):
380380
Return skipped item names.
381381
"""
382382

383-
CHUNK_SIZE = 1000
383+
CHUNK_SIZE = 500
384384

385385
def __init__(
386386
self,
@@ -431,12 +431,18 @@ def execute(self):
431431
)
432432
items = [item.name for item in self._items.get_all(condition)]
433433

434-
existing_items = self._backend_service.get_bulk_images(
435-
project_id=self._project.id,
436-
team_id=self._project.team_id,
437-
folder_id=self._to_folder.uuid,
438-
images=items,
439-
)
434+
existing_items = []
435+
for i in range(0, len(items), self.CHUNK_SIZE):
436+
cand_items = self._backend_service.get_bulk_images(
437+
project_id=self._project.id,
438+
team_id=self._project.team_id,
439+
folder_id=self._to_folder.uuid,
440+
images=items[i : i + self.CHUNK_SIZE],
441+
)
442+
if isinstance(cand_items, dict):
443+
continue
444+
existing_items += cand_items
445+
440446
duplications = [item["name"] for item in existing_items]
441447
items_to_copy = list(set(items) - set(duplications))
442448
skipped_items = duplications
@@ -471,12 +477,19 @@ def execute(self):
471477
except BackendError as e:
472478
self._response.errors = AppException(e)
473479
return self._response
474-
existing_items = self._backend_service.get_bulk_images(
475-
project_id=self._project.id,
476-
team_id=self._project.team_id,
477-
folder_id=self._to_folder.uuid,
478-
images=items,
479-
)
480+
481+
existing_items = []
482+
for i in range(0, len(items), self.CHUNK_SIZE):
483+
cand_items = self._backend_service.get_bulk_images(
484+
project_id=self._project.id,
485+
team_id=self._project.team_id,
486+
folder_id=self._to_folder.uuid,
487+
images=items[i : i + self.CHUNK_SIZE],
488+
)
489+
if isinstance(cand_items, dict):
490+
continue
491+
existing_items += cand_items
492+
480493
existing_item_names_set = {item["name"] for item in existing_items}
481494
items_to_copy_names_set = set(items_to_copy)
482495
copied_items = existing_item_names_set.intersection(
@@ -600,12 +613,21 @@ def validate_items(self):
600613
)
601614
self._item_names = [item.name for item in self._items.get_all(condition)]
602615
return
603-
existing_items = self._backend_service.get_bulk_images(
604-
project_id=self._project.id,
605-
team_id=self._project.team_id,
606-
folder_id=self._folder.uuid,
607-
images=self._item_names,
608-
)
616+
existing_items = []
617+
for i in range(0, len(self._item_names), self.CHUNK_SIZE):
618+
619+
search_names = self._item_names[i : i + self.CHUNK_SIZE]
620+
cand_items = self._backend_service.get_bulk_images(
621+
project_id=self._project.id,
622+
team_id=self._project.team_id,
623+
folder_id=self._folder.uuid,
624+
images=search_names,
625+
)
626+
627+
if isinstance(cand_items, dict):
628+
continue
629+
existing_items += cand_items
630+
609631
if not existing_items:
610632
raise AppValidationException(self.ERROR_MESSAGE)
611633
if existing_items:

src/superannotate/lib/infrastructure/services.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,7 @@ def set_images_statuses_bulk(
693693
def get_bulk_images(
694694
self, project_id: int, team_id: int, folder_id: int, images: List[str]
695695
) -> List[dict]:
696+
696697
bulk_get_images_url = urljoin(self.api_url, self.URL_BULK_GET_IMAGES)
697698
res = self._request(
698699
bulk_get_images_url,

0 commit comments

Comments
 (0)