Skip to content

Commit 983dd9a

Browse files
committed
Merge branch 'friday' of github.com:superannotateai/superannotate-python-sdk into friday
2 parents 8c8716a + 0206c31 commit 983dd9a

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,13 +795,18 @@ def assign_folder(
795795
:type users: list of str
796796
"""
797797

798-
contributors = (
799-
self.controller.projects.get_by_name(
800-
project_name=project_name, include_contributors=True
801-
)
802-
.data["project"]
803-
.users
798+
response = self.controller.projects.get_by_name(name=project_name)
799+
if response.errors:
800+
raise AppException(response.errors)
801+
project = response.data
802+
response = self.controller.projects.get_metadata(
803+
project=project, include_contributors=True
804804
)
805+
806+
if response.errors:
807+
raise AppException(response.errors)
808+
809+
contributors = response.data.users
805810
verified_users = [i["user_id"] for i in contributors]
806811
verified_users = set(users).intersection(set(verified_users))
807812
unverified_contributor = set(users) - verified_users

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ def execute(self) -> Response:
849849

850850
class UploadImagesToProject(BaseInteractiveUseCase):
851851
MAX_WORKERS = 10
852+
LIST_NAME_CHUNK_SIZE = 500
852853

853854
def __init__(
854855
self,
@@ -1023,24 +1024,30 @@ def filter_paths(self, paths: List[str]):
10231024
for path in paths:
10241025
name_path_map[Path(path).name].append(path)
10251026

1027+
CHUNK_SIZE = UploadImagesToProject.LIST_NAME_CHUNK_SIZE
10261028
filtered_paths = []
10271029
duplicated_paths = []
10281030
for file_name in name_path_map:
10291031
if len(name_path_map[file_name]) > 1:
10301032
duplicated_paths.append(name_path_map[file_name][1:])
10311033
filtered_paths.append(name_path_map[file_name][0])
10321034

1033-
response = self._service_provider.items.list_by_names(
1034-
project=self._project,
1035-
folder=self._folder,
1036-
names=[image.split("/")[-1] for image in filtered_paths],
1037-
)
1038-
if not response.ok:
1039-
self._response.errors = AppException(response.error)
1040-
return self._response
1035+
image_list = []
1036+
for i in range(0, len(filtered_paths), CHUNK_SIZE):
1037+
response = self._service_provider.items.list_by_names(
1038+
project=self._project,
1039+
folder=self._folder,
1040+
names=[
1041+
image.split("/")[-1] for image in filtered_paths[i : i + CHUNK_SIZE]
1042+
],
1043+
)
10411044

1045+
if not response.ok:
1046+
raise AppException(response.error)
1047+
image_list.extend([image.name for image in response.data])
1048+
1049+
image_list=set(image_list)
10421050
images_to_upload = []
1043-
image_list = [image.name for image in response.data]
10441051

10451052
for path in filtered_paths:
10461053
if Path(path).name not in image_list:
@@ -1593,15 +1600,14 @@ def fill_classes_data(self, annotations: dict):
15931600
attribute["groupName"] = annotation_class["attribute_groups"][
15941601
attribute["groupId"]
15951602
]["name"]
1596-
if attribute["id"] not in list(
1603+
if attribute.get("id") in list(
15971604
annotation_class["attribute_groups"][attribute["groupId"]][
15981605
"attributes"
15991606
].keys()
16001607
):
1601-
continue
1602-
attribute["name"] = annotation_class["attribute_groups"][
1603-
attribute["groupId"]
1604-
]["attributes"][attribute["id"]]
1608+
attribute["name"] = annotation_class["attribute_groups"][
1609+
attribute["groupId"]
1610+
]["attributes"][attribute["id"]]
16051611

16061612
def execute(self):
16071613
if self.is_valid():

0 commit comments

Comments
 (0)