Skip to content

Commit 4d0c455

Browse files
Update docstrings in client.py (#72)
Adding sample code to docstrings in client.py.
1 parent 94d2d81 commit 4d0c455

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

labelbox/client.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def _get_single(self, db_object_type, uid):
309309

310310
def get_project(self, project_id):
311311
""" Gets a single Project with the given ID.
312+
>>> project = client.get_project("<project_id>")
312313
313314
Args:
314315
project_id (str): Unique ID of the Project.
@@ -322,6 +323,7 @@ def get_project(self, project_id):
322323

323324
def get_dataset(self, dataset_id):
324325
""" Gets a single Dataset with the given ID.
326+
>>> dataset = client.get_dataset("<dataset_id>")
325327
326328
Args:
327329
dataset_id (str): Unique ID of the Dataset.
@@ -334,11 +336,17 @@ def get_dataset(self, dataset_id):
334336
return self._get_single(Dataset, dataset_id)
335337

336338
def get_user(self):
337-
""" Gets the current User database object. """
339+
""" Gets the current User database object.
340+
>>> user = client.get_user()
341+
342+
"""
338343
return self._get_single(User, None)
339344

340345
def get_organization(self):
341-
""" Gets the Organization DB object of the current user. """
346+
""" Gets the Organization DB object of the current user.
347+
>>> organization = client.get_organization()
348+
349+
"""
342350
return self._get_single(Organization, None)
343351

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

362370
def get_projects(self, where=None):
363371
""" Fetches all the projects the user has access to.
372+
>>> projects = client.get_projects(where=(Project.name == "<project_name>") & (Project.description == "<project_description>"))
364373
365374
Args:
366375
where (Comparison, LogicalOperation or None): The `where` clause
@@ -371,7 +380,8 @@ def get_projects(self, where=None):
371380
return self._get_all(Project, where)
372381

373382
def get_datasets(self, where=None):
374-
""" Fetches all the datasets the user has access to.
383+
""" Fetches one or more datasets.
384+
>>> datasets = client.get_datasets(where=(Dataset.name == "<dataset_name>") & (Dataset.description == "<dataset_description"))
375385
376386
Args:
377387
where (Comparison, LogicalOperation or None): The `where` clause
@@ -383,6 +393,7 @@ def get_datasets(self, where=None):
383393

384394
def get_labeling_frontends(self, where=None):
385395
""" Fetches all the labeling frontends.
396+
>>> frontend = client.get_labeling_frontends(where=LabelingFrontend.name == "Editor")
386397
387398
Args:
388399
where (Comparison, LogicalOperation or None): The `where` clause
@@ -422,9 +433,8 @@ def _create(self, db_object_type, data):
422433
def create_dataset(self, **kwargs):
423434
""" Creates a Dataset object on the server. Attribute values are
424435
passed as keyword arguments:
425-
>>> project = client.get_project("uid_of_my_project")
426-
>>> dataset = client.create_dataset(name="MyDataset",
427-
>>> projects=project)
436+
>>> project = client.get_project("<project_uid>")
437+
>>> dataset = client.create_dataset(name="<dataset_name>", projects=project)
428438
429439
Kwargs:
430440
Keyword arguments with new Dataset attribute values.
@@ -441,7 +451,7 @@ def create_dataset(self, **kwargs):
441451
def create_project(self, **kwargs):
442452
""" Creates a Project object on the server. Attribute values are
443453
passed as keyword arguments:
444-
>>> project = client.create_project(name="MyProject")
454+
>>> project = client.create_project(name="<project_name>", description="<project_description>")
445455
446456
Kwargs:
447457
Keyword arguments with new Project attribute values.

0 commit comments

Comments
 (0)