Skip to content

Commit edf6bf8

Browse files
dshabinVaghinak Basentsyan
authored andcommitted
Fix json validation
1 parent 44e78df commit edf6bf8

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/superannotate/lib/core/types.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from typing import List
22
from typing import Optional
33
from typing import Union
4+
from typing import Dict
45

56
from pydantic import BaseModel
67
from pydantic import constr
@@ -46,15 +47,20 @@ class Metadata(BaseModel):
4647
height: Optional[int]
4748

4849

50+
class PointLabels(BaseModel):
51+
__root__: Dict[constr(regex=r"^[0-9]*$"), str]
52+
53+
4954
class BaseInstance(BaseModel):
5055
type: AnnotationType
5156
classId: int
5257
groupId: Optional[int]
5358
attributes: List[Attribute]
59+
point_labels: Optional[PointLabels]
5460

5561
class Config:
5662
error_msg_templates = {
57-
"value_error.missing": "ield required for annotation",
63+
"value_error.missing": "field required for annotation",
5864
}
5965

6066

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,16 @@ def is_valid_json(
370370

371371
def execute(self):
372372
if self.is_valid():
373-
bucket = self.s3_bucket
374-
annotation_json = self.prepare_annotations(
375-
project_type=self._project.project_type,
376-
annotations=self.get_annotation_json(),
377-
annotation_classes=self._annotation_classes,
378-
templates=self._templates,
379-
reporter=self.reporter,
380-
)
373+
annotation_json = self.get_annotation_json()
381374
if self.is_valid_json(annotation_json):
375+
bucket = self.s3_bucket
376+
annotation_json = self.prepare_annotations(
377+
project_type=self._project.project_type,
378+
annotations=annotation_json,
379+
annotation_classes=self._annotation_classes,
380+
templates=self._templates,
381+
reporter=self.reporter,
382+
)
382383
bucket.put_object(
383384
Key=self.annotation_upload_data.images[self._image.uuid][
384385
"annotation_json_path"

0 commit comments

Comments
 (0)