Skip to content

Commit 2f198cf

Browse files
author
Matt Sokoloff
committed
format
1 parent c3a8032 commit 2f198cf

File tree

3 files changed

+33
-26
lines changed

3 files changed

+33
-26
lines changed

labelbox/schema/bulk_import_request.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -788,25 +788,28 @@ class RLEMaskFeatures(BaseModel):
788788
@validator('counts')
789789
def validate_counts(cls, counts):
790790
if not all([count >= 0 for count in counts]):
791-
raise ValueError("Found negative value for counts. They should all be zero or positive")
791+
raise ValueError(
792+
"Found negative value for counts. They should all be zero or positive"
793+
)
792794
return counts
793795

794796
@validator('size')
795797
def validate_size(cls, size):
796798
if len(size) != 2:
797-
raise ValueError(f"Mask `size` should have two ints representing height and with. Found : {size}")
799+
raise ValueError(
800+
f"Mask `size` should have two ints representing height and with. Found : {size}"
801+
)
798802
if not all([count > 0 for count in size]):
799-
raise ValueError(f"Mask `size` should be a postitive int. Found : {size}" )
803+
raise ValueError(
804+
f"Mask `size` should be a postitive int. Found : {size}")
800805
return size
801806

802807

803-
804808
class PNGMaskFeatures(BaseModel):
805809
# base64 encoded png bytes
806810
png: str
807811

808812

809-
810813
class URIMaskFeatures(BaseModel):
811814
instanceURI: str
812815
colorRGB: Union[List[int], Tuple[int, int, int]]
@@ -816,7 +819,8 @@ def validate_color(cls, colorRGB):
816819
#Does the dtype matter? Can it be a float?
817820
if not isinstance(colorRGB, (tuple, list)):
818821
raise ValueError(
819-
f"Received color that is not a list or tuple. Found : {colorRGB}")
822+
f"Received color that is not a list or tuple. Found : {colorRGB}"
823+
)
820824
elif len(colorRGB) != 3:
821825
raise ValueError(
822826
f"Must provide RGB values for segmentation colors. Found : {colorRGB}"
@@ -827,12 +831,10 @@ def validate_color(cls, colorRGB):
827831
return colorRGB
828832

829833

830-
831-
832834
class NDMask(NDBaseTool):
833835
ontology_type: Literal["superpixel"] = "superpixel"
834-
mask: Union[URIMaskFeatures, PNGMaskFeatures, RLEMaskFeatures] = pydantic.Field(determinant=True)
835-
836+
mask: Union[URIMaskFeatures, PNGMaskFeatures,
837+
RLEMaskFeatures] = pydantic.Field(determinant=True)
836838

837839

838840
#A union with custom construction logic to improve error messages

tests/integration/annotation_import/conftest.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -231,31 +231,34 @@ def segmentation_inference(prediction_id_mapping):
231231
del segmentation['tool']
232232
return segmentation
233233

234+
234235
@pytest.fixture
235236
def segmentation_inference_rle(prediction_id_mapping):
236237
segmentation = prediction_id_mapping['superpixel'].copy()
237-
segmentation.update(
238-
{
239-
'uuid' : str(uuid.uuid4()),
240-
'mask': {
241-
'size': [10,10],
242-
'counts': [1, 0, 10,100]
243-
}})
238+
segmentation.update({
239+
'uuid': str(uuid.uuid4()),
240+
'mask': {
241+
'size': [10, 10],
242+
'counts': [1, 0, 10, 100]
243+
}
244+
})
244245
del segmentation['tool']
245246
return segmentation
246247

248+
247249
@pytest.fixture
248250
def segmentation_inference_png(prediction_id_mapping):
249251
segmentation = prediction_id_mapping['superpixel'].copy()
250-
segmentation.update(
251-
{
252-
'uuid' : str(uuid.uuid4()),
253-
'mask': {
252+
segmentation.update({
253+
'uuid': str(uuid.uuid4()),
254+
'mask': {
254255
'png': "somedata",
255-
}})
256+
}
257+
})
256258
del segmentation['tool']
257259
return segmentation
258260

261+
259262
@pytest.fixture
260263
def checklist_inference(prediction_id_mapping):
261264
checklist = prediction_id_mapping['checklist'].copy()
@@ -307,10 +310,12 @@ def model_run_predictions(polygon_inference, rectangle_inference,
307310
# also used for label imports
308311
@pytest.fixture
309312
def object_predictions(polygon_inference, rectangle_inference, line_inference,
310-
entity_inference, segmentation_inference, segmentation_inference_rle, segmentation_inference_png):
313+
entity_inference, segmentation_inference,
314+
segmentation_inference_rle, segmentation_inference_png):
311315
return [
312316
polygon_inference, rectangle_inference, line_inference,
313-
entity_inference, segmentation_inference, segmentation_inference_rle, segmentation_inference_png
317+
entity_inference, segmentation_inference, segmentation_inference_rle,
318+
segmentation_inference_png
314319
]
315320

316321

tests/integration/annotation_import/test_ndjson_validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ def test_incorrect_mask(segmentation_inference, configured_project):
133133
with pytest.raises(MALValidationError):
134134
_validate_ndjson([seg], configured_project)
135135

136-
seg['mask'] = {'counts' : [0], 'size' : [0,1]}
136+
seg['mask'] = {'counts': [0], 'size': [0, 1]}
137137
with pytest.raises(MALValidationError):
138138
_validate_ndjson([seg], configured_project)
139139

140-
seg['mask'] = {'counts' : [-1], 'size' : [1,1]}
140+
seg['mask'] = {'counts': [-1], 'size': [1, 1]}
141141
with pytest.raises(MALValidationError):
142142
_validate_ndjson([seg], configured_project)
143143

0 commit comments

Comments
 (0)