You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"source": "# If you don't want to give google access to drive you can skip this cell\n# and manually set `API_KEY` below.\n\nCOLAB = \"google.colab\" in str(get_ipython())\nif COLAB:\n !pip install colab-env -qU\n from colab_env import envvar_handler\n envvar_handler.envload()\n\nAPI_KEY = os.environ.get(\"LABELBOX_API_KEY\")\nif not os.environ.get(\"LABELBOX_API_KEY\"):\n API_KEY = getpass(\"Please enter your labelbox api key\")\n if COLAB:\n envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
65
69
},
66
70
{
67
71
"cell_type": "markdown",
@@ -72,37 +76,24 @@
72
76
},
73
77
{
74
78
"cell_type": "code",
75
-
"execution_count": 3,
79
+
"execution_count": 4,
76
80
"metadata": {},
77
81
"outputs": [],
78
-
"source": [
79
-
"# Pick a project that has a dataset attached, data has external ids, and there are some labels\n",
80
-
"# This will modify the project so just pick a dummy one that you don't care about\n",
81
-
"PROJECT_ID = \"ckpnfquwy0kyg0y8t9rwb99cz\"\n",
82
-
"# Only update this if you have an on-prem deployment\n",
83
-
"ENDPOINT = \"https://api.labelbox.com/graphql\""
84
-
]
82
+
"source": "# Pick a project that has a dataset attached, data has external ids, and there are some labels\n# This will modify the project so just pick a dummy one that you don't care about\nPROJECT_ID = \"ckpnfquwy0kyg0y8t9rwb99cz\"\n# Only update this if you have an on-prem deployment\nENDPOINT = \"https://api.labelbox.com/graphql\""
"source": "project = client.get_project(PROJECT_ID)\ndataset = next(project.datasets())\n# This is the same as\n# -> dataset = client.get_dataset(dataset_id)"
"source": "# External ids can be a reference to your internal datasets\ndata_row = dataset.data_row_for_external_id(data_row.external_id)\nprint(data_row)"
"source": "dataset = client.create_dataset(name=\"testing-dataset\")\ndataset.create_data_row(row_data=\"https://picsum.photos/200/300\")\n\n# It is reccomended that you use external ids but optional.\n# These are useful for users to maintain references to a data_row.\ndataset.create_data_row(row_data=\"https://picsum.photos/200/300\",\n external_id=str(uuid.uuid4()))"
"source": "# You can mix local files with urls\ntask3 = dataset.create_data_rows([{\n DataRow.row_data: \"https://picsum.photos/200/300\"\n}, local_data_path])"
244
197
},
245
198
{
246
199
"cell_type": "code",
247
-
"execution_count": 13,
200
+
"execution_count": 14,
248
201
"metadata": {},
249
202
"outputs": [],
250
-
"source": [
251
-
"# Note that you cannot set external_ids at this time when uploading from local files.\n",
"source": "# Note that you cannot set external_ids at this time when uploading from local files.\n# To do this you have to first\nitem_url = client.upload_file(local_data_path)\ntask4 = dataset.create_data_rows([{\n DataRow.row_data: item_url,\n DataRow.external_id: str(uuid.uuid4())\n}])"
"# Note that attachment_value must always be a string (url to a video/image or a text value to display)"
333
-
]
258
+
"source": "# We can also create attachments\n# Attachments are visible for all projects connected to the data_row\ndata_row.create_attachment(attachment_type=\"TEXT\",\n attachment_value=\"LABELERS WILL SEE THIS \")\n# See more information here:\n# https://docs.labelbox.com/reference/type-image\n# Note that attachment_value must always be a string (url to a video/image or a text value to display)"
334
259
},
335
260
{
336
261
"cell_type": "markdown",
@@ -341,23 +266,17 @@
341
266
},
342
267
{
343
268
"cell_type": "code",
344
-
"execution_count": 17,
269
+
"execution_count": 18,
345
270
"metadata": {},
346
271
"outputs": [],
347
-
"source": [
348
-
"data_row.delete()\n",
349
-
"# Will remove from the dataset too"
350
-
]
272
+
"source": "data_row.delete()\n# Will remove from the dataset too"
351
273
},
352
274
{
353
275
"cell_type": "code",
354
-
"execution_count": 18,
276
+
"execution_count": 19,
355
277
"metadata": {},
356
278
"outputs": [],
357
-
"source": [
358
-
"# Bulk delete a list of data_rows (in this case all of them we just uploaded)\n",
359
-
"DataRow.bulk_delete(list(dataset.data_rows()))"
360
-
]
279
+
"source": "# Bulk delete a list of data_rows (in this case all of them we just uploaded)\nDataRow.bulk_delete(list(dataset.data_rows()))"
0 commit comments