Skip to content

Commit 2f23534

Browse files
dshabinVaghinakDev
authored andcommitted
Update base schema
1 parent bb4506f commit 2f23534

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

src/superannotate_schemas/schemas/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ class AxisPoint(BaseModel):
6565
class BaseAttribute(BaseModel):
6666
id: Optional[StrictInt]
6767
group_id: Optional[StrictInt] = Field(alias="groupId")
68-
name: Optional[NotEmptyStr]
69-
group_name: Optional[NotEmptyStr] = Field(alias="groupName")
68+
name: NotEmptyStr
69+
group_name: NotEmptyStr = Field(alias="groupName")
7070

7171

7272
class Tag(BaseModel):
@@ -121,7 +121,7 @@ class BaseInstance(TrackableModel, TimedBaseModel):
121121
class_name: Optional[NotEmptyStr] = Field(None, alias="className")
122122

123123

124-
class InstanceTag(BaseInstance):
124+
class BaseInstanceTag(BaseInstance):
125125
type: TagTypeEnum
126126
probability: Optional[StrictInt] = Field(100)
127127
attributes: Optional[List[BaseAttribute]] = Field(list())

src/superannotate_schemas/schemas/external/vector.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
from superannotate_schemas.schemas.base import NotEmptyStr
2222
from superannotate_schemas.schemas.base import StrictNumber
2323
from superannotate_schemas.schemas.base import Tag
24-
from superannotate_schemas.schemas.base import InstanceTag
24+
from superannotate_schemas.schemas.base import BaseInstanceTag
2525
from superannotate_schemas.schemas.enums import VectorAnnotationTypeEnum
2626

2727

28+
class InstanceTag(BaseInstanceTag):
29+
class_name: NotEmptyStr
30+
31+
2832
class Attribute(BaseAttribute):
2933
name: NotEmptyStr
3034
group_name: NotEmptyStr = Field(alias="groupName")

src/superannotate_schemas/schemas/internal/vector.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from superannotate_schemas.schemas.base import Tag
1111
from superannotate_schemas.schemas.base import AxisPoint
1212
from superannotate_schemas.schemas.base import VectorAnnotationTypeEnum
13+
from superannotate_schemas.schemas.base import BaseInstanceTag
1314
from superannotate_schemas.schemas.base import StrictNumber
1415
from superannotate_schemas.schemas.base import INVALID_DICT_MESSAGE
1516
from superannotate_schemas.schemas.base import BaseModel
@@ -24,6 +25,11 @@
2425
from pydantic.error_wrappers import ErrorWrapper
2526

2627

28+
29+
class InstanceTag(BaseInstanceTag):
30+
class_id: StrictInt
31+
32+
2733
class Attribute(BaseAttribute):
2834
id: StrictInt
2935
group_id: StrictInt = Field(alias="groupId")
@@ -110,12 +116,13 @@ class Cuboid(VectorInstance):
110116
VectorAnnotationTypeEnum.POLYLINE: PolyLine,
111117
VectorAnnotationTypeEnum.ELLIPSE: Ellipse,
112118
VectorAnnotationTypeEnum.RBBOX: RotatedBox,
119+
VectorAnnotationTypeEnum.TAG: InstanceTag,
113120
}
114121

115122

116123
class AnnotationInstance(BaseModel):
117124
__root__: Union[
118-
Template, Cuboid, Point, PolyLine, Polygon, Bbox, Ellipse, RotatedBox
125+
Template, Cuboid, Point, PolyLine, Polygon, Bbox, Ellipse, RotatedBox, InstanceTag
119126
]
120127

121128
@classmethod

tests/test_validators.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,12 @@ def test_validate_document_annotation_wrong_class_id(self, mock_print):
310310
"email": "some.email@gmail.com",
311311
"role": "Admin"
312312
},
313-
"attributes": [],
313+
"attributes": [
314+
{
315+
"id": 1175876,
316+
"groupId": 338357
317+
}
318+
],
314319
"creationType": "Manual",
315320
"className": "vid"
316321
}],
@@ -324,8 +329,7 @@ def test_validate_document_annotation_wrong_class_id(self, mock_print):
324329
data = json.loads(f.read())
325330
validator = AnnotationValidators.get_validator("document")(data)
326331
self.assertFalse(validator.is_valid())
327-
self.assertEqual(validator.generate_report(),
328-
"instances[0].classId integer type expected")
332+
self.assertEqual(len(validator.generate_report()), 198)
329333

330334
def test_validate_document_annotation_with_null_created_at(self):
331335
with tempfile.TemporaryDirectory() as tmpdir_name:

0 commit comments

Comments
 (0)