Skip to content

Commit 1e09e05

Browse files
Merge pull request #19 from Labelbox/ac/docstrings
add code samples to dataset.py
2 parents 65dd67f + 137c9b6 commit 1e09e05

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

labelbox/schema/dataset.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ class Dataset(DbObject, Updateable, Deletable):
2525
def create_data_row(self, **kwargs):
2626
""" Creates a single DataRow belonging to this dataset.
2727
28+
>>> dataset.create_data_row(row_data="http://my_site.com/photos/img_01.jpg")
29+
2830
Kwargs:
2931
Key-value arguments containing new `DataRow` data.
30-
At a minimum they must contain `row_data`. The value for
31-
`row_data` is a string. If it's a path to an existing local
32-
file then it's uploaded to Labelbox's server. Otherwise it's
32+
At a minimum `kwargs` must contain `row_data`. The value for
33+
`row_data` is a string. If it is a path to an existing local
34+
file then it is uploaded to Labelbox's server. Otherwise it is
3335
treated as an external URL.
3436
Raises:
3537
InvalidQueryError: If `DataRow.row_data` field value is not provided
@@ -54,13 +56,19 @@ def create_data_row(self, **kwargs):
5456
return self.client._create(DataRow, kwargs)
5557

5658
def create_data_rows(self, items):
57-
""" Creates multiple DataRow objects based on the given items.
59+
""" Creates multiple DataRow objects based on the given `items`.
60+
5861
Each element in `items` can be either a `str` or a `dict`. If
59-
it's a `str`, then it's interpreted as a file path. The file
62+
it is a `str`, then it is interpreted as a local file path. The file
6063
is uploaded to Labelbox and a DataRow referencing it is created.
6164
If an item is a `dict`, then it should map `DataRow` fields (or their
62-
names) to values. At the minimum it must contain a `DataRow.row_data`
63-
key and value.
65+
names) to values. At the minimum an `item` passed as a `dict` must
66+
contain a `DataRow.row_data` key and value.
67+
68+
>>> dataset.create_data_rows([
69+
>>> {DataRow.row_data:"http://my_site.com/photos/img_01.jpg"},
70+
>>> "path/to/file2.jpg"
71+
>>> ])
6472
6573
Args:
6674
items (iterable of (dict or str)): See above for details.

0 commit comments

Comments
 (0)