Skip to content

Commit a76f0b6

Browse files
author
Matt Sokoloff
committed
credential management
1 parent 7ec6f9e commit a76f0b6

File tree

18 files changed

+433
-57
lines changed

18 files changed

+433
-57
lines changed

examples/README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
Structure:
66

77
1. basics
8-
* [Fundamentals](basics/basics.ipynb)
8+
* [Fundamentals](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/basics/basics.ipynb)
99
* CRUD
10-
* [Data rows](basics/data_rows.ipynb)
11-
* [Datasets](basics/datasets.ipynb)
12-
* [Labels](basics/labels.ipynb)
13-
* [Ontologies](basics/ontologies.ipynb)
14-
* [Projects](basics/projects.ipynb)
10+
* [Data rows](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/basics/data_rows.ipynb)
11+
* [Datasets](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/basics/datasets.ipynb)
12+
* [Labels](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/basics/labels.ipynb)
13+
* [Ontologies](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/basics/ontologies.ipynb)
14+
* [Projects](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/basics/projects.ipynb)
1515
2. label_export
16-
* [Image annotation export](label_export/images.ipynb)
17-
* [Text annotation export](label_export/text.ipynb)
18-
* [Video annotation export](label_export/video.ipynb)
16+
* [Image annotation export](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/label_export/images.ipynb)
17+
* [Text annotation export](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/label_export/text.ipynb)
18+
* [Video annotation export](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/abel_export/video.ipynb)
1919
3. model_assisted_labeling
20-
* [MAL introduction](model_assisted_labeling/mal_introduction.ipynb)
21-
* [Image mal example](model_assisted_labeling/image_mal.ipynb)
22-
* [Named entity recognition mal example](model_assisted_labeling/ner_mal.ipynb)
23-
* [Debugging mal](model_assisted_labeling/debugging_mal.ipynb)
24-
* [MAL with subclasses](model_assisted_labeling/mal_with_subclasses.ipynb)
20+
* [MAL introduction](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/model_assisted_labeling/mal_introduction.ipynb)
21+
* [Image mal example](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/model_assisted_labeling/image_mal.ipynb)
22+
* [Named entity recognition mal example](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/model_assisted_labeling/ner_mal.ipynb)
23+
* [Debugging mal](https://colab.research.google.com/github/Labelbox/labelbox-python/tree/examples/examples/model_assisted_labeling/debugging_mal.ipynb)
24+
* [MAL with subclasses](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/model_assisted_labeling/mal_with_subclasses.ipynb)
2525
4. project_configuration
26-
* [Project setup](project_configuration/project_setup.ipynb)
27-
* [Queue management](project_configuration/queue_management.ipynb)
28-
* [Webhooks](project_configuration/webhooks.ipynb)
26+
* [Project setup](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/project_configuration/project_setup.ipynb)
27+
* [Queue management](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/project_configuration/queue_management.ipynb)
28+
* [Webhooks](https://colab.research.google.com/github/Labelbox/labelbox-python/blob/examples/examples/project_configuration/webhooks.ipynb)

examples/basics/basics.ipynb

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,40 @@
4646
},
4747
{
4848
"cell_type": "code",
49-
"execution_count": 5,
49+
"execution_count": 2,
5050
"id": "everyday-street",
5151
"metadata": {},
5252
"outputs": [],
5353
"source": [
5454
"from labelbox import Client\n",
5555
"from labelbox import Project, Dataset\n",
56+
"from getpass import getpass\n",
5657
"import os"
5758
]
5859
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": 4,
63+
"id": "crude-receiver",
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"# If you don't want to give google access to drive you can skip this cell\n",
68+
"# and manually set `API_KEY` below.\n",
69+
"\n",
70+
"COLAB = \"google.colab\" in str(get_ipython())\n",
71+
"if COLAB:\n",
72+
" !pip install colab-env -qU\n",
73+
" from colab_env import envvar_handler\n",
74+
" envvar_handler.envload() \n",
75+
"\n",
76+
"API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
77+
"if not os.environ.get(\"LABELBOX_API_KEY\"):\n",
78+
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
79+
" if COLAB:\n",
80+
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
81+
]
82+
},
5983
{
6084
"cell_type": "markdown",
6185
"id": "committed-matthew",
@@ -86,8 +110,6 @@
86110
"DATASET_ID = \"ckk4q1vjznyhu087203wlghfr\"\n",
87111
"PROJECT_NAME = \"Sample Project\"\n",
88112
"DATASET_NAME = \"Example Jellyfish Dataset\"\n",
89-
"# Set this if running in colab. Otherwise it should work if you have the LABELBOX_API_KEY set.\n",
90-
"API_KEY = os.environ[\"LABELBOX_API_KEY\"]\n",
91113
"# Only update this if you have an on-prem deployment\n",
92114
"ENDPOINT = \"https://api.labelbox.com/graphql\""
93115
]

