Skip to content

Commit 9ec85f1

Browse files
committed
update to remove colab key request and instead just request user to input their API key
1 parent 0ab238d commit 9ec85f1

25 files changed

+3349
-728
lines changed

examples/annotation_types/basics.ipynb

Lines changed: 438 additions & 61 deletions
Large diffs are not rendered by default.

examples/annotation_types/converters.ipynb

Lines changed: 111 additions & 50 deletions
Large diffs are not rendered by default.

examples/annotation_types/label_containers.ipynb

Lines changed: 285 additions & 36 deletions
Large diffs are not rendered by default.

examples/annotation_types/mal_using_annotation_types.ipynb

Lines changed: 137 additions & 30 deletions
Large diffs are not rendered by default.

examples/basics/basics.ipynb

Lines changed: 81 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,21 @@
6666
"id": "indie-bracket",
6767
"metadata": {},
6868
"outputs": [],
69-
"source": "!pip install labelbox"
69+
"source": [
70+
"!pip install labelbox"
71+
]
7072
},
7173
{
7274
"cell_type": "code",
7375
"execution_count": 2,
7476
"id": "everyday-street",
7577
"metadata": {},
7678
"outputs": [],
77-
"source": "from labelbox import Project, Dataset, Client\nfrom getpass import getpass\nimport os"
78-
},
79-
{
80-
"cell_type": "code",
81-
"execution_count": 3,
82-
"id": "crude-receiver",
83-
"metadata": {},
84-
"outputs": [],
85-
"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)"
79+
"source": [
80+
"from labelbox import Project, Dataset, Client\n",
81+
"from getpass import getpass\n",
82+
"import os"
83+
]
8684
},
8785
{
8886
"cell_type": "markdown",
@@ -109,7 +107,14 @@
109107
"id": "instructional-reply",
110108
"metadata": {},
111109
"outputs": [],
112-
"source": "PROJECT_ID = \"ckk4q1viuc0w20704eh69u28h\"\nDATASET_ID = \"ckk4q1vjznyhu087203wlghfr\"\nPROJECT_NAME = \"Sample Project\"\nDATASET_NAME = \"Example Jellyfish Dataset\"\n# Only update this if you have an on-prem deployment\nENDPOINT = \"https://api.labelbox.com/graphql\""
110+
"source": [
111+
"PROJECT_ID = \"ckk4q1viuc0w20704eh69u28h\"\n",
112+
"DATASET_ID = \"ckk4q1vjznyhu087203wlghfr\"\n",
113+
"PROJECT_NAME = \"Sample Project\"\n",
114+
"DATASET_NAME = \"Example Jellyfish Dataset\"\n",
115+
"# Only update this if you have an on-prem deployment\n",
116+
"ENDPOINT = \"https://api.labelbox.com/graphql\""
117+
]
113118
},
114119
{
115120
"cell_type": "markdown",
@@ -126,15 +131,24 @@
126131
"id": "thick-gasoline",
127132
"metadata": {},
128133
"outputs": [],
129-
"source": "client = Client(api_key=API_KEY, endpoint=ENDPOINT)"
134+
"source": [
135+
"# Add your api key\n",
136+
"API_KEY = None\n",
137+
"ENDPOINT = \"https://api.labelbox.com/graphql\"\n",
138+
"client = Client(api_key=API_KEY, endpoint=ENDPOINT)"
139+
]
130140
},
131141
{
132142
"cell_type": "code",
133143
"execution_count": 6,
134144
"id": "victorian-consumer",
135145
"metadata": {},
136146
"outputs": [],
137-
"source": "#Client can be used to fetch by id:\nproject = client.get_project(PROJECT_ID)\ndataset = client.get_dataset(DATASET_ID)"
147+
"source": [
148+
"#Client can be used to fetch by id:\n",
149+
"project = client.get_project(PROJECT_ID)\n",
150+
"dataset = client.get_dataset(DATASET_ID)"
151+
]
138152
},
139153
{
140154
"cell_type": "code",
@@ -153,7 +167,9 @@
153167
"output_type": "execute_result"
154168
}
155169
],
156-
"source": "project"
170+
"source": [
171+
"project"
172+
]
157173
},
158174
{
159175
"cell_type": "markdown",
@@ -181,7 +197,11 @@
181197
]
182198
}
183199
],
184-
"source": "print(project.name)\nprint(project.description)\nprint(dataset.name)"
200+
"source": [
201+
"print(project.name)\n",
202+
"print(project.description)\n",
203+
"print(dataset.name)"
204+
]
185205
},
186206
{
187207
"cell_type": "markdown",
@@ -197,7 +217,10 @@
197217
"id": "according-subdivision",
198218
"metadata": {},
199219
"outputs": [],
200-
"source": "project.update(description=\"new description field\")\nprint(project.description)"
220+
"source": [
221+
"project.update(description=\"new description field\")\n",
222+
"print(project.description)"
223+
]
201224
},
202225
{
203226
"cell_type": "markdown",
@@ -226,15 +249,23 @@
226249
"output_type": "execute_result"
227250
}
228251
],
229-
"source": "labels_paginated_collection = project.labels()\nlabels_paginated_collection"
252+
"source": [
253+
"labels_paginated_collection = project.labels()\n",
254+
"labels_paginated_collection"
255+
]
230256
},
231257
{
232258
"cell_type": "code",
233259
"execution_count": 11,
234260
"id": "convinced-force",
235261
"metadata": {},
236262
"outputs": [],
237-
"source": "# Note that if you selected a `project_id` without any labels this will raise `StopIteration`\n# Iterate over them to get the items out.\nnext(labels_paginated_collection)\n# list(paginated...) should be avoided for queries that could return more than a dozen results"
263+
"source": [
264+
"# Note that if you selected a `project_id` without any labels this will raise `StopIteration`\n",
265+
"# Iterate over them to get the items out.\n",
266+
"next(labels_paginated_collection)\n",
267+
"# list(paginated...) should be avoided for queries that could return more than a dozen results"
268+
]
238269
},
239270
{
240271
"cell_type": "markdown",
@@ -263,7 +294,21 @@
263294
]
264295
}
265296
],
266-
"source": "datasets = client.get_datasets(where=Dataset.name == DATASET_NAME)\n\nprojects = client.get_projects(\n where=((Project.name == PROJECT_NAME) &\n (Project.description == \"new description field\")))\n\n# The above two queries return PaginatedCollections because the filter parameters aren't guaranteed to be unique.\n# So even if there is one element returned it is in a paginatedCollection.\nprint(projects)\nprint(next(projects, None))\nprint(next(projects, None))\nprint(next(projects, None))\n# We can see there is only one."
297+
"source": [
298+
"datasets = client.get_datasets(where=Dataset.name == DATASET_NAME)\n",
299+
"\n",
300+
"projects = client.get_projects(\n",
301+
" where=((Project.name == PROJECT_NAME) &\n",
302+
" (Project.description == \"new description field\")))\n",
303+
"\n",
304+
"# The above two queries return PaginatedCollections because the filter parameters aren't guaranteed to be unique.\n",
305+
"# So even if there is one element returned it is in a paginatedCollection.\n",
306+
"print(projects)\n",
307+
"print(next(projects, None))\n",
308+
"print(next(projects, None))\n",
309+
"print(next(projects, None))\n",
310+
"# We can see there is only one."
311+
]
267312
},
268313
{
269314
"cell_type": "markdown",
@@ -305,7 +350,11 @@
305350
"output_type": "execute_result"
306351
}
307352
],
308-
"source": "# Dataset has a Relationship to a Project so we can use the following\nlist(dataset.projects())\n# This will return all projects that are attached to this dataset"
353+
"source": [
354+
"# Dataset has a Relationship to a Project so we can use the following\n",
355+
"list(dataset.projects())\n",
356+
"# This will return all projects that are attached to this dataset"
357+
]
309358
},
310359
{
311360
"cell_type": "code",
@@ -324,7 +373,10 @@
324373
"output_type": "execute_result"
325374
}
326375
],
327-
"source": "sample_project_datasets = project.datasets()\nlist(sample_project_datasets)"
376+
"source": [
377+
"sample_project_datasets = project.datasets()\n",
378+
"list(sample_project_datasets)"
379+
]
328380
},
329381
{
330382
"cell_type": "markdown",
@@ -341,7 +393,12 @@
341393
"id": "persistent-briefs",
342394
"metadata": {},
343395
"outputs": [],
344-
"source": "#Eg.\n##### project.delete()\n##### dataset.delete()\n##### data_row.delete()"
396+
"source": [
397+
"#Eg.\n",
398+
"##### project.delete()\n",
399+
"##### dataset.delete()\n",
400+
"##### data_row.delete()"
401+
]
345402
},
346403
{
347404
"cell_type": "markdown",
@@ -358,7 +415,7 @@
358415
"id": "thirty-interval",
359416
"metadata": {},
360417
"outputs": [],
361-
"source": ""
418+
"source": []
362419
}
363420
],
364421
"metadata": {
@@ -382,4 +439,4 @@
382439
},
383440
"nbformat": 4,
384441
"nbformat_minor": 5
385-
}
442+
}

0 commit comments

Comments
 (0)