Skip to content

Commit 234d57b

Browse files
committed
Fix issues
1 parent f1a3292 commit 234d57b

27 files changed

+101
-272
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
minversion = 3.0
33
log_cli=true
44
python_files = test_*.py
5-
addopts = -n auto --dist=loadscope
5+
;addopts = -n auto --dist=loadscope

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@
4040
entry_points={
4141
'console_scripts': ['superannotatecli = superannotate.lib.app.bin.superannotate:main']
4242
},
43-
python_requires='>=3.6'
43+
python_requires='>=3.7'
4444
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3212,7 +3212,7 @@ def copy_items(
32123212
to_project_name, destination_folder = extract_project_folder(destination)
32133213
if project_name != to_project_name:
32143214
raise AppException(
3215-
"Source and destination projects should be the same for copy_images"
3215+
"Source and destination projects should be the same"
32163216
)
32173217

32183218
response = Controller.get_default().copy_items(

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def __eq__(self, other):
108108

109109

110110
class Setting(BaseModel):
111-
attribute: NotEmptyStr
111+
attribute: NotEmptyStr
112112
value: Union[NotEmptyStr, float, int]
113113

114114
class Config:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TmpImageEntity(Entity):
3131
segmentation_status: Optional[SegmentationStatus] = Field(
3232
SegmentationStatus.NOT_STARTED
3333
)
34-
approval_status: bool = None
34+
approval_status: Optional[bool] = Field(None)
3535

3636
class Config:
3737
extra = Extra.ignore

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ def execute(self):
584584
project_id=self._project.uuid,
585585
from_folder_id=self._from_folder.uuid,
586586
to_folder_id=self._to_folder.uuid,
587-
images=self._image_names[i : i + self.CHUNK_SIZE],
587+
items=self._image_names[i : i + self.CHUNK_SIZE],
588588
include_annotations=self._include_annotations,
589589
include_pin=self._include_pin,
590590
)

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

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -321,37 +321,31 @@ def _validate_limitations(self, items_count):
321321
if items_count > response.data.project_limit.remaining_image_count:
322322
raise AppValidationException(constances.COPY_PROJECT_LIMIT_ERROR_MESSAGE)
323323

324-
def validate_project_type(self):
325-
if self._project.project_type in constances.LIMITED_FUNCTIONS:
326-
raise AppValidationException(
327-
constances.LIMITED_FUNCTIONS[self._project.project_type]
328-
)
329-
330324
def validate_item_names(self):
331325
if self._item_names:
332326
self._item_names = list(set(self._item_names))
333327

334328
def execute(self):
335329
if self.is_valid():
336-
skipped_images, duplications = [], []
337-
if not self._item_names:
330+
if self._item_names:
331+
items = self._items
332+
else:
338333
condition = (
339334
Condition("team_id", self._project.team_id, EQ)
340335
& Condition("project_id", self._project.uuid, EQ)
341336
& Condition("folder_id", self._from_folder.uuid, EQ)
342337
)
343-
items = self._items.get_all(condition)
344-
items_to_copy = [item.name for item in items]
345-
else:
346-
items = self._backend_service.get_bulk_images(
347-
project_id=self._project.uuid,
348-
team_id=self._project.team_id,
349-
folder_id=self._to_folder.uuid,
350-
images=self._item_names,
351-
)
352-
duplications = [item["name"] for item in items]
353-
items_to_copy = set(self._item_names) - set(duplications)
354-
skipped_images = duplications
338+
items = [item.name for item in self._items.get_all(condition)]
339+
340+
existing_items = self._backend_service.get_bulk_images(
341+
project_id=self._project.uuid,
342+
team_id=self._project.team_id,
343+
folder_id=self._to_folder.uuid,
344+
images=items,
345+
)
346+
duplications = [item["name"] for item in existing_items]
347+
items_to_copy = list(set(items) - set(duplications))
348+
skipped_images = duplications
355349
try:
356350
self._validate_limitations(len(items_to_copy))
357351
except AppValidationException as e:
@@ -382,7 +376,7 @@ def execute(self):
382376
self._response.errors = AppException(e)
383377
return self._response
384378
self.reporter.log_info(
385-
f"Copied {len(items_to_copy)}/{len(items)} items(s) from "
379+
f"Copied {len(items_to_copy)}/{len(items)} item(s) from "
386380
f"{self._project.name}{'' if self._from_folder.is_root else f'/{self._from_folder.name}'} to "
387381
f"{self._project.name}{'' if self._to_folder.is_root else f'/{self._to_folder.name}'}"
388382
)
@@ -394,14 +388,14 @@ class MoveItems(BaseReportableUseCae):
394388
CHUNK_SIZE = 1000
395389

396390
def __init__(
397-
self,
398-
reporter: Reporter,
399-
project: ProjectEntity,
400-
from_folder: FolderEntity,
401-
to_folder: FolderEntity,
402-
item_names: List[str],
403-
items: BaseReadOnlyRepository,
404-
backend_service_provider: SuperannotateServiceProvider,
391+
self,
392+
reporter: Reporter,
393+
project: ProjectEntity,
394+
from_folder: FolderEntity,
395+
to_folder: FolderEntity,
396+
item_names: List[str],
397+
items: BaseReadOnlyRepository,
398+
backend_service_provider: SuperannotateServiceProvider,
405399
):
406400
super().__init__(reporter)
407401
self._project = project
@@ -452,11 +446,11 @@ def execute(self):
452446
project_id=self._project.uuid,
453447
from_folder_id=self._from_folder.uuid,
454448
to_folder_id=self._to_folder.uuid,
455-
images=items[i : i + self.CHUNK_SIZE], # noqa: E203
449+
images=items[i: i + self.CHUNK_SIZE], # noqa: E203
456450
)
457451
)
458452
self.reporter.log_info(
459-
f"Moved {len(moved_images)}/{len(items)} items(s) from "
453+
f"Moved {len(moved_images)}/{len(items)} item(s) from "
460454
f"{self._project.name}{'' if self._from_folder.is_root else f'/{self._from_folder.name}'} to "
461455
f"{self._project.name}{'' if self._to_folder.is_root else f'/{self._to_folder.name}'}"
462456
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def execute(self):
753753
old_settings = self._settings.get_all()
754754
attr_id_mapping = {}
755755
for setting in old_settings:
756-
attr_id_mapping[setting.attribute] = setting.uuid
756+
attr_id_mapping[setting.attribute] = setting.id
757757

758758
new_settings_to_update = []
759759
for new_setting in self._to_update:

src/superannotate/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "4.3.3dev1"
1+
__version__ = "4.3.3dev2"

tests/integration/annotations/test_annotation_class_new.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
class TestAnnotationClasses(BaseTestCase):
1010
PROJECT_NAME = "test_annotation_class_new"
11-
PROJECT_NAME_JSON = "test_annotation_class_json"
1211
PROJECT_DESCRIPTION = "desc"
1312
PROJECT_TYPE = "Vector"
1413

@@ -34,11 +33,11 @@ def test_annotation_classes_filter(self):
3433

3534
def test_create_annotation_class_from_json(self):
3635
sa.create_annotation_classes_from_classes_json(
37-
self.PROJECT_NAME_JSON, self.classes_json
36+
self.PROJECT_NAME, self.classes_json
3837
)
39-
self.assertEqual(len(sa.search_annotation_classes(self.PROJECT_NAME_JSON)), 4)
38+
self.assertEqual(len(sa.search_annotation_classes(self.PROJECT_NAME)), 4)
4039

4140
sa.create_annotation_classes_from_classes_json(
42-
self.PROJECT_NAME_JSON, self.classes_json
41+
self.PROJECT_NAME, self.classes_json
4342
)
44-
self.assertEqual(len(sa.search_annotation_classes(self.PROJECT_NAME_JSON)), 4)
43+
self.assertEqual(len(sa.search_annotation_classes(self.PROJECT_NAME)), 4)

0 commit comments

Comments
 (0)