Skip to content

Commit b72137d

Browse files
authored
Merge pull request #606 from superannotateai/1939_jsonschema
1939 jsonschema
2 parents 884a496 + 10315fa commit b72137d

File tree

8 files changed

+3371
-11
lines changed

8 files changed

+3371
-11
lines changed

CHANGELOG.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ ______________________
1212
**Updated**
1313

1414
- ``SAClient.get_annotations_per_frame()`` Added interpolation of polygonal and polyline annotations.
15-
15+
1616
**Fixed**
1717

1818
- ``SAClient.add_contributors_to_project()`` method.
1919
- ``SAClient.run_prediction()`` method.
20-
20+
2121
**Removed**
2222

2323
- ``SAClient.create_project_from_metadata()`` method.

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,11 @@ async def distribute_queues(self, items_to_upload: List[ItemToUpload]):
334334
if not processed:
335335
try:
336336
item_to_upload.file = io.StringIO()
337-
json.dump(item_to_upload.annotation_json, item_to_upload.file)
337+
json.dump(
338+
item_to_upload.annotation_json,
339+
item_to_upload.file,
340+
allow_nan=False,
341+
)
338342
item_to_upload.file.seek(0, os.SEEK_END)
339343
item_to_upload.file_size = item_to_upload.file.tell()
340344
item_to_upload.file.seek(0)
@@ -358,11 +362,13 @@ async def distribute_queues(self, items_to_upload: List[ItemToUpload]):
358362
break
359363
self._small_files_queue.put_nowait(item_to_upload)
360364
break
361-
except Exception:
362-
logger.debug(traceback.format_exc())
363-
self._report.failed_annotations.append(
364-
item_to_upload.annotation_json["metadata"]["name"]
365-
)
365+
except Exception as e:
366+
name = item_to_upload.annotation_json["metadata"]["name"]
367+
if isinstance(e, ValueError):
368+
logger.debug(f"Invalid annotation {name}: {e}")
369+
else:
370+
logger.debug(traceback.format_exc())
371+
self._report.failed_annotations.append(name)
366372
self.reporter.update_progress()
367373
data[idx][1] = True # noqa
368374
processed_count += 1
@@ -784,7 +790,6 @@ def execute(self):
784790
try:
785791
run_async(self.run_workers(items_to_upload))
786792
except Exception as e:
787-
raise e
788793
logger.debug(e)
789794
self._response.errors = AppException("Can't upload annotations.")
790795
self.reporter.finish_progress()
@@ -977,7 +982,7 @@ def execute(self):
977982
)
978983
if not errors:
979984
annotation_file = io.StringIO()
980-
json.dump(annotation_json, annotation_file)
985+
json.dump(annotation_json, annotation_file, allow_nan=False)
981986
size = annotation_file.tell()
982987
annotation_file.seek(0)
983988
if size > BIG_FILE_THRESHOLD:

