Skip to content

Commit 03c8753

Browse files
authored
Merge pull request #303 from superannotateai/432-483
Fix bug
2 parents f1962a8 + 864375a commit 03c8753

File tree

4 files changed

+121
-1
lines changed

4 files changed

+121
-1
lines changed

src/superannotate/lib/core/entities/pixel.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from lib.core.entities.utils import BaseModel
66
from lib.core.entities.utils import Metadata
77
from lib.core.entities.utils import Tag
8+
from lib.core.entities.utils import Comment
89
from pydantic import Field
910
from pydantic import validator
1011
from pydantic.color import Color
@@ -32,3 +33,4 @@ class PixelAnnotation(BaseModel):
3233
metadata: PixelMetaData
3334
instances: List[PixelAnnotationInstance]
3435
tags: Optional[List[Tag]] = Field(list())
36+
comments: Optional[List[Comment]] = Field(list())

src/superannotate/lib/core/entities/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ class BaseInstance(TrackableModel, TimedBaseModel):
135135

136136

137137
class MetadataBase(BaseModel):
138+
url: Optional[str]
138139
name: NotEmptyStr
139140
last_action: Optional[LastUserAction] = Field(None, alias="lastAction")
140141
width: Optional[int]

src/superannotate/lib/core/entities/video_export.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class VideoType(str, Enum):
2121

2222

2323
class MetaData(MetadataBase):
24-
url: Optional[str]
2524
duration: Optional[int]
2625
error: Optional[bool]
2726

tests/unit/test_validators.py

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,121 @@ def test_validate_annotation_with_wrong_bbox(self):
172172
"template,cuboid,polygon,point,polyline,ellipse,rbbox",
173173
out.getvalue().strip().replace(" ", "")
174174
)
175+
176+
def test_validate_document_annotation(self):
177+
with tempfile.TemporaryDirectory() as tmpdir_name:
178+
with open(f"{tmpdir_name}/doc.json", "w") as doc_json:
179+
doc_json.write(
180+
'''
181+
{
182+
"metadata": {
183+
"name": "text_file_example_1",
184+
"status": "NotStarted",
185+
"url": "https://sa-public-files.s3.us-west-2.amazonaws.com/Text+project/text_file_example_1.txt",
186+
"projectId": 167826,
187+
"annotatorEmail": null,
188+
"qaEmail": null,
189+
"lastAction": {
190+
"email": "some.email@gmail.com"
191+
"timestamp": 1636620976450
192+
}
193+
},
194+
"instances": [],
195+
"tags": [],
196+
"freeText": ""
197+
}
198+
'''
199+
)
200+
self.assertTrue(sa.validate_annotations("Document", os.path.join(self.vector_folder_path, f"{tmpdir_name}/doc.json")))
201+
202+
203+
def test_validate_pixel_annotation(self):
204+
with tempfile.TemporaryDirectory() as tmpdir_name:
205+
with open(f"{tmpdir_name}/pixel.json", "w") as pix_json:
206+
pix_json.write(
207+
'''
208+
{
209+
"metadata": {
210+
"lastAction": {
211+
"email": "some.email@gmail.com"
212+
"timestamp": 1636627539398
213+
},
214+
"width": 1024,
215+
"height": 683,
216+
"name": "example_image_1.jpg",
217+
"projectId": 164324,
218+
"isPredicted": false,
219+
"isSegmented": false,
220+
"status": "NotStarted",
221+
"pinned": false,
222+
"annotatorEmail": null,
223+
"qaEmail": null
224+
},
225+
"comments": [],
226+
"tags": [],
227+
"instances": []
228+
}
229+
'''
230+
)
231+
self.assertTrue(sa.validate_annotations("Pixel", os.path.join(self.vector_folder_path, f"{tmpdir_name}/pixel.json")))
232+
233+
def test_validate_video_export_annotation(self):
234+
with tempfile.TemporaryDirectory() as tmpdir_name:
235+
with open(f"{tmpdir_name}/video_export.json", "w") as video_export:
236+
video_export.write(
237+
'''
238+
{
239+
"metadata": {
240+
"name": "video.mp4",
241+
"width": 848,
242+
"height": 476,
243+
"status": "NotStarted",
244+
"url": "https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4",
245+
"duration": 2817000,
246+
"projectId": 164334,
247+
"error": null,
248+
"annotatorEmail": null,
249+
"qaEmail": null,
250+
"lastAction": {
251+
"timestamp": 1636384061135,
252+
"email": "some.email@gmail.com"
253+
}
254+
},
255+
"instances": [],
256+
"tags": []
257+
}
258+
'''
259+
)
260+
self.assertTrue(sa.validate_annotations("Video", os.path.join(self.vector_folder_path,
261+
f"{tmpdir_name}/video_export.json")))
262+
263+
264+
def test_validate_vector_empty_annotation(self):
265+
with tempfile.TemporaryDirectory() as tmpdir_name:
266+
with open(f"{tmpdir_name}/vector_empty.json", "w") as vector_empty:
267+
vector_empty.write(
268+
'''
269+
{
270+
"metadata": {
271+
"lastAction": {
272+
"email": "shab.prog@gmail.com",
273+
"timestamp": 1636627956948
274+
},
275+
"width": 1024,
276+
"height": 683,
277+
"name": "example_image_1.jpg",
278+
"projectId": 162462,
279+
"isPredicted": false,
280+
"status": "NotStarted",
281+
"pinned": false,
282+
"annotatorEmail": null,
283+
"qaEmail": null
284+
},
285+
"comments": [],
286+
"tags": [],
287+
"instances": []
288+
}
289+
'''
290+
)
291+
self.assertTrue(sa.validate_annotations("Vector", os.path.join(self.vector_folder_path,
292+
f"{tmpdir_name}/vector_empty.json")))

0 commit comments

Comments
 (0)