Skip to content
Merged
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
24 changes: 17 additions & 7 deletions labelbox/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ def _get_single(self, db_object_type, uid):

def get_project(self, project_id):
""" Gets a single Project with the given ID.
>>> project = client.get_project("<project_id>")

Args:
project_id (str): Unique ID of the Project.
Expand All @@ -322,6 +323,7 @@ def get_project(self, project_id):

def get_dataset(self, dataset_id):
""" Gets a single Dataset with the given ID.
>>> dataset = client.get_dataset("<dataset_id>")

Args:
dataset_id (str): Unique ID of the Dataset.
Expand All @@ -334,11 +336,17 @@ def get_dataset(self, dataset_id):
return self._get_single(Dataset, dataset_id)

def get_user(self):
""" Gets the current User database object. """
""" Gets the current User database object.
>>> user = client.get_user()

"""
return self._get_single(User, None)

def get_organization(self):
""" Gets the Organization DB object of the current user. """
""" Gets the Organization DB object of the current user.
>>> organization = client.get_organization()

"""
return self._get_single(Organization, None)

def _get_all(self, db_object_type, where):
Expand All @@ -361,6 +369,7 @@ def _get_all(self, db_object_type, where):

def get_projects(self, where=None):
""" Fetches all the projects the user has access to.
>>> projects = client.get_projects(where=(Project.name == "<project_name>") & (Project.description == "<project_description>"))

Args:
where (Comparison, LogicalOperation or None): The `where` clause
Expand All @@ -371,7 +380,8 @@ def get_projects(self, where=None):
return self._get_all(Project, where)

def get_datasets(self, where=None):
""" Fetches all the datasets the user has access to.
""" Fetches one or more datasets.
>>> datasets = client.get_datasets(where=(Dataset.name == "<dataset_name>") & (Dataset.description == "<dataset_description"))

Args:
where (Comparison, LogicalOperation or None): The `where` clause
Expand All @@ -383,6 +393,7 @@ def get_datasets(self, where=None):

def get_labeling_frontends(self, where=None):
""" Fetches all the labeling frontends.
>>> frontend = client.get_labeling_frontends(where=LabelingFrontend.name == "Editor")

Args:
where (Comparison, LogicalOperation or None): The `where` clause
Expand Down Expand Up @@ -422,9 +433,8 @@ 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("uid_of_my_project")
>>> dataset = client.create_dataset(name="MyDataset",
>>> projects=project)
>>> project = client.get_project("<project_uid>")
>>> dataset = client.create_dataset(name="<dataset_name>", projects=project)

Kwargs:
Keyword arguments with new Dataset attribute values.
Expand All @@ -441,7 +451,7 @@ def create_dataset(self, **kwargs):
def create_project(self, **kwargs):
""" Creates a Project object on the server. Attribute values are
passed as keyword arguments:
>>> project = client.create_project(name="MyProject")
>>> project = client.create_project(name="<project_name>", description="<project_description>")

Kwargs:
Keyword arguments with new Project attribute values.
Expand Down