Skip to content

Commit d6add78

Browse files
committed
test changes
1 parent 2709cc4 commit d6add78

File tree

8 files changed

+73
-73
lines changed

8 files changed

+73
-73
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ async def upload(_chunk):
150150
for i in chunk:
151151
callback(i)
152152
except Exception:
153-
logger.debug(traceback.format_exc())
153+
logger.debug(traceback.print_exc())
154154
failed_annotations.extend([i.item.name for i in chunk])
155155
finally:
156156
report.failed_annotations.extend(failed_annotations)
@@ -513,9 +513,10 @@ def prepare_annotation(self, annotation: dict, size) -> dict:
513513
service_provider=self._service_provider,
514514
)
515515
errors = use_case.execute().data
516-
logger.debug("Invalid json data")
517-
logger.debug("\n".join(["-".join(i) for i in use_case.execute().data if i]))
516+
518517
if errors:
518+
logger.debug("Invalid json data")
519+
logger.debug("\n".join(["-".join(i) for i in errors]))
519520
raise AppException(errors)
520521

521522
annotation = UploadAnnotationUseCase.set_defaults(

src/superannotate/lib/core/video_convertor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def _process(self):
187187
interpolated_frames = {}
188188
for timestamp in parameter["timestamps"]:
189189
frames_mapping[
190-
int(math.ceil(timesstamp["timestamp"] / self.ratio))
190+
int(math.ceil(timestamp["timestamp"] / self.ratio))
191191
].append(timestamp)
192192
frames_mapping = self.merge_first_frame(frames_mapping)
193193

tests/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import sys
21
import os
2+
import sys
33
from pathlib import Path
44

5-
65
os.environ.update({"SA_VERSION_CHECK": "False"})
76

87
LIB_PATH = Path(__file__).parent.parent / "src"
@@ -12,3 +11,8 @@
1211
__all__ = [
1312
"DATA_SET_PATH"
1413
]
14+
15+
from src.superannotate import get_default_logger
16+
17+
logger = get_default_logger()
18+
logger.setLevel("DEBUG")

tests/data_set/sample_video_num_free_text/sample_video.mp4.json

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
{
22
"metadata": {
33
"name": "Go_out_avi.avi",
4+
"width": 480,
5+
"height": 360,
6+
"status": "InProgress",
7+
"url": "videos/videos/Go_out_avi.avi",
48
"duration": 160440000,
5-
"annotatorEmail": "automation_sa@mailinator.com",
9+
"projectId": 214122,
610
"error": false,
7-
"height": 360,
11+
"annotatorEmail": "automation_sa@mailinator.com",
12+
"qaEmail": "test_automation1@mailinator.com",
813
"lastAction": {
914
"timestamp": 1669189913059,
1015
"email": "arturn@superannotate.com"
11-
},
12-
"projectId": 214122,
13-
"qaEmail": "test_automation1@mailinator.com",
14-
"status": "InProgress",
15-
"url": "videos/videos/Go_out_avi.avi",
16-
"width": 480
16+
}
1717
},
1818
"instances": [
1919
{
2020
"meta": {
2121
"type": "bbox",
22-
"classId": 1820068,
23-
"className": "car",
22+
"pointLabels": {},
2423
"createdBy": {
2524
"email": "arturn@superannotate.com",
2625
"role": "Admin"
@@ -31,9 +30,10 @@
3130
"role": "Admin"
3231
},
3332
"updatedAt": "2022-11-23T07:51:12.500Z",
33+
"classId": 1820068,
34+
"className": "car",
3435
"start": 72377,
35-
"end": 2270513,
36-
"pointLabels": {}
36+
"end": 2270513
3737
},
3838
"parameters": [
3939
{
@@ -167,8 +167,10 @@
167167
{
168168
"meta": {
169169
"type": "bbox",
170-
"classId": 1820068,
171-
"className": "car",
170+
"pointLabels": {
171+
"0": "testlabel",
172+
"2": "label2"
173+
},
172174
"createdBy": {
173175
"email": "arturn@superannotate.com",
174176
"role": "Admin"
@@ -179,12 +181,10 @@
179181
"role": "Admin"
180182
},
181183
"updatedAt": "2022-11-23T07:48:01.953Z",
184+
"classId": 1820068,
185+
"className": "car",
182186
"start": 15967742,
183-
"end": 26167742,
184-
"pointLabels": {
185-
"0": "testlabel",
186-
"2": "label2"
187-
}
187+
"end": 26167742
188188
},
189189
"parameters": [
190190
{
@@ -228,8 +228,6 @@
228228
{
229229
"meta": {
230230
"type": "point",
231-
"classId": 1645591,
232-
"className": "class3",
233231
"createdBy": {
234232
"email": "arturn@superannotate.com",
235233
"role": "Admin"
@@ -240,6 +238,8 @@
240238
"role": "Admin"
241239
},
242240
"updatedAt": "2022-07-04T10:49:10.454Z",
241+
"classId": 1645591,
242+
"className": "class3",
243243
"start": 2154547,
244244
"end": 3836690
245245
},
@@ -273,8 +273,6 @@
273273
{
274274
"meta": {
275275
"type": "event",
276-
"classId": 1645591,
277-
"className": "class3",
278276
"createdBy": {
279277
"email": "arturn@superannotate.com",
280278
"role": "Admin"
@@ -285,6 +283,8 @@
285283
"role": "Admin"
286284
},
287285
"updatedAt": "2022-07-04T10:49:10.455Z",
286+
"classId": 1645591,
287+
"className": "class3",
288288
"start": 5131014,
289289
"end": 6517905
290290
},
@@ -308,8 +308,6 @@
308308
{
309309
"meta": {
310310
"type": "polygon",
311-
"classId": 1820067,
312-
"className": "tree",
313311
"createdBy": {
314312
"email": "arturn@superannotate.com",
315313
"role": "Admin"
@@ -320,6 +318,8 @@
320318
"role": "Admin"
321319
},
322320
"updatedAt": "2022-10-18T11:21:20.267Z",
321+
"classId": 1820067,
322+
"className": "tree",
323323
"start": 11704101,
324324
"end": 19463671
325325
},
@@ -404,8 +404,6 @@
404404
{
405405
"meta": {
406406
"type": "polyline",
407-
"classId": 1820067,
408-
"className": "tree",
409407
"createdBy": {
410408
"email": "arturn@superannotate.com",
411409
"role": "Admin"
@@ -416,6 +414,8 @@
416414
"role": "Admin"
417415
},
418416
"updatedAt": "2022-10-18T11:23:40.500Z",
417+
"classId": 1820067,
418+
"className": "tree",
419419
"start": 8616210,
420420
"end": 12391405
421421
},
@@ -500,8 +500,6 @@
500500
{
501501
"meta": {
502502
"type": "point",
503-
"classId": 1820067,
504-
"className": "tree",
505503
"createdBy": {
506504
"email": "arturn@superannotate.com",
507505
"role": "Admin"
@@ -512,6 +510,8 @@
512510
"role": "Admin"
513511
},
514512
"updatedAt": "2022-11-09T14:55:50.645Z",
513+
"classId": 1820067,
514+
"className": "tree",
515515
"start": 28737304,
516516
"end": 45725853
517517
},
@@ -630,8 +630,6 @@
630630
{
631631
"meta": {
632632
"type": "tag",
633-
"classId": 1645589,
634-
"className": "class1",
635633
"createdBy": {
636634
"email": "arturn@superannotate.com",
637635
"role": "Admin"
@@ -642,6 +640,8 @@
642640
"role": "Admin"
643641
},
644642
"updatedAt": "2022-08-10T11:54:37.707Z",
643+
"classId": 1645589,
644+
"className": "class1",
645645
"attributes": [
646646
{
647647
"id": 4396132,
@@ -655,8 +655,6 @@
655655
{
656656
"meta": {
657657
"type": "tag",
658-
"classId": 2012407,
659-
"className": "class_tag",
660658
"createdBy": {
661659
"email": "arturn@superannotate.com",
662660
"role": "Admin"
@@ -667,15 +665,17 @@
667665
"role": "Admin"
668666
},
669667
"updatedAt": "2022-11-23T07:51:53.052Z",
668+
"classId": 2012407,
669+
"className": "class_tag",
670670
"attributes": [
671671
{
672+
"name": 3,
672673
"groupId": 3077618,
673-
"name": "",
674674
"groupName": "numeric_group_tag"
675675
},
676676
{
677+
"name": "text_tag",
677678
"groupId": 3077617,
678-
"name": "",
679679
"groupName": "text_group_tag"
680680
},
681681
{
@@ -706,8 +706,7 @@
706706
"role": "Admin"
707707
},
708708
"updatedAt": "2022-11-09T14:26:35.123Z",
709-
"start": 9801951,
710-
"end": 12240000,
709+
"resolved": true,
711710
"correspondence": [
712711
{
713712
"email": "arturn@superannotate.com",
@@ -722,7 +721,8 @@
722721
"createdAt": "2022-11-09T14:26:32.861Z"
723722
}
724723
],
725-
"resolved": true
724+
"start": 9801951,
725+
"end": 12240000
726726
},
727727
"parameters": [
728728
{
@@ -773,8 +773,7 @@
773773
"role": "Admin"
774774
},
775775
"updatedAt": "2022-11-09T13:30:49.326Z",
776-
"start": 24231219,
777-
"end": 30152195,
776+
"resolved": false,
778777
"correspondence": [
779778
{
780779
"email": "arturn@superannotate.com",
@@ -783,7 +782,8 @@
783782
"createdAt": "2022-11-09T13:30:26.194Z"
784783
}
785784
],
786-
"resolved": true
785+
"start": 24231219,
786+
"end": 30152195
787787
},
788788
"parameters": [
789789
{

tests/integration/annotations/video/test_video_annotation_upload.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,52 @@
11
import os
22
import tempfile
3-
from pathlib import Path
43

54
import pytest
65

76
from src.superannotate import SAClient
7+
from tests import DATA_SET_PATH
88
from tests.integration.base import BaseTestCase
99

10-
1110
sa = SAClient()
1211

1312

1413
class TestUploadVideoAnnotation(BaseTestCase):
1514
PROJECT_NAME = "video annotation upload"
16-
PATH_TO_URLS = "data_set/attach_video_for_annotation.csv"
15+
PATH_TO_URLS = "attach_video_for_annotation.csv"
1716
PROJECT_DESCRIPTION = "desc"
1817
PROJECT_TYPE = "Video"
19-
ANNOTATIONS_PATH = "data_set/video_annotation"
20-
ANNOTATIONS_WITHOUT_CLASSES_PATH = "data_set/annotations"
21-
CLASSES_PATH = "data_set/video_annotation/classes/classes.json"
22-
ANNOTATIONS_PATH_INVALID_JSON = "data_set/video_annotation_invalid_json"
23-
MINIMAL_ANNOTATION_PATH = "data_set/video_annotation_minimal_fields"
24-
MINIMAL_ANNOTATION_TRUTH_PATH = "data_set/minimal_video_annotation_truth"
18+
ANNOTATIONS_PATH = "video_annotation"
19+
ANNOTATIONS_WITHOUT_CLASSES_PATH = "annotations"
20+
CLASSES_PATH = "video_annotation/classes/classes.json"
21+
ANNOTATIONS_PATH_INVALID_JSON = "video_annotation_invalid_json"
22+
MINIMAL_ANNOTATION_PATH = "video_annotation_minimal_fields"
23+
MINIMAL_ANNOTATION_TRUTH_PATH = "minimal_video_annotation_truth"
2524

2625
maxDiff = None
2726

2827
@property
2928
def minimal_annotation_truth_path(self):
30-
return os.path.join(self.folder_path, self.MINIMAL_ANNOTATION_TRUTH_PATH)
31-
32-
@property
33-
def folder_path(self):
34-
return Path(__file__).parent.parent.parent
29+
return os.path.join(DATA_SET_PATH, self.MINIMAL_ANNOTATION_TRUTH_PATH)
3530

3631
@property
3732
def csv_path(self):
38-
return os.path.join(self.folder_path, self.PATH_TO_URLS)
33+
return os.path.join(DATA_SET_PATH, self.PATH_TO_URLS)
3934

4035
@property
4136
def annotations_path(self):
42-
return os.path.join(self.folder_path, self.ANNOTATIONS_PATH)
43-
44-
@property
45-
def minimal_annotations_path(self):
46-
return os.path.join(self.folder_path, self.MINIMAL_ANNOTATION_PATH)
37+
return os.path.join(DATA_SET_PATH, self.ANNOTATIONS_PATH)
4738

4839
@property
4940
def annotations_without_classes(self):
50-
return os.path.join(self.folder_path, self.ANNOTATIONS_WITHOUT_CLASSES_PATH)
41+
return os.path.join(DATA_SET_PATH, self.ANNOTATIONS_WITHOUT_CLASSES_PATH)
5142

5243
@property
5344
def invalid_annotations_path(self):
54-
return os.path.join(self.folder_path, self.ANNOTATIONS_PATH_INVALID_JSON)
45+
return os.path.join(DATA_SET_PATH, self.ANNOTATIONS_PATH_INVALID_JSON)
5546

5647
@property
5748
def classes_path(self):
58-
return os.path.join(self.folder_path, self.CLASSES_PATH)
49+
return os.path.join(DATA_SET_PATH, self.CLASSES_PATH)
5950

6051
@pytest.fixture(autouse=True)
6152
def inject_fixtures(self, caplog):

tests/integration/annotations/video/test_video_free_text_numeric.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23

34
from tests import DATA_SET_PATH
@@ -27,6 +28,9 @@ def test_upload(self):
2728
)
2829
(uploaded_annotations, failed_annotations, missing_annotations) = sa.upload_annotations_from_folder_to_project(
2930
self.PROJECT_NAME, self.folder_path)
30-
self.assertEqual(len(uploaded_annotations), 0)
31-
self.assertEqual(len(failed_annotations), 1)
31+
self.assertEqual(len(uploaded_annotations), 1)
32+
self.assertEqual(len(failed_annotations), 0)
3233
self.assertEqual(len(missing_annotations), 0)
34+
annotation = sa.get_annotations(self.PROJECT_NAME)[0]
35+
local_annotation = json.load(open(os.path.join(self.folder_path, (self.ITEM_NAME + ".json"))))
36+
assert len(annotation['instances']) == len(local_annotation['instances'])

0 commit comments

Comments
 (0)