Skip to content

Commit 2283fab

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
Added createion type
1 parent c219f91 commit 2283fab

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
from pydantic.color import Color
1414
from pydantic.color import ColorType
1515
from pydantic.datetime_parse import parse_datetime
16+
from pydantic.errors import EnumMemberError
17+
18+
19+
def enum_error_handling(self) -> str:
20+
permitted = ', '.join(repr(v.value) for v in self.enum_values)
21+
return f'Invalid value, permitted: {permitted}'
22+
23+
24+
EnumMemberError.__str__ = enum_error_handling
1625

1726

1827
NotEmptyStr = constr(strict=True, min_length=1)
@@ -53,7 +62,7 @@ class VectorAnnotationTypeEnum(str, Enum):
5362
class CreationTypeEnum(str, Enum):
5463
MANUAL = "Manual"
5564
PREDICTION = "Prediction"
56-
PRE_ANNOTATION = "Pre-annotation"
65+
PRE_ANNOTATION = "Preannotation"
5766

5867

5968
class AnnotationStatusEnum(str, Enum):
@@ -103,7 +112,6 @@ class BboxPoints(BaseModel):
103112

104113

105114
class TimedBaseModel(BaseModel):
106-
# TODO change to datetime
107115
created_at: StringDate = Field(None, alias="createdAt")
108116
updated_at: StringDate = Field(None, alias="updatedAt")
109117

@@ -118,9 +126,9 @@ class TrackableModel(BaseModel):
118126
updated_by: Optional[UserAction] = Field(None, alias="updatedBy")
119127
creation_type: Optional[CreationTypeEnum] = Field(CreationTypeEnum.PRE_ANNOTATION.value, alias="creationType")
120128

121-
@validator("creation_type")
122-
def clean_creation_type(cls, value):
123-
return value or CreationTypeEnum.PRE_ANNOTATION.value
129+
@validator("creation_type", always=True)
130+
def clean_creation_type(cls, _):
131+
return CreationTypeEnum.PRE_ANNOTATION.value
124132

125133

126134
class LastUserAction(BaseModel):

src/superannotate/lib/core/helpers.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,10 @@ def convert_timestamp(timestamp):
268268

269269

270270
def handle_last_action(annotations: dict, team: TeamEntity):
271-
metadata = annotations["metadata"]
272-
if not annotations.get("lastAction"):
273-
metadata["lastAction"] = {
274-
"email": team.creator_id,
275-
"timestamp": int(time.time()),
276-
}
271+
annotations["metadata"]["lastAction"] = {
272+
"email": team.creator_id,
273+
"timestamp": int(time.time()),
274+
}
277275

278276

279277
class SetEncoder(json.JSONEncoder):

tests/integration/test_interface.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import tempfile
44
import pytest
55

6-
76
import src.superannotate as sa
87
from src.superannotate.lib.app.exceptions import AppException
98
from tests.integration.base import BaseTestCase

0 commit comments

Comments
 (0)