Skip to content

Commit 745b948

Browse files
authored
Merge pull request #404 from superannotateai/friday
Friday
2 parents d0b7fbf + e377520 commit 745b948

File tree

15 files changed

+137
-46
lines changed

15 files changed

+137
-46
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

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ ffmpeg-python>=0.2.0
1616
fire==0.4.0
1717
mixpanel==4.8.3
1818
pydantic>=1.8.2
19-
pydantic[email]
2019
setuptools~=57.4.0
2120
aiohttp==3.8.1
2221

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def export_project(
123123
folders = None
124124
if folder_name:
125125
folders = [folder_name]
126-
export_res = self.controller.prepare_export(
126+
export_res = controller.prepare_export(
127127
project_name, folders, include_fuse, False, annotation_statuses
128128
)
129129
export_name = export_res.data["name"]
@@ -187,7 +187,7 @@ def _upload_annotations(
187187
self, project, folder, format, dataset_name, task, pre=True
188188
):
189189
project_name, folder_name = split_project_path(project)
190-
project = self.controller.get_project_metadata(project_name=project_name).data
190+
project = controller.get_project_metadata(project_name=project_name).data
191191
if not format:
192192
format = "SuperAnnotate"
193193
if not dataset_name and format == "COCO":

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def create_project(
181181
def create_project_from_metadata(project_metadata: Project):
182182
"""Create a new project in the team using project metadata object dict.
183183
Mandatory keys in project_metadata are "name", "description" and "type" (Vector or Pixel)
184-
Non-mandatory keys: "workflow", "contributors", "settings" and "annotation_classes".
184+
Non-mandatory keys: "workflow", "settings" and "annotation_classes".
185185
186186
:return: dict object metadata the new project
187187
:rtype: dict
@@ -191,7 +191,6 @@ def create_project_from_metadata(project_metadata: Project):
191191
name=project_metadata["name"],
192192
description=project_metadata["description"],
193193
project_type=project_metadata["type"],
194-
contributors=project_metadata.get("contributors", []),
195194
settings=project_metadata.get("settings", []),
196195
annotation_classes=project_metadata.get("classes", []),
197196
workflows=project_metadata.get("workflows", []),
@@ -2788,7 +2787,7 @@ def validate_annotations(
27882787
"""
27892788
with open(annotations_json) as file:
27902789
annotation_data = json.loads(file.read())
2791-
response = Controller.get_default().validate_annotations(
2790+
response = Controller.validate_annotations(
27922791
project_type, annotation_data, allow_extra=False
27932792
)
27942793
if response.errors:

src/superannotate/lib/core/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def generate_thumb(self):
9595
return buffer, width, height
9696

9797
def generate_huge(self, base_width: int = 600) -> Tuple[io.BytesIO, float, float]:
98-
im = self._image
98+
im = self._get_image()
9999
width, height = im.size
100100
buffer = io.BytesIO()
101101
h_size = int(height * base_width / width)
@@ -107,7 +107,7 @@ def generate_huge(self, base_width: int = 600) -> Tuple[io.BytesIO, float, float
107107
return buffer, width, height
108108

109109
def generate_low_resolution(self, quality: int = 60, subsampling: int = -1):
110-
im = self._image
110+
im = self._get_image()
111111
buffer = io.BytesIO()
112112
bg = Image.new("RGBA", im.size, (255, 255, 255))
113113
im = im.convert("RGBA")

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

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,18 @@ def execute(self):
125125
)
126126
data["project"] = project
127127
if self._include_complete_image_count:
128-
projects = self._projects.get_all(
129-
condition=(
130-
Condition("completeImagesCount", "true", EQ)
131-
& Condition("name", self._project.name, EQ)
132-
& Condition("team_id", self._project.team_id, EQ)
133-
)
128+
completed_images_data = self._service.bulk_get_folders(
129+
self._project.team_id, [project.uuid]
134130
)
135-
if projects:
136-
data["project"] = projects[0]
131+
root_completed_count = 0
132+
total_completed_count = 0
133+
for i in completed_images_data['data']:
134+
total_completed_count += i['completedCount']
135+
if i['is_root']:
136+
root_completed_count = i['completedCount']
137+
138+
project.root_folder_completed_images_count = root_completed_count
139+
project.completed_images_count = total_completed_count
137140

138141
if self._include_annotation_classes:
139142
self.annotation_classes_use_case.execute()
@@ -168,7 +171,6 @@ def __init__(
168171
settings: List[ProjectSettingEntity] = None,
169172
workflows: List[WorkflowEntity] = None,
170173
annotation_classes: List[AnnotationClassEntity] = None,
171-
contributors: Iterable[dict] = None,
172174
):
173175

174176
super().__init__()
@@ -180,7 +182,6 @@ def __init__(
180182
self._workflows_repo = workflows_repo
181183
self._workflows = workflows
182184
self._annotation_classes = annotation_classes
183-
self._contributors = contributors
184185
self._backend_service = backend_service_provider
185186

186187
def validate_project_name(self):
@@ -258,22 +259,6 @@ def execute(self):
258259
self._response.errors = set_workflow_response.errors
259260
data["workflows"] = self._workflows
260261

261-
if self._contributors:
262-
for contributor in self._contributors:
263-
self._backend_service.share_project_bulk(
264-
team_id=entity.team_id,
265-
project_id=entity.uuid,
266-
users=[
267-
{
268-
"user_id": contributor["user_id"],
269-
"user_role": constances.UserRole.get_value(
270-
contributor["user_role"]
271-
),
272-
}
273-
],
274-
)
275-
data["contributors"] = self._contributors
276-
277262
logger.info(
278263
"Created project %s (ID %s) with type %s",
279264
self._response.data.name,
@@ -701,8 +686,9 @@ def execute(self):
701686
if self._fill_classes:
702687
annotation_classes = self._annotation_classes.get_all()
703688
for annotation_class in annotation_classes:
704-
annotation_class.uuid = workflow.class_id
705-
workflow_data["className"] = annotation_class.name
689+
if annotation_class.id == workflow.class_id:
690+
workflow_data["className"] = annotation_class.name
691+
break
706692
data.append(workflow_data)
707693
self._response.data = data
708694
return self._response

src/superannotate/lib/infrastructure/controller.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ def create_project(
292292
name: str,
293293
description: str,
294294
project_type: str,
295-
contributors: Iterable = tuple(),
296295
settings: Iterable = tuple(),
297296
annotation_classes: Iterable = tuple(),
298297
workflows: Iterable = tuple(),
@@ -324,8 +323,7 @@ def create_project(
324323
annotation_classes=[
325324
AnnotationClassEntity(**annotation_class)
326325
for annotation_class in annotation_classes
327-
],
328-
contributors=contributors,
326+
]
329327
)
330328
return use_case.execute()
331329

@@ -1546,13 +1544,14 @@ def delete_annotations(
15461544
)
15471545
return use_case.execute()
15481546

1547+
@staticmethod
15491548
def validate_annotations(
1550-
self, project_type: str, annotation: dict, allow_extra: bool = False
1549+
project_type: str, annotation: dict, allow_extra: bool = False
15511550
):
15521551
use_case = usecases.ValidateAnnotationUseCase(
15531552
project_type,
15541553
annotation,
1555-
validators=self.annotation_validators,
1554+
validators=AnnotationValidators(),
15561555
allow_extra=allow_extra,
15571556
)
15581557
return use_case.execute()

src/superannotate/lib/infrastructure/stream_data_handler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def map_image_names_to_fetch_streamed_data(data: List[str]):
1313

1414

1515
class StreamedAnnotations:
16-
DELIMITER = b'\n:)\n'
16+
DELIMITER = b"\\n;)\\n"
1717

1818
def __init__(self, headers: dict):
1919
self._headers = headers

tests/conftest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import os
2+
import pytest
3+
4+
5+
@pytest.fixture(autouse=True)
6+
def tests_setup():
7+
os.environ.update({"SA_TESTING": "True"})

tests/integration/annotations/test_annotations_pre_processing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515

1616
class TestAnnotationUploadVector(BaseTestCase):
17-
PROJECT_NAME = "TestAnnotationUploadVector"
17+
PROJECT_NAME = "TestAnnotationUploadVectorPreProcessing"
1818
PROJECT_DESCRIPTION = "Desc"
1919
PROJECT_TYPE = "Vector"
2020
S3_FOLDER_PATH = "sample_project_pixel"

0 commit comments

Comments
 (0)