Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@


class Client:
""" A Labelbox client.
Contains info necessary for connecting to a Labelbox server (URL,
authentication key). Provides functions for querying and creating
top-level data objects (Projects, Datasets).
""" A Labelbox client.

Contains info necessary for connecting to a Labelbox server (URL,
authentication key). Provides functions for querying and creating
top-level data objects (Projects, Datasets).
"""

def __init__(self,
Expand Down Expand Up @@ -73,8 +73,8 @@ def __init__(self,
labelbox.exceptions.InternalServerError))
def execute(self, query, params=None, timeout=10.0):
""" Sends a request to the server for the execution of the
given query.
given query.

Checks the response for errors and wraps errors
in appropriate `labelbox.exceptions.LabelboxError` subtypes.

Expand Down Expand Up @@ -336,7 +336,7 @@ def get_dataset(self, dataset_id):

def get_user(self):
""" Gets the current User database object.

>>> user = client.get_user()
"""
return self._get_single(User, None)
Expand Down Expand Up @@ -435,7 +435,7 @@ def _create(self, db_object_type, data):

def create_dataset(self, **kwargs):
""" Creates a Dataset object on the server.

Attribute values are passed as keyword arguments.

>>> project = client.get_project("<project_uid>")
Expand All @@ -452,8 +452,8 @@ def create_dataset(self, **kwargs):
return self._create(Dataset, kwargs)

def create_project(self, **kwargs):
""" Creates a Project object on the server.
""" Creates a Project object on the server.

Attribute values are passed as keyword arguments.

>>> project = client.create_project(name="<project_name>", description="<project_description>")
Expand Down
2 changes: 1 addition & 1 deletion labelbox/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ResourceNotFoundError(LabelboxError):

def __init__(self, db_object_type, params):
""" Constructor.

Args:
db_object_type (type): A labelbox.schema.DbObject subtype.
params (dict): Dict of params identifying the sought resource.
Expand Down
4 changes: 2 additions & 2 deletions labelbox/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class PaginatedCollection:
""" An iterable collection of database objects (Projects, Labels, etc...).

Implements automatic (transparent to the user) paginated fetching during
iteration. Intended for use by library internals and not by the end user.
For a list of attributes see __init__(...) documentation. The params of
Expand All @@ -13,7 +13,7 @@ class PaginatedCollection:

def __init__(self, client, query, params, dereferencing, obj_class):
""" Creates a PaginatedCollection.

Args:
client (labelbox.Client): the client used for fetching data from DB.
query (str): Base query used for pagination. It must contain two
Expand Down
8 changes: 4 additions & 4 deletions labelbox/schema/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

class Benchmark(DbObject):
""" Represents a benchmark label.
The Benchmarks tool works by interspersing data to be labeled, for
which there is a benchmark label, to each person labeling. These

The Benchmarks tool works by interspersing data to be labeled, for
which there is a benchmark label, to each person labeling. These
labeled data are compared against their respective benchmark and an
accuracy score between 0 and 100 percent is calculated.

Expand All @@ -15,7 +15,7 @@ class Benchmark(DbObject):
last_activity (datetime)
average_agreement (float)
completed_count (int)

created_by (Relationship): `ToOne` relationship to User
reference_label (Relationship): `ToOne` relationship to Label
"""
Expand Down
8 changes: 4 additions & 4 deletions labelbox/schema/bulk_import_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class BulkImportRequest(DbObject):
error_file_url (str): NDJSON that contains error messages for failed annotations
status_file_url (str): NDJSON that contains status for each annotation
created_at (datetime): UTC timestamp for date BulkImportRequest was created

project (Relationship): `ToOne` relationship to Project
created_by (Relationship): `ToOne` relationship to User
"""
Expand All @@ -125,7 +125,7 @@ def refresh(self) -> None:

def wait_until_done(self, sleep_time_seconds: int = 30) -> None:
"""Blocks import job until certain conditions are met.

