Skip to content

Commit 2ba04b9

Browse files
author
Kevin Kim
committed
Add _CamelCaseMixin
1 parent 67dc7a9 commit 2ba04b9

File tree

1 file changed

+4
-12
lines changed
  • labelbox/data/serialization/ndjson

1 file changed

+4
-12
lines changed

labelbox/data/serialization/ndjson/base.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,22 @@
22
from uuid import uuid4
33
from pydantic import BaseModel, root_validator, validator, Field
44

5-
from labelbox.utils import camel_case, is_exactly_one_set
5+
from labelbox.utils import _CamelCaseMixin, camel_case, is_exactly_one_set
66
from ...annotation_types.types import Cuid
77

88

9-
class DataRow(BaseModel):
9+
class DataRow(_CamelCaseMixin):
1010
id: str = None
1111
global_key: str = None
1212

1313
@root_validator()
1414
def must_set_one(cls, values):
15-
if is_exactly_one_set(values.get('id'), values.get('global_key')):
15+
if not is_exactly_one_set(values.get('id'), values.get('global_key')):
1616
raise ValueError("Must set either id or global_key")
1717
return values
1818

19-
class Config:
20-
allow_population_by_field_name = True
21-
alias_generator = camel_case
2219

23-
24-
class NDJsonBase(BaseModel):
20+
class NDJsonBase(_CamelCaseMixin):
2521
uuid: str = None
2622
data_row: DataRow
2723

@@ -38,10 +34,6 @@ def dict(self, *args, **kwargs):
3834
res['dataRow'].pop('globalKey')
3935
return res
4036

41-
class Config:
42-
allow_population_by_field_name = True
43-
alias_generator = camel_case
44-
4537

4638
class NDAnnotation(NDJsonBase):
4739
name: Optional[str] = None

0 commit comments

Comments
 (0)