Skip to content

Commit e2220d3

Browse files
committed
Added tags handeling, tests adjuted
1 parent d2b24a0 commit e2220d3

File tree

13 files changed

+33
-31
lines changed

13 files changed

+33
-31
lines changed

requirements_dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
superannotate_schemas>=1.0.38.b1
1+
superannotate_schemas==1.0.40b2

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def __copy__(self):
124124
team_id=self.team_id,
125125
name=self.name,
126126
project_type=self.project_type,
127-
description=self.description,
127+
description=self.description if self.description else f"Copy of {self.name}.",
128128
status=self.status,
129129
folder_id=self.folder_id,
130130
users=self.users,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ def __init__(
165165
projects: BaseManageableRepository,
166166
backend_service_provider: SuperannotateServiceProvider,
167167
settings_repo: Type[BaseManageableRepository],
168-
annotation_classes_repo: BaseManageableRepository,
169-
workflows_repo: BaseManageableRepository,
168+
annotation_classes_repo: Type[BaseManageableRepository],
169+
workflows_repo: Type[BaseManageableRepository],
170170
settings: List[ProjectSettingEntity] = None,
171171
workflows: List[WorkflowEntity] = None,
172172
annotation_classes: List[AnnotationClassEntity] = None,

src/superannotate/lib/infrastructure/controller.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,6 @@ def clone_project(
482482
project_to_create.name = name
483483
if project_description:
484484
project_to_create.description = project_description
485-
elif not project.description:
486-
project.description = f"Copy of {from_name}."
487-
488485
use_case = usecases.CloneProjectUseCase(
489486
reporter=self.default_reporter,
490487
project=project,

src/superannotate/lib/infrastructure/repositories.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ def get_all(self, condition: Condition = None) -> List[ProjectEntity]:
9999

100100
def insert(self, entity: ProjectEntity) -> ProjectEntity:
101101
project_data = self._drop_nones(entity.to_dict())
102+
if not project_data.get("status"):
103+
project_data["status"] = constance.ProjectStatus.NotStarted.value
102104
result = self._service.create_project(project_data)
103105
return self.dict2entity(result)
104106

@@ -118,21 +120,21 @@ def delete(self, entity: ProjectEntity):
118120
)
119121

120122
@staticmethod
121-
def dict2entity(data: dict):
123+
def dict2entity(data: dict) -> ProjectEntity:
122124
try:
123125
return ProjectEntity(
124126
uuid=data["id"],
125127
team_id=data["team_id"],
126128
name=data["name"],
127129
project_type=data["type"],
128-
status=data["status"],
129-
attachment_name=data["attachment_name"],
130-
attachment_path=data["attachment_path"],
131-
entropy_status=data["entropy_status"],
130+
status=data.get("status"),
131+
attachment_name=data.get("attachment_name"),
132+
attachment_path=data.get("attachment_path"),
133+
entropy_status=data.get("entropy_status"),
132134
sharing_status=data.get("sharing_status"),
133135
creator_id=data["creator_id"],
134136
upload_state=data["upload_state"],
135-
description=data["description"],
137+
description=data.get("description"),
136138
folder_id=data.get("folder_id"),
137139
users=data.get("users", ()),
138140
unverified_users=data.get("unverified_users", ()),
@@ -148,6 +150,7 @@ def dict2entity(data: dict):
148150

149151

150152
class S3Repository(BaseS3Repository):
153+
151154
def get_one(self, uuid: str) -> S3FileEntity:
152155
file = io.BytesIO()
153156
self._resource.Object(self._bucket, uuid).download_fileobj(file)
@@ -242,7 +245,7 @@ def update(self, entity: WorkflowEntity):
242245
raise NotImplementedError
243246

244247
@staticmethod
245-
def dict2entity(data: dict):
248+
def dict2entity(data: dict) -> WorkflowEntity:
246249
return WorkflowEntity(
247250
uuid=data["id"],
248251
project_id=data["project_id"],
@@ -294,7 +297,7 @@ def bulk_delete(self, entities: List[FolderEntity]):
294297
return self._service.delete_folders(entity.project_id, entity.team_id, ids)
295298

296299
@staticmethod
297-
def dict2entity(data: dict):
300+
def dict2entity(data: dict) -> FolderEntity:
298301
try:
299302
return FolderEntity(
300303
uuid=data["id"],
@@ -397,7 +400,7 @@ def update(self, entity: ImageEntity):
397400
return entity
398401

399402
@staticmethod
400-
def dict2entity(data: dict):
403+
def dict2entity(data: dict) -> ImageEntity:
401404
return ImageEntity(
402405
uuid=data["id"],
403406
name=data["name"],
@@ -416,7 +419,7 @@ def dict2entity(data: dict):
416419

417420
class UserRepository(BaseReadOnlyRepository):
418421
@staticmethod
419-
def dict2entity(data: dict):
422+
def dict2entity(data: dict) -> UserEntity:
420423
return UserEntity(
421424
uuid=data["id"],
422425
first_name=data["first_name"],
@@ -480,7 +483,7 @@ def update(self, entity: MLModelEntity):
480483
return self.dict2entity(data)
481484

482485
@staticmethod
483-
def dict2entity(data: dict):
486+
def dict2entity(data: dict) -> MLModelEntity:
484487
return MLModelEntity(
485488
uuid=data["id"],
486489
name=data["name"],

src/superannotate/lib/infrastructure/services.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ def delete_project(self, uuid: int, query_string: str = None) -> bool:
318318
res = self._request(url, "delete")
319319
return res.ok
320320

321-
def update_project(self, data: dict, query_string: str = None) -> bool:
321+
def update_project(self, data: dict, query_string: str = None) -> dict:
322322
url = urljoin(self.api_url, self.URL_GET_PROJECT.format(data["id"]))
323323
if query_string:
324324
url = f"{url}?{query_string}"
@@ -689,8 +689,6 @@ def get_bulk_images(
689689
self, project_id: int, team_id: int, folder_id: int, images: List[str]
690690
) -> List[dict]:
691691
bulk_get_images_url = urljoin(self.api_url, self.URL_BULK_GET_IMAGES)
692-
time.sleep(1)
693-
694692
res = self._request(
695693
bulk_get_images_url,
696694
"post",

tests/data_set/document_annotation/text_file_example_1.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"instances": [
1515
{
16+
"type": "entity",
1617
"start": 253,
1718
"end": 593,
1819
"classId": 873208,

tests/data_set/document_annotation_without_class_data/text_file_example_1.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
},
1414
"instances": [
1515
{
16+
"type": "entity",
1617
"start": 253,
1718
"end": 593,
1819
"classId": 873208,

tests/integration/classes/test_create_annotation_class.py

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

99

1010
class TestCreateAnnotationClass(BaseTestCase):
11-
PROJECT_NAME = "test_create_annotation_class"
11+
PROJECT_NAME = "TestCreateAnnotationClass"
1212
PROJECT_TYPE = "Vector"
1313
PROJECT_DESCRIPTION = "Example "
1414
TEST_LARGE_CLASSES_JSON = "large_classes_json.json"
@@ -29,7 +29,7 @@ def test_create_annotations_classes_from_class_json(self):
2929

3030

3131
class TestCreateAnnotationClassNonVectorWithError(BaseTestCase):
32-
PROJECT_NAME = "test_create_annotation_class"
32+
PROJECT_NAME = "TestCreateAnnotationClassNonVectorWithError"
3333
PROJECT_TYPE = "Video"
3434
PROJECT_DESCRIPTION = "Example Project test pixel basic images"
3535

@@ -43,7 +43,7 @@ def test_create_annotation_class(self):
4343

4444

4545
class TestCreateAnnotationClassesNonVectorWithError(BaseTestCase):
46-
PROJECT_NAME = "test_create_annotation_class"
46+
PROJECT_NAME = "TestCreateAnnotationClassesNonVectorWithError"
4747
PROJECT_TYPE = "Video"
4848
PROJECT_DESCRIPTION = "Example Project test pixel basic images"
4949

tests/integration/projects/test_basic_project.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_workflow_get(self):
9898

9999

100100
class TestProjectCreateMetadata(BaseTestCase):
101-
PROJECT_NAME = "sample_basic_project"
101+
PROJECT_NAME = "TestProjectCreateMetadata"
102102
PROJECT_TYPE = "Vector"
103103
OTHER_PROJECT_NAME = "other_project"
104104
PROJECT_DESCRIPTION = "DESCRIPTION"

0 commit comments

Comments
 (0)