Skip to content

Commit 0e20f97

Browse files
committed
Merge branch 'develop' into jtso/3250
2 parents ab93749 + aa644a1 commit 0e20f97

File tree

1 file changed

+107
-91
lines changed

1 file changed

+107
-91
lines changed

examples/basics/batches.ipynb

Lines changed: 107 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,20 @@
3232
},
3333
{
3434
"cell_type": "markdown",
35-
"source": [
36-
"## Batches (*Currently in Public Beta*)"
37-
],
35+
"id": "Lup2QNWjaxKg",
3836
"metadata": {
3937
"id": "Lup2QNWjaxKg"
4038
},
41-
"id": "Lup2QNWjaxKg"
39+
"source": [
40+
"## Batches (*Currently in Public Beta*)"
41+
]
4242
},
4343
{
4444
"cell_type": "markdown",
45+
"id": "KONWmRQkadPf",
46+
"metadata": {
47+
"id": "KONWmRQkadPf"
48+
},
4549
"source": [
4650
"* A Batch is collection of datarows picked out of a Data Set.\n",
4751
"* A Datarow cannot be part of more than one batch in a project.\n",
@@ -50,59 +54,55 @@
5054
"* Batches may have Datarows from multiple Datasets.\n",
5155
"* Datarows can only be attached to a Project as part of a single Batch.\n",
5256
"* You can set priority for each Batch."
53-
],
54-
"metadata": {
55-
"id": "KONWmRQkadPf"
56-
},
57-
"id": "KONWmRQkadPf"
57+
]
5858
},
5959
{
6060
"cell_type": "code",
6161
"execution_count": null,
62+
"id": "HoW5ypnyzpqb",
6263
"metadata": {
6364
"id": "HoW5ypnyzpqb"
6465
},
6566
"outputs": [],
6667
"source": [
6768
"!pip install labelbox[data]"
68-
],
69-
"id": "HoW5ypnyzpqb"
69+
]
7070
},
7171
{
7272
"cell_type": "code",
7373
"execution_count": null,
74+
"id": "6-Us9Gj1zpqc",
7475
"metadata": {
7576
"id": "6-Us9Gj1zpqc"
7677
},
7778
"outputs": [],
7879
"source": [
7980
"from labelbox import DataRow, Client\n",
8081
"import random"
81-
],
82-
"id": "6-Us9Gj1zpqc"
82+
]
8383
},
8484
{
8585
"cell_type": "markdown",
86+
"id": "qQiozm-dzpqd",
8687
"metadata": {
8788
"id": "qQiozm-dzpqd"
8889
},
8990
"source": [
9091
"Set the following cell with your data to run this notebook:"
91-
],
92-
"id": "qQiozm-dzpqd"
92+
]
9393
},
9494
{
9595
"cell_type": "code",
9696
"execution_count": null,
97+
"id": "84Zna5c0zpqd",
9798
"metadata": {
9899
"id": "84Zna5c0zpqd"
99100
},
100101
"outputs": [],
101102
"source": [
102103
"PROJECT_NAME = \"Batch Queue Demo\" #text project\n",
103104
"DATASET_NAME = \"Batch Queue Demo Data\""
104-
],
105-
"id": "84Zna5c0zpqd"
105+
]
106106
},
107107
{
108108
"cell_type": "markdown",
@@ -118,6 +118,7 @@
118118
{
119119
"cell_type": "code",
120120
"execution_count": null,
121+
"id": "Ge-dfNh-zpqe",
121122
"metadata": {
122123
"id": "Ge-dfNh-zpqe"
123124
},
@@ -126,12 +127,12 @@
126127
"# Add your api key\n",
127128
"API_KEY = None\n",
128129
"client = Client(api_key=API_KEY)"
129-
],
130-
"id": "Ge-dfNh-zpqe"
130+
]
131131
},
132132
{
133133
"cell_type": "code",
134134
"execution_count": null,
135+
"id": "nMVtBYQmzpqe",
135136
"metadata": {
136137
"id": "nMVtBYQmzpqe"
137138
},
@@ -146,161 +147,181 @@
146147
" 'row_data': 'https://picsum.photos/200/300'\n",
147148
" })\n",
148149
"dataset.create_data_rows(uploads)"
149-
],
150-
"id": "nMVtBYQmzpqe"
150+
]
151151
},
152152
{
153153
"cell_type": "markdown",
154-
"source": [
155-
"# Ensure project is in batch mode:"
156-
],
154+
"id": "61CvCD3C7qv6",
157155
"metadata": {
158156
"id": "61CvCD3C7qv6"
159157
},
160-
"id": "61CvCD3C7qv6"
158+
"source": [
159+
"# Ensure project is in batch mode:"
160+
]
161161
},
162162
{
163163
"cell_type": "code",
164-
"source": [
165-
"project = client.create_project(name=PROJECT_NAME)\n",
166-
"project.update(queue_mode=project.QueueMode.Batch)"
167-
],
164+
"execution_count": null,
165+
"id": "tqtT4q31787T",
168166
"metadata": {
169167
"id": "tqtT4q31787T"
170168
},
171-
"id": "tqtT4q31787T",
172-
"execution_count": null,
173-
"outputs": []
169+
"outputs": [],
170+
"source": [
171+
"project = client.create_project(name=PROJECT_NAME)\n",
172+
"project.update(queue_mode=project.QueueMode.Batch)"
173+
]
174174
},
175175
{
176176
"cell_type": "markdown",
177-
"source": [
178-
"# Collect Datarow id's:"
179-
],
177+
"id": "Xti9AoZWELrq",
180178
"metadata": {
181179
"id": "Xti9AoZWELrq"
182180
},
183-
"id": "Xti9AoZWELrq"
181+
"source": [
182+
"# Collect Datarow id's:"
183+
]
184184
},
185185
{
186186
"cell_type": "markdown",
187-
"source": [
188-
"### Select All Data Rows from dataset."
189-
],
187+
"id": "9JVLsXdevywS",
190188
"metadata": {
191189
"id": "9JVLsXdevywS"
192190
},
193-
"id": "9JVLsXdevywS"
191+
"source": [
192+
"### Select All Data Rows from dataset."
193+
]
194194
},
195195
{
196196
"cell_type": "code",
197-
"source": [
198-
"data_rows = [dr.uid for dr in list(dataset.export_data_rows())]"
199-
],
197+
"execution_count": null,
198+
"id": "U4C1ZyJ2EgTS",
200199
"metadata": {
201200
"id": "U4C1ZyJ2EgTS"
202201
},
203-
"id": "U4C1ZyJ2EgTS",
204-
"execution_count": null,
205-
"outputs": []
202+
"outputs": [],
203+
"source": [
204+
"data_row_ids = [dr.uid for dr in dataset.export_data_rows()]"
205+
]
206206
},
207207
{
208208
"cell_type": "markdown",
209+
"id": "6699941a",
210+
"metadata": {},
211+
"source": []
212+
},
213+
{
214+
"cell_type": "markdown",
215+
"id": "B0UqO_O1V8ei",
216+
"metadata": {
217+
"id": "B0UqO_O1V8ei"
218+
},
209219
"source": [
210220
"### Randomly sample\n",
211221
"\n",
212222
"Rather than selecting all of the data we sample 5 data rows at random"
213-
],
214-
"metadata": {
215-
"id": "B0UqO_O1V8ei"
216-
},
217-
"id": "B0UqO_O1V8ei"
223+
]
218224
},
219225
{
220226
"cell_type": "code",
221-
"source": [
222-
"sample = random.sample(data_rows, 5)"
223-
],
227+
"execution_count": null,
228+
"id": "WJAXBf1bV-td",
224229
"metadata": {
225230
"id": "WJAXBf1bV-td"
226231
},
227-
"id": "WJAXBf1bV-td",
228-
"execution_count": null,
229-
"outputs": []
232+
"outputs": [],
233+
"source": [
234+
"sample = random.sample(data_rows, 5)"
235+
]
230236
},
231237
{
232238
"cell_type": "markdown",
233-
"source": [
234-
"# Batch Manipulation"
235-
],
239+
"id": "UPdaTqkgYyvt",
236240
"metadata": {
237241
"id": "UPdaTqkgYyvt"
238242
},
239-
"id": "UPdaTqkgYyvt"
243+
"source": [
244+
"# Batch Manipulation"
245+
]
240246
},
241247
{
242248
"cell_type": "markdown",
243-
"source": [
244-
"### Create a Batch:"
245-
],
249+
"id": "Al-K1lBBEjtb",
246250
"metadata": {
247251
"id": "Al-K1lBBEjtb"
248252
},
249-
"id": "Al-K1lBBEjtb"
253+
"source": [
254+
"### Create a Batch:"
255+
]
250256
},
251257
{
252258
"cell_type": "code",
259+
"execution_count": null,
260+
"id": "resH3xqeErVv",
261+
"metadata": {
262+
"id": "resH3xqeErVv"
263+
},
264+
"outputs": [],
253265
"source": [
254266
"batch = project.create_batch(\n",
255267
" \"first batch\", # Each batch in a project must have a unique name\n",
256268
" sample, # A list of data rows or data row ids\n",
257269
" 5 # priority between 1(Highest) - 5(lowest)\n",
258270
")"
259-
],
260-
"metadata": {
261-
"id": "resH3xqeErVv"
262-
},
263-
"id": "resH3xqeErVv",
264-
"execution_count": null,
265-
"outputs": []
271+
]
266272
},
267273
{
268274
"cell_type": "code",
269-
"source": [
270-
"# number of data rows in the batch\n",
271-
"batch.size"
272-
],
275+
"execution_count": null,
276+
"id": "gFio7ONOWYdJ",
273277
"metadata": {
274278
"id": "gFio7ONOWYdJ"
275279
},
276-
"id": "gFio7ONOWYdJ",
277-
"execution_count": null,
278-
"outputs": []
280+
"outputs": [],
281+
"source": [
282+
"# number of data rows in the batch\n",
283+
"batch.size"
284+
]
279285
},
280286
{
281287
"cell_type": "markdown",
288+
"id": "8Cj64Isxzpqe",
282289
"metadata": {
283290
"id": "8Cj64Isxzpqe"
284291
},
285292
"source": [
286-
"### List DataRows in a Batch (Not supported yet)\n",
287-
"Note: You can view your batch through in the Data Row table of the project"
288-
],
289-
"id": "8Cj64Isxzpqe"
293+
"### List DataRows in a Batch\n",
294+
"Note: You can view your batch through in the *Data Row tab* of the project"
295+
]
296+
},
297+
{
298+
"cell_type": "code",
299+
"execution_count": null,
300+
"id": "0a7d1d3e",
301+
"metadata": {},
302+
"outputs": [],
303+
"source": [
304+
"data_rows = [dr for dr in batch.export_data_rows()]"
305+
]
290306
},
291307
{
292308
"cell_type": "markdown",
309+
"id": "rU7iddSQzpqg",
293310
"metadata": {
294311
"id": "rU7iddSQzpqg"
295312
},
296313
"source": [
297314
"### Remove queued data rows by batch (Not supported yet)\n",
298315
"Note: You can do this through the batch management pane on the data rows tab of the project"
299-
],
300-
"id": "rU7iddSQzpqg"
316+
]
301317
}
302318
],
303319
"metadata": {
320+
"colab": {
321+
"collapsed_sections": [],
322+
"name": "Batches.ipynb",
323+
"provenance": []
324+
},
304325
"kernelspec": {
305326
"display_name": "Python 3",
306327
"language": "python",
@@ -317,13 +338,8 @@
317338
"nbconvert_exporter": "python",
318339
"pygments_lexer": "ipython3",
319340
"version": "3.8.5"
320-
},
321-
"colab": {
322-
"name": "Batches.ipynb",
323-
"provenance": [],
324-
"collapsed_sections": []
325341
}
326342
},
327343
"nbformat": 4,
328344
"nbformat_minor": 5
329-
}
345+
}

0 commit comments

Comments
 (0)