Skip to content

Commit 61aa064

Browse files
ovalle15ovalle15
authored andcommitted
Adding list to global keys
1 parent d1ea29c commit 61aa064

File tree

11 files changed

+173
-802
lines changed

11 files changed

+173
-802
lines changed

examples/annotation_import/conversational.ipynb

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,7 @@
310310
"project.setup_editor(ontology) # Connect your ontology and editor to your project"
311311
],
312312
"cell_type": "code",
313-
"outputs": [
314-
{
315-
"name": "stderr",
316-
"output_type": "stream",
317-
"text": [
318-
"WARNING:labelbox.client:Default createProject behavior will soon be adjusted to prefer batch projects. Pass in `queue_mode` parameter explicitly to opt-out for the time being.\n"
319-
]
320-
}
321-
],
313+
"outputs": [],
322314
"execution_count": null
323315
},
324316
{
@@ -336,29 +328,14 @@
336328
"# Create a batch to send to your MAL project\n",
337329
"batch = project.create_batch(\n",
338330
" \"first-batch-convo-demo\", # Each batch in a project must have a unique name\n",
339-
" global_keys=global_key, # Paginated collection of data row objects, list of data row ids or global keys\n",
331+
" global_keys=[global_key], # Paginated collection of data row objects, list of data row ids or global keys\n",
340332
" priority=5 # priority between 1(Highest) - 5(lowest)\n",
341333
")\n",
342334
"\n",
343335
"print(\"Batch: \", batch)"
344336
],
345337
"cell_type": "code",
346-
"outputs": [
347-
{
348-
"name": "stdout",
349-
"output_type": "stream",
350-
"text": [
351-
"Batch: <Batch {\n",
352-
" \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
353-
" \"created_at\": \"2022-12-23 20:20:51+00:00\",\n",
354-
" \"name\": \"first-batch-convo-demo\",\n",
355-
" \"size\": 1,\n",
356-
" \"uid\": \"4bceaa60-82ff-11ed-b68f-3b1759fe9ddf\",\n",
357-
" \"updated_at\": \"2022-12-23 20:20:51+00:00\"\n",
358-
"}>\n"
359-
]
360-
}
361-
],
338+
"outputs": [],
362339
"execution_count": null
363340
},
364341
{
@@ -428,16 +405,7 @@
428405
"print(\"Status of uploads: \", upload_job.statuses)"
429406
],
430407
"cell_type": "code",
431-
"outputs": [
432-
{
433-
"name": "stdout",
434-
"output_type": "stream",
435-
"text": [
436-
"Errors: []\n",
437-
" \n"
438-
]
439-
}
440-
],
408+
"outputs": [],
441409
"execution_count": null
442410
},
443411
{
@@ -463,15 +431,7 @@
463431
"print(\"Status of uploads: \", upload_job.statuses)"
464432
],
465433
"cell_type": "code",
466-
"outputs": [
467-
{
468-
"name": "stdout",
469-
"output_type": "stream",
470-
"text": [
471-
"Errors: []\n"
472-
]
473-
}
474-
],
434+
"outputs": [],
475435
"execution_count": null
476436
},
477437
{
@@ -484,7 +444,6 @@
484444
{
485445
"metadata": {},
486446
"source": [
487-
"#upload_job\n",
488447
"# project.delete()\n",
489448
"# dataset.delete()"
490449
],

examples/annotation_import/image.ipynb

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,11 @@
304304
"outputs": [],
305305
"execution_count": null
306306
},
307+
{
308+
"metadata": {},
309+
"source": [],
310+
"cell_type": "markdown"
311+
},
307312
{
308313
"metadata": {},
309314
"source": [
@@ -690,28 +695,13 @@
690695
"source": [
691696
"batch = project.create_batch(\n",
692697
" \"Initial batch2\", # name of the batch\n",
693-
" global_keys=global_key, # DataRow objects, a list of global keys or data row ids are supported\n",
698+
" global_keys=[global_key], # Paginated collection of data row objects, list of data row ids or global keys\n",
694699
" priority=1 # priority between 1-5\n",
695700
")\n",
696701
"print(\"Batch\", batch)"
697702
],
698703
"cell_type": "code",
699-
"outputs": [
700-
{
701-
"name": "stdout",
702-
"output_type": "stream",
703-
"text": [
704-
"Batch <Batch {\n",
705-
" \"consensus_settings_json\": \"{\\\"numberOfLabels\\\":1,\\\"coveragePercentage\\\":0}\",\n",
706-
" \"created_at\": \"2023-03-17 13:58:44+00:00\",\n",
707-
" \"name\": \"Initial batch2\",\n",
708-
" \"size\": 0,\n",
709-
" \"uid\": \"d4b46230-c4cb-11ed-8ef7-03b2e7ba4cb0\",\n",
710-
" \"updated_at\": \"2023-03-17 13:58:44+00:00\"\n",
711-
"}>\n"
712-
]
713-
}
714-
],
704+
"outputs": [],
715705
"execution_count": null
716706
},
717707
{
@@ -773,7 +763,7 @@
773763
{
774764
"metadata": {},
775765
"source": [
776-
"label_ndjson_method2 = []\n",
766+
"label_ndjson = []\n",
777767
"for annotation in [radio_annotation_ndjson, \n",
778768
" checklist_annotation_ndjson, \n",
779769
" text_annotation_ndjson,\n",
@@ -792,7 +782,7 @@
792782
" annotation.update({\n",
793783
" 'dataRow': {'globalKey':global_key},\n",
794784
" })\n",
795-
" label_ndjson_method2.append(annotation)\n"
785+
" label_ndjson.append(annotation)\n"
796786
],
797787
"cell_type": "code",
798788
"outputs": [],
@@ -821,23 +811,14 @@
821811
" client = client, \n",
822812
" project_id = project.uid, \n",
823813
" name=\"mal_job\"+str(uuid.uuid4()), \n",
824-
" predictions=label_ndjson_method2)\n",
814+
" predictions=label_ndjson)\n",
825815
"\n",
826816
"print(\"Errors:\", upload_job.errors)\n",
827817
"print(\"Status of uploads: \", upload_job.statuses)\n",
828818
"print(\" \")"
829819
],
830820
"cell_type": "code",
831-
"outputs": [
832-
{
833-
"name": "stdout",
834-
"output_type": "stream",
835-
"text": [
836-
"Errors: []\n",
837-
" \n"
838-
]
839-
}
840-
],
821+
"outputs": [],
841822
"execution_count": null
842823
},
843824
{
@@ -855,7 +836,7 @@
855836
" client = client, \n",
856837
" project_id = project.uid, \n",
857838
" name=\"label_import_job\"+str(uuid.uuid4()), \n",
858-
" labels=label_ndjson_method2)\n",
839+
" labels=label_ndjson)\n",
859840
"\n",
860841
"print(\"Errors:\", upload_job.errors)\n",
861842
"print(\"Status of uploads: \", upload_job.statuses)\n",

examples/annotation_import/pdf.ipynb

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
"metadata": {},
292292
"source": [
293293
"## Text layer url is required for uploading entity annotations\n",
294-
"global_key = \"0801.3483.pd\"\n",
294+
"global_key = \"0801.3483.pdf\"\n",
295295
"img_url = {\n",
296296
" \"row_data\": {\n",
297297
" \"pdf_url\": \"https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483.pdf\",\n",
@@ -308,7 +308,23 @@
308308
"print(\"Failed data rows:\", task.failed_data_rows)"
309309
],
310310
"cell_type": "code",
311-
"outputs": [],
311+
"outputs": [
312+
{
313+
"name": "stderr",
314+
"output_type": "stream",
315+
"text": [
316+
"There are errors present. Please look at `task.errors` for more details\n"
317+
]
318+
},
319+
{
320+
"name": "stdout",
321+
"output_type": "stream",
322+
"text": [
323+
"Errors: Duplicate global keys found: 0801.3483.pdf\n",
324+
"Failed data rows: [{'message': 'Duplicate global keys found: 0801.3483.pdf', 'failedDataRows': [{'globalKey': '0801.3483.pdf', 'rowData': 'https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483.pdf', 'attachmentInputs': [], 'mediaAttributes': {'textLayerUrl': 'https://storage.googleapis.com/labelbox-datasets/arxiv-pdf/data/99-word-token-pdfs/0801.3483-lb-textlayer.json'}}]}]\n"
325+
]
326+
}
327+
],
312328
"execution_count": null
313329
},
314330
{
@@ -431,7 +447,7 @@
431447
"source": [
432448
"project.create_batch(\n",
433449
" \"PDF_annotation_batch\", # Each batch in a project must have a unique name\n",
434-
" global_keys=global_key, # A list of data rows or data row ids\n",
450+
" global_keys=[global_key], # Paginated collection of data row objects, list of data row ids or global keys\n",
435451
" priority=5 # priority between 1(Highest) - 5(lowest)\n",
436452
")"
437453
],
@@ -440,10 +456,10 @@
440456
{
441457
"data": {
442458
"text/plain": [
443-
"<Batch ID: e2152a50-c402-11ed-9933-959d2b6c8c3c>"
459+
"<Batch ID: eb670250-c749-11ed-a43b-3542d8b96bf7>"
444460
]
445461
},
446-
"execution_count": 13,
462+
"execution_count": 33,
447463
"metadata": {},
448464
"output_type": "execute_result"
449465
}
@@ -545,19 +561,20 @@
545561
{
546562
"metadata": {},
547563
"source": [
548-
"# create a Label\n",
564+
"\n",
549565
"\n",
550566
"labels = []\n",
551567
"\n",
552-
"labels.append(lb_types.Label(\n",
553-
" data=lb_types.DocumentData(\n",
554-
" global_key=global_key),\n",
555-
" annotations = [\n",
556-
" entities_annotation,\n",
557-
" checklist_annotation, \n",
558-
" text_annotation,\n",
559-
" radio_annotation\n",
560-
" ]\n",
568+
"labels.append(\n",
569+
" lb_types.Label(\n",
570+
" data=lb_types.DocumentData(\n",
571+
" global_key=global_key),\n",
572+
" annotations = [\n",
573+
" entities_annotation,\n",
574+
" checklist_annotation, \n",
575+
" text_annotation,\n",
576+
" radio_annotation\n",
577+
" ]\n",
561578
" )\n",
562579
")"
563580
],
@@ -577,7 +594,7 @@
577594
"metadata": {},
578595
"source": [
579596
"\n",
580-
"ndjson_annotation = []\n",
597+
"label_ndjson = []\n",
581598
"for annot in [\n",
582599
" entities_annotations_ndjson,\n",
583600
" bbox_annotation_ndjson,\n",
@@ -590,7 +607,7 @@
590607
" annot.update({\n",
591608
" 'dataRow': {'globalKey': global_key},\n",
592609
" })\n",
593-
" ndjson_annotation.append(annot)\n",
610+
" label_ndjson.append(annot)\n",
594611
"\n"
595612
],
596613
"cell_type": "code",
@@ -618,15 +635,24 @@
618635
" client = client,\n",
619636
" project_id = project.uid,\n",
620637
" name=\"pdf_annotation_upload\" + str(uuid.uuid4()),\n",
621-
" predictions=ndjson_annotation)\n",
638+
" predictions=label_ndjson)\n",
622639
"\n",
623640
"upload_job.wait_until_done()\n",
624641
"# Errors will appear for annotation uploads that failed.\n",
625642
"print(\"Errors:\", upload_job.errors)\n",
626643
"print(\"Status of uploads: \", upload_job.statuses)"
627644
],
628645
"cell_type": "code",
629-
"outputs": [],
646+
"outputs": [
647+
{
648+
"name": "stdout",
649+
"output_type": "stream",
650+
"text": [
651+
"Errors: []\n",
652+
"Status of uploads: [{'uuid': '262296fe-6877-432a-b12d-9c688f996f2c', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': '1018a2d5-9e16-4a71-9bf4-58ab7f575a38', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': '2755d3cd-5cfa-4022-be37-cf754734b8b0', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': 'ead202c6-d9d3-4f8a-9e2f-e42bb71573e2', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': '5a586b1a-11f1-4f49-8aca-25cb2a39956c', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': '17211b2a-abab-4d65-8ed6-585bbbca3483', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': 'c1a18383-df7c-4a72-9f45-917c8404af72', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}]\n"
653+
]
654+
}
655+
],
630656
"execution_count": null
631657
},
632658
{
@@ -644,13 +670,22 @@
644670
" client = client, \n",
645671
" project_id = project.uid, \n",
646672
" name=\"label_import_job\"+str(uuid.uuid4()), \n",
647-
" labels=ndjson_annotation)\n",
673+
" labels=label_ndjson)\n",
648674
"\n",
649675
"print(\"Errors:\", upload_job.errors)\n",
650676
"print(\"Status of uploads: \", upload_job.statuses)"
651677
],
652678
"cell_type": "code",
653-
"outputs": [],
679+
"outputs": [
680+
{
681+
"name": "stdout",
682+
"output_type": "stream",
683+
"text": [
684+
"Errors: []\n",
685+
"Status of uploads: [{'uuid': 'bb0dbd33-4f7a-49b3-808a-a5d57563cc1a', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': '32021451-e988-4e23-b526-46afd769bef3', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': '2aaf89be-c02c-4d09-ae1a-097ff69de28a', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': '80e57133-3bf5-4479-9301-be37dc634283', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': 'a4842956-f857-4c91-ba83-9ab5969159cb', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': '38ee3c85-4762-4630-94d3-cf5fc10f9ce5', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}, {'uuid': '6ec97e39-b971-4a46-a591-efd0705e0817', 'dataRow': {'id': 'clfh1n29e1mh2078d3jt3b5cx', 'globalKey': '0801.3483.pdf'}, 'status': 'SUCCESS'}]\n"
686+
]
687+
}
688+
],
654689
"execution_count": null
655690
}
656691
]

0 commit comments

Comments
 (0)