Skip to content

Commit 621edef

Browse files
rllinrllin
authored andcommitted
catch bad inputs
1 parent 9f3d672 commit 621edef

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

labelbox/schema/bulk_import_request.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ def create_from_objects(cls, client, project_id: str, name: str,
222222
"""
223223
_validate_ndjson(predictions)
224224
data_str = ndjson.dumps(predictions)
225+
if not data_str:
226+
raise ValueError('annotations cannot be empty')
227+
225228
data = data_str.encode('utf-8')
226229
file_name = _make_file_name(project_id, name)
227230
request_data = _make_request_data(project_id, name, len(data_str),

labelbox/schema/project.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,16 @@ def _is_url_valid(url: Union[str, Path]) -> bool:
410410
file=path,
411411
validate_file=True,
412412
)
413-
else:
413+
elif isinstance(annotations, Iterable):
414414
return BulkImportRequest.create_from_objects(
415415
client=self.client,
416416
project_id=self.uid,
417417
name=name,
418418
predictions=annotations, # type: ignore
419419
)
420+
else:
421+
raise ValueError(
422+
f'Invalid annotations given of type: {type(annotations)}')
420423

421424

422425
class LabelingParameterOverride(DbObject):

0 commit comments

Comments
 (0)