examples/basics/data_rows.ipynb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,34 @@
4040
"outputs": [],
4141
"source": [
4242
"from labelbox import DataRow, Client\n",
43+
"from getpass import getpass\n",
4344
"import uuid\n",
4445
"import os"
4546
]
4647
},
48+
{
49+
"cell_type": "code",
50+
"execution_count": null,
51+
"id": "vertical-stockholm",
52+
"metadata": {},
53+
"outputs": [],
54+
"source": [
55+
"# If you don't want to give google access to drive you can skip this cell\n",
56+
"# and manually set `API_KEY` below.\n",
57+
"\n",
58+
"COLAB = \"google.colab\" in str(get_ipython())\n",
59+
"if COLAB:\n",
60+
" !pip install colab-env -qU\n",
61+
" from colab_env import envvar_handler\n",
62+
" envvar_handler.envload() \n",
63+
"\n",
64+
"API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
65+
"if not os.environ.get(\"LABELBOX_API_KEY\"):\n",
66+
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
67+
" if COLAB:\n",
68+
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
69+
]
70+
},
4771
{
4872
"cell_type": "markdown",
4973
"id": "legendary-harvard",
@@ -61,8 +85,6 @@
6185
"source": [
6286
"# Pick a project that has a dataset attached, data has external ids, and there are some labels\n",
6387
"PROJECT_ID = \"ckk4q1viuc0w20704eh69u28h\"\n",
64-
"# Set this if running in colab. Otherwise it should work if you have the LABELBOX_API_KEY set.\n",
65-
"API_KEY = os.environ[\"LABELBOX_API_KEY\"]\n",
6688
"# Only update this if you have an on-prem deployment\n",
6789
"ENDPOINT = \"https://api.labelbox.com/graphql\""
6890
]

examples/basics/datasets.ipynb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,34 @@
3838
"outputs": [],
3939
"source": [
4040
"from labelbox import Client\n",
41+
"from getpass import getpass\n",
4142
"import uuid\n",
4243
"import os"
4344
]
4445
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"id": "secret-shore",
50+
"metadata": {},
51+
"outputs": [],
52+
"source": [
53+
"# If you don't want to give google access to drive you can skip this cell\n",
54+
"# and manually set `API_KEY` below.\n",
55+
"\n",
56+
"COLAB = \"google.colab\" in str(get_ipython())\n",
57+
"if COLAB:\n",
58+
" !pip install colab-env -qU\n",
59+
" from colab_env import envvar_handler\n",
60+
" envvar_handler.envload() \n",
61+
"\n",
62+
"API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
63+
"if not os.environ.get(\"LABELBOX_API_KEY\"):\n",
64+
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
65+
" if COLAB:\n",
66+
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
67+
]
68+
},
4569
{
4670
"cell_type": "markdown",
4771
"id": "geological-clear",

examples/basics/labels.ipynb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,29 @@
3838
"import os"
3939
]
4040
},
41+
{
42+
"cell_type": "code",
43+
"execution_count": null,
44+
"id": "shaped-particle",
45+
"metadata": {},
46+
"outputs": [],
47+
"source": [
48+
"# If you don't want to give google access to drive you can skip this cell\n",
49+
"# and manually set `API_KEY` below.\n",
50+
"\n",
51+
"COLAB = \"google.colab\" in str(get_ipython())\n",
52+
"if COLAB:\n",
53+
" !pip install colab-env -qU\n",
54+
" from colab_env import envvar_handler\n",
55+
" envvar_handler.envload() \n",
56+
"\n",
57+
"API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
58+
"if not os.environ.get(\"LABELBOX_API_KEY\"):\n",
59+
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
60+
" if COLAB:\n",
61+
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
62+
]
63+
},
4164
{
4265
"cell_type": "markdown",
4366
"id": "technical-receiver",
@@ -55,8 +78,6 @@
5578
"source": [
5679
"# Pick a project that has labels\n",
5780
"PROJECT_ID = \"ckmdx02yhzsrt0757owj3aprx\"\n",
58-
"# Set this if running in colab. Otherwise it should work if you have the LABELBOX_API_KEY set.\n",
59-
"API_KEY = os.environ[\"LABELBOX_API_KEY\"]\n",
6081
"# Only update this if you have an on-prem deployment\n",
6182
"ENDPOINT = \"https://api.labelbox.com/graphql\""
6283
]

examples/basics/ontologies.ipynb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,33 @@
3232
"source": [
3333
"from labelbox.schema.ontology import OntologyBuilder, Tool, Classification, Option\n",
3434
"from labelbox import Client\n",
35+
"from getpass import getpass\n",
3536
"import os"
3637
]
3738
},
39+
{
40+
"cell_type": "code",
41+
"execution_count": null,
42+
"id": "interested-bishop",
43+
"metadata": {},
44+
"outputs": [],
45+
"source": [
46+
"# If you don't want to give google access to drive you can skip this cell\n",
47+
"# and manually set `API_KEY` below.\n",
48+
"\n",
49+
"COLAB = \"google.colab\" in str(get_ipython())\n",
50+
"if COLAB:\n",
51+
" !pip install colab-env -qU\n",
52+
" from colab_env import envvar_handler\n",
53+
" envvar_handler.envload() \n",
54+
"\n",
55+
"API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
56+
"if not os.environ.get(\"LABELBOX_API_KEY\"):\n",
57+
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
58+
" if COLAB:\n",
59+
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
60+
]
61+
},
3862
{
3963
"cell_type": "markdown",
4064
"id": "educated-commercial",
@@ -53,8 +77,6 @@
5377
"# Make sure this project has been fully setup (see project examples/project_configuration/project_setup.ipynb)\n",
5478
"# You also can just setup a project in the web ui\n",
5579
"PROJECT_ID = \"ckm4xyfncfgja0760vpfdxoro\"\n",
56-
"# Set this if running in colab. Otherwise it should work if you have the LABELBOX_API_KEY set.\n",
57-
"API_KEY = os.environ[\"LABELBOX_API_KEY\"]\n",
5880
"# Only update this if you have an on-prem deployment\n",
5981
"ENDPOINT = \"https://api.labelbox.com/graphql\""
6082
]

