Skip to content

Commit b675332

Browse files
author
Matt Sokoloff
committed
requested changes
1 parent 43a501c commit b675332

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

labelbox/schema/dataset.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
import os
12
import json
23
import logging
4+
from itertools import islice
35
from multiprocessing.dummy import Pool as ThreadPool
4-
import os
56

67
from labelbox.exceptions import InvalidQueryError, ResourceNotFoundError, InvalidAttributeError
78
from labelbox.orm.db_object import DbObject, Updateable, Deletable
89
from labelbox.orm.model import Entity, Field, Relationship
910

11+
logger = logging.getLogger(__name__)
1012

1113
class Dataset(DbObject, Updateable, Deletable):
1214
""" A Dataset is a collection of DataRows.
@@ -185,7 +187,7 @@ def data_rows_for_external_id(self, external_id, limit=10):
185187

186188
data_rows = self.data_rows(where=where)
187189
# Get at most `limit` data_rows.
188-
data_rows = [row for row, _ in zip(data_rows, range(limit))]
190+
data_rows = list(islice(data_rows, limit))
189191

190192
if not len(data_rows):
191193
raise ResourceNotFoundError(DataRow, where)
@@ -209,7 +211,7 @@ def data_row_for_external_id(self, external_id):
209211
data_rows = self.data_rows_for_external_id(external_id=external_id,
210212
limit=2)
211213
if len(data_rows) > 1:
212-
logging.warn(
213-
f"More than one data_row has the provided external_id : `{external_id}`. Use function data_rows_for_external_id to fetch all"
214+
logger.warning(
215+
f"More than one data_row has the provided external_id : `%s`. Use function data_rows_for_external_id to fetch all", external_id
214216
)
215217
return data_rows[0]

labelbox/schema/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def upsert_instructions(self, instructions_file: str):
200200
frontendId = frontend.uid
201201

202202
if frontend.name != "Editor":
203-
logger.warn(
203+
logger.warning(
204204
f"This function has only been tested to work with the Editor front end. Found %s",
205205
frontend.name)
206206

@@ -325,7 +325,7 @@ def validate_labeling_parameter_overrides(self, data):
325325
data_row, priority, num_labels = row
326326
if not isinstance(data_row, DataRow):
327327
raise TypeError(
328-
f"Datarow should be be of type DataRow. Found {type(data_row)}. Index: {idx}"
328+
f"data_row should be be of type DataRow. Found {type(data_row)}. Index: {idx}"
329329
)
330330

331331
for name, value in [["Priority", priority],
@@ -358,7 +358,7 @@ def set_labeling_parameter_overrides(self, data):
358358
- Minimum priority is 1.
359359
* Priority is not the queue position.
360360
- The position is determined by the relative priority.
361-
- Eg. [(data_row_1, 5,1), (data_row_2, 2,1), (data_row_3, 10,1)]
361+
- E.g. [(data_row_1, 5,1), (data_row_2, 2,1), (data_row_3, 10,1)]
362362
will be assigned in the following order: [data_row_2, data_row_1, data_row_3]
363363
* Datarows with parameter overrides will appear before datarows without overrides.
364364
* The priority only effects items in the queue.

tests/integration/test_labeling_parameter_overrides.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_labeling_parameter_overrides(project, rand_gen):
5050
data = [(data_rows[12].uid, 1, 3)]
5151
project.set_labeling_parameter_overrides(data)
5252
assert str(exc_info.value) == \
53-
"Datarow should be be of type DataRow. Found <class 'str'>. Index: 0"
53+
"data_row should be be of type DataRow. Found <class 'str'>. Index: 0"
5454

5555
with pytest.raises(ValueError) as exc_info:
5656
data = [(data_rows[12], 0, 3)]

0 commit comments

Comments
 (0)