Blocks until the BulkImportRequest.state changes either to
`BulkImportRequestState.FINISHED` or `BulkImportRequestState.FAILED`,
periodically refreshing object's state.
Expand Down Expand Up @@ -209,8 +209,8 @@ def create_from_url(cls, client, project_id: str, name: str,
def create_from_objects(cls, client, project_id: str, name: str,
predictions: Iterable[dict]) -> 'BulkImportRequest':
"""
Creates a `BulkImportRequest` from an iterable of dictionaries.
Creates a `BulkImportRequest` from an iterable of dictionaries.

Conforms to JSON predictions format, e.g.:
``{
"uuid": "9fd9a92e-2560-4e77-81d4-b2e955800092",
Expand Down
10 changes: 5 additions & 5 deletions labelbox/schema/data_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@


class DataRow(DbObject, Updateable, BulkDeletable):
""" Internal Labelbox representation of a single piece of data (e.g. image, video, text).
""" Internal Labelbox representation of a single piece of data (e.g. image, video, text).

Attributes:
external_id (str): User-generated file name or identifier
row_data (str): Paths to local files are uploaded to Labelbox's server.
row_data (str): Paths to local files are uploaded to Labelbox's server.
Otherwise, it's treated as an external URL.
updated_at (datetime)
created_at (datetime)

dataset (Relationship): `ToOne` relationship to Dataset
created_by (Relationship): `ToOne` relationship to User
organization (Relationship): `ToOne` relationship to Organization
labels (Relationship): `ToMany` relationship to Label
metadata (Relationship): `ToMany` relationship to AssetMetadata
predictions (Relationship): `ToMany` relationship to Prediction
predictions (Relationship): `ToMany` relationship to Prediction
"""
external_id = Field.String("external_id")
row_data = Field.String("row_data")
Expand Down Expand Up @@ -50,7 +50,7 @@ def __init__(self, *args, **kwargs):

def create_metadata(self, meta_type, meta_value):
""" Attaches asset metadata to a DataRow.

>>> datarow.create_metadata("TEXT", "This is a text message")

Args:
Expand Down
6 changes: 3 additions & 3 deletions labelbox/schema/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@


class Dataset(DbObject, Updateable, Deletable):
""" A Dataset is a collection of DataRows.
""" A Dataset is a collection of DataRows.

Attributes:
name (str)
Expand Down Expand Up @@ -39,7 +39,7 @@ def create_data_row(self, **kwargs):
>>> dataset.create_data_row(row_data="http://my_site.com/photos/img_01.jpg")

Args:
**kwargs: Key-value arguments containing new `DataRow` data. At a minimum,
**kwargs: Key-value arguments containing new `DataRow` data. At a minimum,
must contain `row_data`.

Raises:
Expand Down Expand Up @@ -70,7 +70,7 @@ def create_data_rows(self, items):
it is a `str`, then it is interpreted as a local file path. The file
is uploaded to Labelbox and a DataRow referencing it is created.
If an item is a `dict`, then it should map `DataRow` fields (or their
names) to values. At the minimum an `item` passed as a `dict` must
names) to values. At the minimum an `item` passed as a `dict` must
contain a `DataRow.row_data` key and value.

>>> dataset.create_data_rows([
Expand Down
2 changes: 1 addition & 1 deletion labelbox/schema/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Label(DbObject, Updateable, BulkDeletable):
agreement (float)
benchmark_agreement (float)
is_benchmark_reference (bool)

project (Relationship): `ToOne` relationship to Project
data_row (Relationship): `ToOne` relationship to DataRow
reviews (Relationship): `ToMany` relationship to Review
Expand Down
2 changes: 1 addition & 1 deletion labelbox/schema/labeling_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class LabelingFrontend(DbObject):
Represents an HTML / JavaScript UI that is used to generate
labels. “Editor” is the default Labeling Frontend that comes in every
organization. You can create new labeling frontends for an organization.

Attributes:
name (str)
description (str)
Expand Down
4 changes: 2 additions & 2 deletions labelbox/schema/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

class Organization(DbObject):
""" An Organization is a group of Users.

It is associated with data created by Users within that Organization.
Typically all Users within an Organization have access to data created by any User in the same Organization.

Attributes:
updated_at (datetime)
created_at (datetime)
Expand Down
4 changes: 2 additions & 2 deletions labelbox/schema/prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PredictionModel(DbObject):
version (int)

created_by (Relationship): `ToOne` relationship to User
organization (Relationship): `ToOne` relationship to Organization
organization (Relationship): `ToOne` relationship to Organization
"""
updated_at = Field.DateTime("updated_at")
created_at = Field.DateTime("created_at")
Expand All @@ -40,7 +40,7 @@ class Prediction(DbObject):
created_at (datetime)
label (str)
agreement (float)

organization (Relationship): `ToOne` relationship to Organization
prediction_model (Relationship): `ToOne` relationship to PredictionModel
data_row (Relationship): `ToOne` relationship to DataRow
Expand Down
16 changes: 8 additions & 8 deletions labelbox/schema/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Project(DbObject, Updateable, Deletable):
""" A Project is a container that includes a labeling frontend, an ontology,
datasets and labels.

Attributes:
Attributes:
name (str)
description (str)
updated_at (datetime)
Expand Down Expand Up @@ -150,7 +150,7 @@ def export_labels(self, timeout_seconds=60):
Args:
timeout_seconds (float): Max waiting time, in seconds.
Returns:
URL of the data file with this Project's labels. If the server didn't
URL of the data file with this Project's labels. If the server didn't
generate during the `timeout_seconds` period, None is returned.
"""
sleep_time = 2
Expand Down Expand Up @@ -250,8 +250,8 @@ def setup(self, labeling_frontend, labeling_frontend_options):
self.update(setup_complete=timestamp)

def set_labeling_parameter_overrides(self, data):
""" Adds labeling parameter overrides to this project.
""" Adds labeling parameter overrides to this project.

>>> project.set_labeling_parameter_overrides([
>>> (data_row_1, 2, 3), (data_row_2, 1, 4)])

Expand Down Expand Up @@ -328,7 +328,7 @@ def extend_reservations(self, queue_type):

def create_prediction_model(self, name, version):
""" Creates a PredictionModel connected to a Legacy Editor Project.

Args:
name (str): The new PredictionModel's name.
version (int): The new PredictionModel's version.
Expand All @@ -346,7 +346,7 @@ def create_prediction_model(self, name, version):
def create_prediction(self, label, data_row, prediction_model=None):
""" Creates a Prediction within a Legacy Editor Project. Not supported
in the new Editor.

Args:
label (str): The `label` field of the new Prediction.
data_row (DataRow): The DataRow for which the Prediction is created.
Expand Down Expand Up @@ -392,7 +392,7 @@ def enable_model_assisted_labeling(self, toggle: bool = True) -> bool:
""" Turns model assisted labeling either on or off based on input

Args:
toggle (bool): True or False boolean
toggle (bool): True or False boolean
Returns:
True if toggled on or False if toggled off
"""
Expand All @@ -401,7 +401,7 @@ def enable_model_assisted_labeling(self, toggle: bool = True) -> bool:

query_str = """mutation toggle_model_assisted_labelingPyApi($%s: ID!, $%s: Boolean!) {
project(where: {id: $%s }) {
showPredictionsToLabelers(show: $%s) {
showPredictionsToLabelers(show: $%s) {
id, showingPredictionsToLabelers
}
}
Expand Down
4 changes: 2 additions & 2 deletions labelbox/schema/review.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Review(DbObject, Deletable, Updateable):
""" Reviewing labeled data is a collaborative quality assurance technique.

A Review object indicates the quality of the assigned Label. The aggregated
review numbers can be obtained on a Project object.
review numbers can be obtained on a Project object.

Attributes:
created_at (datetime)
Expand All @@ -22,7 +22,7 @@ class Review(DbObject, Deletable, Updateable):
"""

class NetScore(Enum):
""" Negative, Zero, or Positive.
""" Negative, Zero, or Positive.
"""
Negative = auto()
Zero = auto()
Expand Down
2 changes: 1 addition & 1 deletion labelbox/schema/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def create(client, topics, url, secret, project):

def update(self, topics=None, url=None, status=None):
""" Updates this Webhook.

Args:
topics (list of str): The new topics value, optional.
url (str): The new URL value, optional.
Expand Down