examples/basics/projects.ipynb

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,36 @@
4343
"import os"
4444
]
4545
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"id": "transsexual-oakland",
50+
"metadata": {},
51+
"outputs": [],
52+
"source": [
53+
"# If you don't want to give google access to drive you can skip this cell\n",
54+
"# and manually set `API_KEY` below.\n",
55+
"\n",
56+
"COLAB = \"google.colab\" in str(get_ipython())\n",
57+
"if COLAB:\n",
58+
" !pip install colab-env -qU\n",
59+
" from colab_env import envvar_handler\n",
60+
" envvar_handler.envload() \n",
61+
"\n",
62+
"API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
63+
"if not os.environ.get(\"LABELBOX_API_KEY\"):\n",
64+
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
65+
" if COLAB:\n",
66+
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
67+
]
68+
},
4669
{
4770
"cell_type": "code",
4871
"execution_count": null,
4972
"id": "intermediate-istanbul",
5073
"metadata": {},
5174
"outputs": [],
5275
"source": [
53-
"# Set this if running in colab. Otherwise it should work if you have the LABELBOX_API_KEY set.\n",
54-
"API_KEY = os.environ[\"LABELBOX_API_KEY\"]\n",
5576
"# Only update this if you have an on-prem deployment\n",
5677
"ENDPOINT = \"https://api.labelbox.com/graphql\""
5778
]

examples/label_export/images.ipynb

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"!pip install requests\n",
2121
"!pip install numpy\n",
2222
"!pip install PILLOW\n",
23-
"!apt-get update && apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python"
23+
"!pip install opencv-python"
2424
]
2525
},
2626
{
@@ -32,12 +32,36 @@
3232
"source": [
3333
"from labelbox import Client\n",
3434
"import requests\n",
35+
"from getpass import getpass\n",
3536
"from PIL import Image\n",
36-
"import cv2\n",
3737
"import numpy as np\n",
3838
"from io import BytesIO\n",
3939
"from typing import Dict, Any\n",
40-
"import os"
40+
"import os\n",
41+
"import cv2"
42+
]
43+
},
44+
{
45+
"cell_type": "code",
46+
"execution_count": null,
47+
"id": "under-vancouver",
48+
"metadata": {},
49+
"outputs": [],
50+
"source": [
51+
"# If you don't want to give google access to drive you can skip this cell\n",
52+
"# and manually set `API_KEY` below.\n",
53+
"\n",
54+
"COLAB = \"google.colab\" in str(get_ipython())\n",
55+
"if COLAB:\n",
56+
" !pip install colab-env -qU\n",
57+
" from colab_env import envvar_handler\n",
58+
" envvar_handler.envload() \n",
59+
"\n",
60+
"API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
61+
"if not os.environ.get(\"LABELBOX_API_KEY\"):\n",
62+
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
63+
" if COLAB:\n",
64+
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
4165
]
4266
},
4367
{
@@ -50,8 +74,6 @@
5074
"# Pick a project that has and of box, point, polygon, or segmentation tools tools in the ontology\n",
5175
"# and has completed labels\n",
5276
"PROJECT_ID = \"ckmdx02yhzsrt0757owj3aprx\"\n",
53-
"# Set this if running in colab. Otherwise it should work if you have the LABELBOX_API_KEY set.\n",
54-
"API_KEY = os.environ[\"LABELBOX_API_KEY\"]\n",
5577
"# Only update this if you have an on-prem deployment\n",
5678
"ENDPOINT = \"https://api.labelbox.com/graphql\""
5779
]

