Skip to content

Commit 9eba022

Browse files
authored
Merge pull request #574 from superannotateai/1797_fix
fix clone_project upload_state issue
2 parents 52229ad + 7c3e8a5 commit 9eba022

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

docs/source/api_reference/api_annotation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ Annotations
99
.. automethod:: superannotate.SAClient.set_annotation_statuses
1010
.. automethod:: superannotate.SAClient.delete_annotations
1111
.. _ref_upload_annotations_from_folder_to_project:
12-
.. automethod:: superannotate.SAClient.upload_annotations_from_folder_to_project
12+
.. automethod:: superannotate.SAClient.upload_annotations_from_folder_to_project

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,9 @@ def create_project(
359359
if invalid_classes:
360360
seen = set()
361361
seen_add = seen.add
362-
invalid_classes = [i for i in invalid_classes if not (i in seen or seen_add(i))]
362+
invalid_classes = [
363+
i for i in invalid_classes if not (i in seen or seen_add(i))
364+
]
363365
raise AppException(
364366
f"There are no [{', '.join(invalid_classes)}] classes created in the project."
365367
)
@@ -475,13 +477,16 @@ def clone_project(
475477
f"Workflow is not supported in {project.type.name} project."
476478
)
477479
project_copy = copy.copy(project)
480+
if project_copy.type in (
481+
constants.ProjectType.VECTOR,
482+
constants.ProjectType.PIXEL,
483+
):
484+
project_copy.upload_state = constants.UploadState.INITIAL
478485
if project_description:
479486
project_copy.description = project_description
480487
else:
481488
project_copy.description = project.description
482489
project_copy.name = project_name
483-
if project.type in (constants.ProjectType.VECTOR, constants.ProjectType.PIXEL):
484-
project.upload_state = enums.UploadState.INITIAL
485490
create_response = self.controller.projects.create(project_copy)
486491
create_response.raise_for_status()
487492
new_project = create_response.data
@@ -501,7 +506,9 @@ def clone_project(
501506
project.classes = classes_response.data
502507
if copy_workflow:
503508
if not copy_annotation_classes:
504-
logger.info(f"Skipping the workflow clone from {from_project} to {project_name}.")
509+
logger.info(
510+
f"Skipping the workflow clone from {from_project} to {project_name}."
511+
)
505512
else:
506513
logger.info(f"Cloning workflow from {from_project} to {project_name}.")
507514
workflow_response = self.controller.projects.set_workflows(
@@ -2174,7 +2181,9 @@ def add_contributors_to_project(
21742181
"""
21752182
project = self.controller.projects.get_by_name(project).data
21762183
contributors = [
2177-
entities.ContributorEntity(user_id=email, user_role=constants.UserRole(role))
2184+
entities.ContributorEntity(
2185+
user_id=email, user_role=constants.UserRole(role)
2186+
)
21782187
for email in emails
21792188
]
21802189
response = self.controller.projects.add_contributors(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ def execute(self):
704704
team_users = set()
705705
project_users = {user.user_id for user in self._project.users}
706706
for user in self._team.users:
707-
if user['user_role'] > constances.UserRole.ADMIN.value:
708-
team_users.add(user['email'])
707+
if user["user_role"] > constances.UserRole.ADMIN.value:
708+
team_users.add(user["email"])
709709
# collecting pending team users which is not admin
710710
for user in self._team.pending_invitations:
711711
if user["user_role"] > constances.UserRole.ADMIN.value:

tests/integration/projects/test_clone_project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def test_clone_project(self):
8989
copy_annotation_classes=True,
9090
)
9191
self.assertEqual(
92-
new_project["upload_state"], constances.UploadState.EXTERNAL.name
92+
new_project["upload_state"], constances.UploadState.INITIAL.name
9393
)
9494
new_settings = sa.get_project_settings(self.PROJECT_NAME_2)
9595
for setting in new_settings:
@@ -211,7 +211,7 @@ def test_clone_video_project(self):
211211
)
212212
self.assertEqual(new_project["name"], self.PROJECT_NAME_2)
213213
self.assertEqual(new_project["type"].lower(), "video")
214-
self.assertEqual(new_project["description"], self._project_1['description'])
214+
self.assertEqual(new_project["description"], self._project_1["description"])
215215

216216
def test_clone_video_project_frame_mode_on(self):
217217
self._project_1 = sa.create_project(

0 commit comments

Comments
 (0)