Skip to content

Commit 0312789

Browse files
[SN-132] modified queue_management.ipynb to remove some parameters (#1614)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent aa62651 commit 0312789

File tree

1 file changed

+60
-55
lines changed

1 file changed

+60
-55
lines changed

examples/project_configuration/queue_management.ipynb

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
{
4949
"metadata": {},
5050
"source": [
51-
"!pip install labelbox -q\n",
52-
"!pip install numpy"
51+
"%pip install -q \"labelbox[data]\"\n",
52+
"%pip install -q numpy"
5353
],
5454
"cell_type": "code",
5555
"outputs": [],
@@ -105,11 +105,13 @@
105105
"source": [
106106
"# Create Labelbox project\n",
107107
"\n",
108-
"project = client.create_project(name=\"batch-test-project\",\n",
109-
" description=\"a description\",\n",
110-
" quality_mode=QualityMode.Benchmark, # For Consensus projects use quality_mode = QualityMode.Consensus\n",
111-
" media_type=lb.MediaType.Image,\n",
112-
" )\n",
108+
"project = client.create_project(\n",
109+
" name=\"batch-test-project\",\n",
110+
" description=\"a description\",\n",
111+
" quality_mode=QualityMode.\n",
112+
" Benchmark, # For Consensus projects use quality_mode = QualityMode.Consensus\n",
113+
" media_type=lb.MediaType.Image,\n",
114+
")\n",
113115
"\n",
114116
"dataset = client.create_dataset(name=\"queue_dataset\")"
115117
],
@@ -133,20 +135,19 @@
133135
" name=\"Quality Issues\",\n",
134136
" options=[\n",
135137
" lb.Option(value=\"blurry\", label=\"Blurry\"),\n",
136-
" lb.Option(value=\"distorted\", label=\"Distorted\")\n",
137-
" ]\n",
138+
" lb.Option(value=\"distorted\", label=\"Distorted\"),\n",
139+
" ],\n",
138140
" )\n",
139141
"]\n",
140142
"\n",
141143
"ontology_builder = lb.OntologyBuilder(\n",
142-
" tools=[],\n",
143-
" classifications=classification_features\n",
144+
" tools=[], classifications=classification_features\n",
144145
")\n",
145146
"\n",
146147
"ontology = client.create_ontology(\n",
147-
" \"Ontology from new features\",\n",
148-
" ontology_builder.asdict(),\n",
149-
" media_type=lb.MediaType.Image\n",
148+
" \"Ontology from new features\",\n",
149+
" ontology_builder.asdict(),\n",
150+
" media_type=lb.MediaType.Image,\n",
150151
")\n",
151152
"\n",
152153
"project.setup_editor(ontology)"
@@ -170,19 +171,20 @@
170171
"global_keys = []\n",
171172
"# Generate data rows\n",
172173
"for i in range(1, 5):\n",
173-
" global_key = str(uuid4())\n",
174-
" row = {\n",
175-
" \"row_data\": f\"https://storage.googleapis.com/labelbox-datasets/People_Clothing_Segmentation/jpeg_images/IMAGES/img_000{i}.jpeg\",\n",
176-
" \"global_key\": global_key\n",
174+
" global_key = str(uuid4())\n",
175+
" row = {\n",
176+
" \"row_data\":\n",
177+
" f\"https://storage.googleapis.com/labelbox-datasets/People_Clothing_Segmentation/jpeg_images/IMAGES/img_000{i}.jpeg\",\n",
178+
" \"global_key\":\n",
179+
" global_key,\n",
177180
" }\n",
178-
" global_keys.append(global_key)\n",
179-
" uploads.append(row)\n",
180-
"\n",
181+
" global_keys.append(global_key)\n",
182+
" uploads.append(row)\n",
181183
"\n",
182184
"data_rows = dataset.create_data_rows(uploads)\n",
183185
"data_rows.wait_till_done()\n",
184-
"print(\"Errors\" , data_rows.errors)\n",
185-
"print(\"Dataset status: \", data_rows.status)\n"
186+
"print(\"Errors\", data_rows.errors)\n",
187+
"print(\"Dataset status: \", data_rows.status)"
186188
],
187189
"cell_type": "code",
188190
"outputs": [],
@@ -203,19 +205,22 @@
203205
"# Create the batch\n",
204206
"\n",
205207
"batch = project.create_batch(\n",
206-
" \"batch-demo\", # Each batch in a project must have a unique name\n",
207-
" global_keys = global_keys[0:2], # A list of data rows, data row ids or global keys\n",
208-
" priority=5 # priority between 1(Highest) - 5(lowest) 5 is the max priority that can be set\n",
208+
" \"batch-demo\", # Each batch in a project must have a unique name\n",
209+
" global_keys=global_keys[\n",
210+
" 0:2], # A list of data rows, data row ids or global keys\n",
211+
" priority=\n",
212+
" 5, # priority between 1(Highest) - 5(lowest) 5 is the max priority that can be set\n",
209213
")\n",
210214
"\n",
211215
"batch2 = project.create_batch(\n",
212-
" \"batch-demo-2\", # Each batch in a project must have a unique name\n",
213-
" #Provide a slice of the data since you can't import assets with global keys that already exist in the project.\n",
214-
" global_keys=global_keys[2:4], # A list of data rows, data row ids or global keys\n",
215-
" priority=1 # priority between 1(Highest) - 5(lowest) 5 is the max priority that can be set\n",
216+
" \"batch-demo-2\", # Each batch in a project must have a unique name\n",
217+
" # Provide a slice of the data since you can't import assets with global keys that already exist in the project.\n",
218+
" global_keys=global_keys[\n",
219+
" 2:4], # A list of data rows, data row ids or global keys\n",
220+
" priority=\n",
221+
" 1, # priority between 1(Highest) - 5(lowest) 5 is the max priority that can be set\n",
216222
")\n",
217223
"\n",
218-
"\n",
219224
"print(\"Batch: \", batch)\n",
220225
"print(\"Batch2: \", batch2)"
221226
],
@@ -226,8 +231,9 @@
226231
{
227232
"metadata": {},
228233
"source": [
229-
"print(\"View the results here:\",\n",
230-
" f\"https://app.labelbox.com/projects/{project.uid}\")\n",
234+
"print(\n",
235+
" \"View the results here:\", f\"https://app.labelbox.com/projects/{project.uid}\"\n",
236+
")\n",
231237
"# Click `start labeling` to see the images in order"
232238
],
233239
"cell_type": "code",
@@ -246,8 +252,6 @@
246252
{
247253
"metadata": {},
248254
"source": [
249-
"client.enable_experimental = True\n",
250-
"\n",
251255
"export_task = project.export()\n",
252256
"export_task.wait_till_done()"
253257
],
@@ -261,23 +265,23 @@
261265
"# Get data rows from project\n",
262266
"data_rows = []\n",
263267
"\n",
268+
"\n",
264269
"def json_stream_handler(output: lb.JsonConverterOutput):\n",
265-
" data_row = json.loads(output.json_str)\n",
266-
" data_rows.append(lb.GlobalKey(data_row[\"data_row\"][\"global_key\"])) # Convert json data row into data row identifier object\n",
270+
" data_row = json.loads(output.json_str)\n",
271+
" data_rows.append(\n",
272+
" lb.GlobalKey(data_row[\"data_row\"][\"global_key\"])\n",
273+
" ) # Convert json data row into data row identifier object\n",
267274
"\n",
268275
"\n",
269276
"if export_task.has_errors():\n",
270-
" export_task.get_stream(\n",
271-
"\n",
272-
" converter=lb.JsonConverter(),\n",
273-
" stream_type=lb.StreamType.ERRORS\n",
274-
" ).start(stream_handler=lambda error: print(error))\n",
277+
" export_task.get_stream(\n",
278+
" converter=lb.JsonConverter(), stream_type=lb.StreamType.ERRORS\n",
279+
" ).start(stream_handler=lambda error: print(error))\n",
275280
"\n",
276281
"if export_task.has_result():\n",
277-
" export_json = export_task.get_stream(\n",
278-
" converter=lb.JsonConverter(),\n",
279-
" stream_type=lb.StreamType.RESULT\n",
280-
" ).start(stream_handler=json_stream_handler)"
282+
" export_json = export_task.get_stream(\n",
283+
" converter=lb.JsonConverter(), stream_type=lb.StreamType.RESULT\n",
284+
" ).start(stream_handler=json_stream_handler)"
281285
],
282286
"cell_type": "code",
283287
"outputs": [],
@@ -290,8 +294,8 @@
290294
"project_lpos = project.labeling_parameter_overrides()\n",
291295
"\n",
292296
"for lpo in project_lpos:\n",
293-
" print(lpo)\n",
294-
" print(\"Data row:\", lpo.data_row().uid)"
297+
" print(lpo)\n",
298+
" print(\"Data row:\", lpo.data_row().uid)"
295299
],
296300
"cell_type": "code",
297301
"outputs": [],
@@ -302,19 +306,18 @@
302306
"source": [
303307
"# Add LPOs\n",
304308
"lpos = []\n",
305-
"priority=1\n",
309+
"priority = 1\n",
306310
"for data_row in data_rows:\n",
307-
" lpos.append((data_row, priority, 1))\n",
308-
" priority+=1\n",
309-
"\n",
311+
" lpos.append((data_row, priority))\n",
312+
" priority += 1\n",
310313
"\n",
311314
"project.set_labeling_parameter_overrides(lpos)\n",
312315
"\n",
313316
"# Check results\n",
314317
"project_lpos = list(project.labeling_parameter_overrides())\n",
315318
"\n",
316319
"for lpo in project_lpos:\n",
317-
" print(lpo)"
320+
" print(lpo)"
318321
],
319322
"cell_type": "code",
320323
"outputs": [],
@@ -328,13 +331,15 @@
328331
"for data_row in data_rows:\n",
329332
" global_keys.append(data_row.key)\n",
330333
"\n",
331-
"project.update_data_row_labeling_priority(data_rows=lb.GlobalKeys(global_keys), priority=1)\n",
334+
"project.update_data_row_labeling_priority(\n",
335+
" data_rows=lb.GlobalKeys(global_keys), priority=1\n",
336+
")\n",
332337
"\n",
333338
"# Check results\n",
334339
"project_lpos = list(project.labeling_parameter_overrides())\n",
335340
"\n",
336341
"for lpo in project_lpos:\n",
337-
" print(lpo)"
342+
" print(lpo)"
338343
],
339344
"cell_type": "code",
340345
"outputs": [],

0 commit comments

Comments
 (0)