examples/label_export/text.ipynb

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,35 @@
2828
"outputs": [],
2929
"source": [
3030
"from labelbox import Client\n",
31+
"from getpass import getpass\n",
3132
"import requests\n",
3233
"from collections import Counter\n",
3334
"import os"
3435
]
3536
},
37+
{
38+
"cell_type": "code",
39+
"execution_count": null,
40+
"id": "preceding-vitamin",
41+
"metadata": {},
42+
"outputs": [],
43+
"source": [
44+
"# If you don't want to give google access to drive you can skip this cell\n",
45+
"# and manually set `API_KEY` below.\n",
46+
"\n",
47+
"COLAB = \"google.colab\" in str(get_ipython())\n",
48+
"if COLAB:\n",
49+
" !pip install colab-env -qU\n",
50+
" from colab_env import envvar_handler\n",
51+
" envvar_handler.envload() \n",
52+
"\n",
53+
"API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
54+
"if not os.environ.get(\"LABELBOX_API_KEY\"):\n",
55+
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
56+
" if COLAB:\n",
57+
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
58+
]
59+
},
3660
{
3761
"cell_type": "code",
3862
"execution_count": 3,
@@ -42,8 +66,6 @@
4266
"source": [
4367
"# Pick a project that has entity tools in the ontology and has completed labels\n",
4468
"PROJECT_ID = \"ckme5v7aykpoj0709ufi5h6i2\"\n",
45-
"# Set this if running in colab. Otherwise it should work if you have the LABELBOX_API_KEY set.\n",
46-
"API_KEY = os.environ[\"LABELBOX_API_KEY\"]\n",
4769
"# Only update this if you have an on-prem deployment\n",
4870
"ENDPOINT = \"https://api.labelbox.com/graphql\""
4971
]

0 commit comments

Comments
 (0)