src/superannotate/lib/infrastructure/services/annotation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ async def upload_big_annotation(
341341
),
342342
params=params,
343343
headers=headers,
344-
data=json.dumps({"data_chunk": chunk}),
344+
data=json.dumps({"data_chunk": chunk}, allow_nan=False),
345345
)
346346
if not response.ok:
347347
raise AppException(str(await response.text()))
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
[
2+
{
3+
"id": 55917,
4+
"project_id": 11979,
5+
"name": "Personal vehicle",
6+
"color": "#ecb65f",
7+
"count": 25,
8+
"createdAt": "2020-10-12T11:35:20.000Z",
9+
"updatedAt": "2020-10-12T11:48:19.000Z",
10+
"attribute_groups": [
11+
{
12+
"id": 17245,
13+
"class_id": 55917,
14+
"name": "Num doors",
15+
"is_multiselect": 0,
16+
"createdAt": "2020-10-12T11:35:20.000Z",
17+
"updatedAt": "2020-10-12T11:35:20.000Z",
18+
"attributes": [
19+
{
20+
"id": 62792,
21+
"group_id": 17245,
22+
"project_id": 11979,
23+
"name": "2",
24+
"count": 1,
25+
"createdAt": "2020-10-12T11:35:20.000Z",
26+
"updatedAt": "2020-10-12T11:46:28.000Z"
27+
},
28+
{
29+
"id": 62793,
30+
"group_id": 17245,
31+
"project_id": 11979,
32+
"name": "4",
33+
"count": 1,
34+
"createdAt": "2020-10-12T11:35:20.000Z",
35+
"updatedAt": "2020-10-12T11:35:20.000Z"
36+
}
37+
]
38+
}
39+
]
40+
},
41+
{
42+
"id": 55918,
43+
"project_id": 11979,
44+
"name": "Large vehicle",
45+
"color": "#737b28",
46+
"count": 1,
47+
"createdAt": "2020-10-12T11:35:20.000Z",
48+
"updatedAt": "2020-10-12T11:48:19.000Z",
49+
"attribute_groups": [
50+
{
51+
"id": 17246,
52+
"class_id": 55918,
53+
"name": "swedish",
54+
"is_multiselect": 0,
55+
"createdAt": "2020-10-12T11:35:20.000Z",
56+
"updatedAt": "2020-10-12T11:35:20.000Z",
57+
"attributes": [
58+
{
59+
"id": 62794,
60+
"group_id": 17246,
61+
"project_id": 11979,
62+
"name": "yes",
63+
"count": 0,
64+
"createdAt": "2020-10-12T11:35:20.000Z",
65+
"updatedAt": "2020-10-12T11:35:20.000Z"
66+
},
67+
{
68+
"id": 62795,
69+
"group_id": 17246,
70+
"project_id": 11979,
71+
"name": "no",
72+
"count": 1,
73+
"createdAt": "2020-10-12T11:35:20.000Z",
74+
"updatedAt": "2020-10-12T11:46:28.000Z"
75+
}
76+
]
77+
},
78+
{
79+
"id": 17247,
80+
"class_id": 55918,
81+
"name": "Num doors",
82+
"is_multiselect": 0,
83+
"createdAt": "2020-10-12T11:35:20.000Z",
84+
"updatedAt": "2020-10-12T11:35:20.000Z",
85+
"attributes": [
86+
{
87+
"id": 62796,
88+
"group_id": 17247,
89+
"project_id": 11979,
90+
"name": "2",
91+
"count": 0,
92+
"createdAt": "2020-10-12T11:35:20.000Z",
93+
"updatedAt": "2020-10-12T11:35:20.000Z"
94+
},
95+
{
96+
"id": 62797,
97+
"group_id": 17247,
98+
"project_id": 11979,
99+
"name": "4",
100+
"count": 1,
101+
"createdAt": "2020-10-12T11:35:20.000Z",
102+
"updatedAt": "2020-10-12T11:46:28.000Z"
103+
}
104+
]
105+
}
106+
]
107+
},
108+
{
109+
"id": 55919,
110+
"project_id": 11979,
111+
"name": "Human",
112+
"color": "#e4542b",
113+
"count": 9,
114+
"createdAt": "2020-10-12T11:35:20.000Z",
115+
"updatedAt": "2020-10-12T11:48:14.000Z",
116+
"attribute_groups": [
117+
{
118+
"id": 17248,
119+
"class_id": 55919,
120+
"name": "Height",
121+
"is_multiselect": 0,
122+
"createdAt": "2020-10-12T11:35:20.000Z",
123+
"updatedAt": "2020-10-12T11:35:20.000Z",
124+
"attributes": [
125+
{
126+
"id": 62798,
127+
"group_id": 17248,
128+
"project_id": 11979,
129+
"name": "Tall",
130+
"count": 0,
131+
"createdAt": "2020-10-12T11:35:20.000Z",
132+
"updatedAt": "2020-10-12T11:35:20.000Z"
133+
},
134+
{
135+
"id": 62799,
136+
"group_id": 17248,
137+
"project_id": 11979,
138+
"name": "Short",
139+
"count": 0,
140+
"createdAt": "2020-10-12T11:35:20.000Z",
141+
"updatedAt": "2020-10-12T11:35:20.000Z"
142+
}
143+
]
144+
}
145+
]
146+
},
147+
{
148+
"id": 55920,
149+
"project_id": 11979,
150+
"name": "Plant",
151+
"color": "#46ccb2",
152+
"count": 0,
153+
"createdAt": "2020-10-12T11:35:20.000Z",
154+
"updatedAt": "2020-10-12T11:35:20.000Z",
155+
"attribute_groups": []
156+
},
157+
{
158+
"id": 55921,
159+
"project_id": 11979,
160+
"type": "tag",
161+
"name": "Tag_Class",
162+
"color": "#46ccb2",
163+
"count": 0,
164+
"createdAt": "2020-10-12T11:35:20.000Z",
165+
"updatedAt": "2020-10-12T11:35:20.000Z",
166+
"attribute_groups": []
167+
},
168+
{
169+
"id": 55923,
170+
"project_id": 11979,
171+
"type": "tag",
172+
"name": "Tag_Class_2",
173+
"color": "#46ccb2",
174+
"count": 0,
175+
"createdAt": "2020-10-12T11:35:20.000Z",
176+
"updatedAt": "2020-10-12T11:35:20.000Z",
177+
"attribute_groups": []
178+
}
179+
]
209 KB
Loading
15.4 KB
Loading

0 commit comments

Comments
 (0)