Skip to content

Commit 9637c81

Browse files
author
Matt Sokoloff
committed
minor changes
1 parent 91bc40e commit 9637c81

File tree

1 file changed

+43
-31
lines changed

1 file changed

+43
-31
lines changed

labelbox/schema/project.py

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ def create_label(self, **kwargs):
8989
# deprecated and we don't want the Py client lib user to know
9090
# about them. At the same time they're connected to a Label at
9191
# label creation in a non-standard way (connect via name).
92-
logger.warning("This function is deprecated and is not compatible with the new editor.")
92+
logger.warning(
93+
"This function is deprecated and is not compatible with the new editor."
94+
)
9395

9496
Label = Entity.Label
9597

@@ -254,38 +256,49 @@ def setup(self, labeling_frontend, labeling_frontend_options):
254256
def validate_labeling_parameter_overrides(self, data):
255257
for idx, row in enumerate(data):
256258
if len(row) != 3:
257-
raise TypeError(f"Data must be a list of tuples containing a DataRow, priority (int), num_labels (int). Found {len(row)} items")
259+
raise TypeError(
260+
f"Data must be a list of tuples containing a DataRow, priority (int), num_labels (int). Found {len(row)} items"
261+
)
258262
data_row, priority, num_labels = row
259263
if not isinstance(data_row, DataRow):
260-
raise TypeError(f"Datarow should be be of type DataRow. Found {data_row}")
264+
raise TypeError(
265+
f"Datarow should be be of type DataRow. Found {data_row}")
261266

262-
for name, value in [["priority", priority], ["Number of labels", num_labels]]:
267+
for name, value in [["priority", priority],
268+
["Number of labels", num_labels]]:
263269
if not isinstance(value, int):
264-
raise TypeError(f"{name} must be an int. Found {type(value)} for data_row {data_row}")
270+
raise TypeError(
271+
f"{name} must be an int. Found {type(value)} for data_row {data_row}"
272+
)
265273
if value < 1:
266-
raise ValueError(f"{name} must be greater than 0 for data_row {data_row}")
274+
raise ValueError(
275+
f"{name} must be greater than 0 for data_row {data_row}"
276+
)
267277

268278
def set_labeling_parameter_overrides(self, data):
269279
""" Adds labeling parameter overrides to this project.
270280
271281
Priority:
272-
* data will be labeled in priority order with the lower priority numbers being labeled first
282+
* data will be labeled in priority order
283+
- lower numbers labeled first
273284
- Minimum priority is 1.
274-
* Priority is not the queue position. The position is determined by the relative priority.
285+
* Priority is not the queue position.
286+
- The position is determined by the relative priority.
275287
- Eg. [(data_row_1, 5,1), (data_row_2, 2,1), (data_row_3, 10,1)]
276288
will be assigned in the following order: [data_row_2, data_row_1, data_row_3]
277289
* datarows with parameter overrides will appear before datarows without overrides
278-
* The priority only effects items in the queue and assigning a priority will not automatically add the item back the queue
279-
- If a datarow has already been labeled this will not have an effect until it is added back into the queue
290+
* The priority only effects items in the queue
291+
- Assigning a priority will not automatically add the item back into the queue
280292
281293
Number of labels:
282294
* The number times a data row should be labeled
283295
* This will create duplicates in a project
284296
* The queue will never assign the same datarow to a labeler more than once
285297
- if the number of labels is greater than the number of labelers working on a project then
286298
the extra items will get stuck in the queue (thsi can be fixed by removing the override at any time).
287-
* This can add items to the queue even if they have already been labeled but they will only be assigned to members who have not labeled that image before.
288-
* Set this to 1 if you only want to effect the priority.
299+
* This can add items to the queue (even if they have already been labeled)
300+
- New copies will only be assigned to members who have not labeled that same datarow before.
301+
* Setting this to 1 will result in the default behavior (no duplicates)
289302
290303
291304
See information on priority here:
@@ -366,7 +379,9 @@ def create_prediction_model(self, name, version):
366379
A newly created PredictionModel.
367380
"""
368381

369-
logger.warning("This function is deprecated and is not compatible with the new editor.")
382+
logger.warning(
383+
"This function is deprecated and is not compatible with the new editor."
384+
)
370385

371386
PM = Entity.PredictionModel
372387
model = self.client._create(PM, {
@@ -393,7 +408,9 @@ def create_prediction(self, label, data_row, prediction_model=None):
393408
is None and this Project's active_prediction_model is also
394409
None.
395410
"""
396-
logger.warning("This function is deprecated and is not compatible with the new editor.")
411+
logger.warning(
412+
"This function is deprecated and is not compatible with the new editor."
413+
)
397414

398415
if prediction_model is None:
399416
prediction_model = self.active_prediction_model()
@@ -449,11 +466,10 @@ def enable_model_assisted_labeling(self, toggle: bool = True) -> bool:
449466
"showingPredictionsToLabelers"]
450467

451468
def upload_annotations(
452-
self,
453-
name: str,
454-
annotations: Union[str, Union[str, Path], Iterable[dict]],
455-
validate = True
456-
) -> 'BulkImportRequest': # type: ignore
469+
self,
470+
name: str,
471+
annotations: Union[str, Union[str, Path], Iterable[dict]],
472+
validate=True) -> 'BulkImportRequest': # type: ignore
457473
""" Uploads annotations to a new Editor project.
458474
459475
Args:
@@ -468,7 +484,7 @@ def upload_annotations(
468484
Returns:
469485
BulkImportRequest
470486
"""
471-
487+
472488
if isinstance(annotations, str) or isinstance(annotations, Path):
473489

474490
def _is_url_valid(url: Union[str, Path]) -> bool:
@@ -486,13 +502,11 @@ def _is_url_valid(url: Union[str, Path]) -> bool:
486502
return bool(parsed.scheme) and bool(parsed.netloc)
487503

488504
if _is_url_valid(annotations):
489-
return BulkImportRequest.create_from_url(
490-
client=self.client,
491-
project_id=self.uid,
492-
name=name,
493-
url=str(annotations),
494-
validate = validate
495-
)
505+
return BulkImportRequest.create_from_url(client=self.client,
506+
project_id=self.uid,
507+
name=name,
508+
url=str(annotations),
509+
validate=validate)
496510
else:
497511
path = Path(annotations)
498512
if not path.exists():
@@ -512,12 +526,12 @@ def _is_url_valid(url: Union[str, Path]) -> bool:
512526
project_id=self.uid,
513527
name=name,
514528
predictions=annotations, # type: ignore
515-
validate = validate
516-
)
529+
validate=validate)
517530
else:
518531
raise ValueError(
519532
f'Invalid annotations given of type: {type(annotations)}')
520533

534+
521535
class LabelingParameterOverride(DbObject):
522536
""" Customizes the order of assets in the label queue.
523537
@@ -529,8 +543,6 @@ class LabelingParameterOverride(DbObject):
529543
number_of_labels = Field.Int("number_of_labels")
530544

531545

532-
533-
534546
LabelerPerformance = namedtuple(
535547
"LabelerPerformance", "user count seconds_per_label, total_time_labeling "
536548
"consensus average_benchmark_agreement last_activity_time")

0 commit comments

Comments
 (0)