Skip to content

Commit a39ed1a

Browse files
author
Matt Sokoloff
committed
change mal validation to use data row bulk exports
1 parent fc8c621 commit a39ed1a

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

labelbox/schema/bulk_import_request.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ class BulkImportRequest(DbObject):
119119
def inputs(self) -> List[Dict[str, Any]]:
120120
"""
121121
Inputs for each individual annotation uploaded.
122-
This should match the ndjson annotations that you have uploaded.
123-
122+
This should match the ndjson annotations that you have uploaded.
123+
124124
Returns:
125125
Uploaded ndjson.
126126
127-
* This information will expire after 24 hours.
127+
* This information will expire after 24 hours.
128128
"""
129129
return self._fetch_remote_ndjson(self.input_file_url)
130130

@@ -137,7 +137,7 @@ def errors(self) -> List[Dict[str, Any]]:
137137
List of dicts containing error messages. Empty list means there were no errors
138138
See `BulkImportRequest.statuses` for more details.
139139
140-
* This information will expire after 24 hours.
140+
* This information will expire after 24 hours.
141141
"""
142142
self.wait_until_done()
143143
return self._fetch_remote_ndjson(self.error_file_url)
@@ -150,14 +150,14 @@ def statuses(self) -> List[Dict[str, Any]]:
150150
Returns:
151151
A status for each annotation if the upload is done running.
152152
See below table for more details
153-
153+
154154
.. list-table::
155155
:widths: 15 150
156-
:header-rows: 1
156+
:header-rows: 1
157157
158158
* - Field
159159
- Description
160-
* - uuid
160+
* - uuid
161161
- Specifies the annotation for the status row.
162162
* - dataRow
163163
- JSON object containing the Labelbox data row ID for the annotation.
@@ -166,7 +166,7 @@ def statuses(self) -> List[Dict[str, Any]]:
166166
* - errors
167167
- An array of error messages included when status is FAILURE. Each error has a name, message and optional (key might not exist) additional_info.
168168
169-
* This information will expire after 24 hours.
169+
* This information will expire after 24 hours.
170170
"""
171171
self.wait_until_done()
172172
return self._fetch_remote_ndjson(self.status_file_url)
@@ -390,27 +390,26 @@ def create_from_local_file(cls,
390390

391391
def _validate_ndjson(lines: Iterable[Dict[str, Any]],
392392
project: "labelbox.Project") -> None:
393-
"""
393+
"""
394394
Client side validation of an ndjson object.
395395
396396
Does not guarentee that an upload will succeed for the following reasons:
397397
* We are not checking the data row types which will cause the following errors to slip through
398398
* Missing frame indices will not causes an error for videos
399-
* Uploaded annotations for the wrong data type will pass (Eg. entity on images)
399+
* Uploaded annotations for the wrong data type will pass (Eg. entity on images)
400400
* We are not checking bounds of an asset (Eg. frame index, image height, text location)
401-
401+
402402
Args:
403403
lines (Iterable[Dict[str,Any]]): An iterable of ndjson lines
404404
project (Project): id of project for which predictions will be imported
405-
405+
406406
Raises:
407407
MALValidationError: Raise for invalid NDJson
408408
UuidError: Duplicate UUID in upload
409409
"""
410-
data_row_ids = {
411-
data_row.uid: data_row for dataset in project.datasets()
412-
for data_row in dataset.data_rows()
413-
}
410+
export_url = project.export_queued_data_rows()
411+
data_row_json = ndjson.loads(requests.get(export_url).text)
412+
data_row_ids = {row['id'] for row in data_row_json}
414413
feature_schemas = get_mal_schemas(project.ontology())
415414
uids: Set[str] = set()
416415
for idx, line in enumerate(lines):
@@ -539,7 +538,7 @@ def build(cls: Any, data: Union[dict, BaseModel]) -> "NDBase":
539538
raises:
540539
KeyError: data does not contain the determinant fields for any of the types supported by this SpecialUnion
541540
ValidationError: Error while trying to construct a specific object in the union
542-
541+
543542
"""
544543
if isinstance(data, BaseModel):
545544
data = data.dict()

0 commit comments

Comments
 (0)