Skip to content

Commit a46c8d6

Browse files
authored
Merge pull request #373 from superannotateai/friday
Friday
2 parents 0e2b5cd + ab3bb84 commit a46c8d6

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2039,7 +2039,6 @@ def upload_preannotations_from_folder_to_project(
20392039
"The JSON files should follow a specific naming convention, matching file names already present "
20402040
"on the platform. Existing annotations will be overwritten"
20412041
)
2042-
logger.info("Existing annotations will be overwritten.",)
20432042
annotation_paths = get_annotation_paths(
20442043
folder_path, from_s3_bucket, recursive_subfolders
20452044
)
@@ -2051,6 +2050,7 @@ def upload_preannotations_from_folder_to_project(
20512050
folder_name=folder_name,
20522051
annotation_paths=annotation_paths, # noqa: E203
20532052
client_s3_bucket=from_s3_bucket,
2053+
folder_path=folder_path,
20542054
is_pre_annotations=True,
20552055
)
20562056
if response.errors:

tests/integration/test_interface.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ class TestInterface(BaseTestCase):
2020
NEW_IMAGE_NAME = "new_name_yup"
2121
IMAGE_PATH_IN_S3 = 'MP.MB/img1.bmp'
2222
TEST_S3_BUCKET_NAME = "test-openseadragon-1212"
23+
TEST_INVALID_ANNOTATION_FOLDER_PATH = "sample_project_vector_invalid"
24+
25+
@property
26+
def invalid_json_path(self):
27+
return os.path.join(self.data_set_path, self.TEST_INVALID_ANNOTATION_FOLDER_PATH)
2328

2429
@property
2530
def data_set_path(self):
@@ -172,6 +177,70 @@ def test_validate_log_for_single_uplaod(self):
172177
)
173178
self.assertEqual(len(logs[1][0]), 150)
174179

180+
sa.upload_image_annotations(
181+
self.PROJECT_NAME, self.EXAMPLE_IMAGE_1, {
182+
"metadata": {
183+
"name": "example_image_1.jpg",
184+
"width": 1024,
185+
"height": 683,
186+
"status": "Completed",
187+
},
188+
"instance": []
189+
}
190+
)
191+
self.assertEqual(len(logs[1][1]), 86)
192+
193+
sa.upload_images_from_folder_to_project(
194+
self.PROJECT_NAME, self.folder_path, annotation_status="InProgress"
195+
)
196+
uploaded_annotations, failed_annotations, missing_annotations = sa.upload_annotations_from_folder_to_project(
197+
self.PROJECT_NAME, self.invalid_json_path
198+
)
199+
self.assertEqual(len(uploaded_annotations), 3)
200+
self.assertEqual(len(failed_annotations), 1)
201+
self.assertEqual(len(missing_annotations), 0)
202+
self.assertEqual(len(logs[1][2].split("from")[0]), 98)
203+
self.assertEqual(len(logs[1][3]), 66)
204+
self.assertEqual(len(logs[1][4]), 53)
205+
self.assertEqual(len(logs[1][5]), 160)
206+
self.assertEqual(len(logs[1][6].split("from")[0]), 32)
207+
208+
uploaded_annotations, failed_annotations, missing_annotations = sa.upload_preannotations_from_folder_to_project(
209+
self.PROJECT_NAME, self.invalid_json_path
210+
)
211+
self.assertEqual(len(uploaded_annotations), 3)
212+
self.assertEqual(len(failed_annotations), 1)
213+
self.assertEqual(len(missing_annotations), 0)
214+
215+
with tempfile.TemporaryDirectory() as tmpdir_name:
216+
path = f"{tmpdir_name}/annotation___objects.json"
217+
with open(path, "w") as annotation:
218+
annotation.write(
219+
'''
220+
{
221+
"metadata": {
222+
"name": "text_file_example_1",
223+
"status": "NotStarted",
224+
"url": "https://sa-public-files.s3.us-west-2.amazonaws.com/Text+project/text_file_example_1.txt",
225+
"projectId": 167826,
226+
"annotatorEmail": null,
227+
"qaEmail": null,
228+
"lastAction": {
229+
"email": "some.email@gmail.com",
230+
"timestamp": 1636620976450
231+
}
232+
},
233+
"instances": [],
234+
"tags": []
235+
}
236+
'''
237+
)
238+
sa.upload_image_annotations(self.PROJECT_NAME, self.EXAMPLE_IMAGE_1, path)
239+
self.assertEqual(len(logs[1][-1]),86)
240+
self.assertEqual(len(logs[1][-2].split('from')[0]),30)
241+
242+
243+
175244

176245

177246
class TestPixelInterface(BaseTestCase):

0 commit comments

Comments
 (0)