Skip to content

Commit 2fe156f

Browse files
authored
Merge pull request #524 from Labelbox/webhook_notebook
Remove review_deleted from webhook notebook
2 parents 4de21d4 + a31b627 commit 2fe156f

File tree

1 file changed

+52
-155
lines changed

1 file changed

+52
-155
lines changed

examples/project_configuration/webhooks.ipynb

Lines changed: 52 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,5 @@
11
{
22
"cells": [
3-
{
4-
"cell_type": "markdown",
5-
"id": "db768cda",
6-
"metadata": {},
7-
"source": [
8-
"<td>\n",
9-
" <a target=\"_blank\" href=\"https://labelbox.com\" ><img src=\"https://labelbox.com/blog/content/images/2021/02/logo-v4.svg\" width=256/></a>\n",
10-
"</td>"
11-
]
12-
},
13-
{
14-
"cell_type": "markdown",
15-
"id": "cb5611d0",
16-
"metadata": {},
17-
"source": [
18-
"<td>\n",
19-
"<a href=\"https://colab.research.google.com/github/Labelbox/labelbox-python/blob/develop/examples/project_configuration/webhooks.ipynb\" target=\"_blank\"><img\n",
20-
"src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"></a>\n",
21-
"</td>\n",
22-
"\n",
23-
"<td>\n",
24-
"<a href=\"https://github.com/Labelbox/labelbox-python/tree/develop/examples/project_configuration/webhooks.ipynb\" target=\"_blank\"><img\n",
25-
"src=\"https://img.shields.io/badge/GitHub-100000?logo=github&logoColor=white\" alt=\"GitHub\"></a>\n",
26-
"</td>"
27-
]
28-
},
293
{
304
"cell_type": "markdown",
315
"id": "registered-pressure",
@@ -44,8 +18,7 @@
4418
" 2. label_updated\n",
4519
" 3. label_deleted\n",
4620
" 4. review_created\n",
47-
" 5. review_updated\n",
48-
" 6. review_deleted"
21+
" 5. review_updated"
4922
]
5023
},
5124
{
@@ -55,12 +28,17 @@
5528
"metadata": {},
5629
"outputs": [],
5730
"source": [
58-
"!pip install -q labelbox hmac hashlib flask Werkzeug"
31+
"!pip install labelbox\n",
32+
"!pip install requests\n",
33+
"!pip install hmac\n",
34+
"!pip install hashlib\n",
35+
"!pip install flask\n",
36+
"!pip install Werkzeug"
5937
]
6038
},
6139
{
6240
"cell_type": "code",
63-
"execution_count": 2,
41+
"execution_count": null,
6442
"id": "responsible-clinton",
6543
"metadata": {},
6644
"outputs": [],
@@ -74,44 +52,60 @@
7452
"import json\n",
7553
"import requests\n",
7654
"import os\n",
55+
"from getpass import getpass\n",
7756
"import socket"
7857
]
7958
},
8059
{
8160
"cell_type": "code",
82-
"execution_count": 4,
83-
"id": "satellite-impossible",
61+
"execution_count": null,
62+
"id": "foreign-theorem",
8463
"metadata": {},
8564
"outputs": [],
8665
"source": [
87-
"# Set this to a project that you want to use for the webhook\n",
88-
"PROJECT_ID = \"ckm4xyfncfgja0760vpfdxoro\""
66+
"# If you don't want to give google access to drive you can skip this cell\n",
67+
"# and manually set `API_KEY` below.\n",
68+
"\n",
69+
"COLAB = \"google.colab\" in str(get_ipython())\n",
70+
"if COLAB:\n",
71+
" !pip install colab-env -qU\n",
72+
" from colab_env import envvar_handler\n",
73+
"\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)"
8981
]
9082
},
9183
{
92-
"cell_type": "markdown",
93-
"id": "170cae56",
84+
"cell_type": "code",
85+
"execution_count": null,
86+
"id": "satellite-impossible",
9487
"metadata": {},
88+
"outputs": [],
9589
"source": [
96-
"# API Key and Client\n",
97-
"Provide a valid api key below in order to properly connect to the Labelbox Client."
90+
"# Set this to a project that you want to use for the webhook\n",
91+
"PROJECT_ID = \"\"\n",
92+
"# Only update this if you have an on-prem deployment\n",
93+
"ENDPOINT = \"https://api.labelbox.com/graphql\""
9894
]
9995
},
10096
{
10197
"cell_type": "code",
102-
"execution_count": 5,
98+
"execution_count": null,
10399
"id": "clean-ireland",
104100
"metadata": {},
105101
"outputs": [],
106102
"source": [
107-
"# Add your api key\n",
108-
"API_KEY = None\n",
109-
"client = Client(api_key=API_KEY)"
103+
"client = Client(api_key=API_KEY, endpoint=ENDPOINT)"
110104
]
111105
},
112106
{
113107
"cell_type": "code",
114-
"execution_count": 6,
108+
"execution_count": null,
115109
"id": "bacterial-cheat",
116110
"metadata": {},
117111
"outputs": [],
@@ -138,21 +132,10 @@
138132
},
139133
{
140134
"cell_type": "code",
141-
"execution_count": 7,
135+
"execution_count": null,
142136
"id": "aboriginal-antibody",
143137
"metadata": {},
144-
"outputs": [
145-
{
146-
"data": {
147-
"text/plain": [
148-
"0"
149-
]
150-
},
151-
"execution_count": 6,
152-
"metadata": {},
153-
"output_type": "execute_result"
154-
}
155-
],
138+
"outputs": [],
156139
"source": [
157140
"if not COLAB:\n",
158141
" os.system(f\"ngrok http {WH_PORT} &\")"
@@ -168,7 +151,7 @@
168151
},
169152
{
170153
"cell_type": "code",
171-
"execution_count": 8,
154+
"execution_count": null,
172155
"id": "stable-group",
173156
"metadata": {},
174157
"outputs": [],
@@ -179,7 +162,7 @@
179162
},
180163
{
181164
"cell_type": "code",
182-
"execution_count": 9,
165+
"execution_count": null,
183166
"id": "limiting-variety",
184167
"metadata": {},
185168
"outputs": [],
@@ -225,26 +208,10 @@
225208
},
226209
{
227210
"cell_type": "code",
228-
"execution_count": 10,
211+
"execution_count": null,
229212
"id": "delayed-convention",
230213
"metadata": {},
231-
"outputs": [
232-
{
233-
"name": "stderr",
234-
"output_type": "stream",
235-
"text": [
236-
" * Running on http://0.0.0.0:3001/ (Press CTRL+C to quit)\n",
237-
"127.0.0.1 - - [29/Mar/2021 16:54:32] \"\u001b[37mGET / HTTP/1.1\u001b[0m\" 200 -\n"
238-
]
239-
},
240-
{
241-
"name": "stdout",
242-
"output_type": "stream",
243-
"text": [
244-
"Hello, World!\n"
245-
]
246-
}
247-
],
214+
"outputs": [],
248215
"source": [
249216
"print(requests.get(\"http://localhost:3001\").text)"
250217
]
@@ -268,7 +235,7 @@
268235
},
269236
{
270237
"cell_type": "code",
271-
"execution_count": 11,
238+
"execution_count": null,
272239
"id": "biblical-scottish",
273240
"metadata": {},
274241
"outputs": [],
@@ -290,7 +257,7 @@
290257
},
291258
{
292259
"cell_type": "code",
293-
"execution_count": 12,
260+
"execution_count": null,
294261
"id": "raising-preservation",
295262
"metadata": {},
296263
"outputs": [],
@@ -307,18 +274,10 @@
307274
},
308275
{
309276
"cell_type": "code",
310-
"execution_count": 13,
277+
"execution_count": null,
311278
"id": "approximate-gothic",
312279
"metadata": {},
313-
"outputs": [
314-
{
315-
"name": "stdout",
316-
"output_type": "stream",
317-
"text": [
318-
"https://app.labelbox.com/projects/ckm4xyfncfgja0760vpfdxoro\n"
319-
]
320-
}
321-
],
280+
"outputs": [],
322281
"source": [
323282
"# Ok so we should be configured assuming everything is setup correctly.\n",
324283
"# Go to the following url and make a new label to see if it works\n",
@@ -327,7 +286,7 @@
327286
},
328287
{
329288
"cell_type": "code",
330-
"execution_count": 14,
289+
"execution_count": null,
331290
"id": "worst-material",
332291
"metadata": {},
333292
"outputs": [],
@@ -345,72 +304,10 @@
345304
},
346305
{
347306
"cell_type": "code",
348-
"execution_count": 15,
307+
"execution_count": null,
349308
"id": "stopped-steel",
350309
"metadata": {},
351-
"outputs": [
352-
{
353-
"name": "stdout",
354-
"output_type": "stream",
355-
"text": [
356-
"https://eb3e7f8eb089.ngrok.io/webhook-endpoint\n"
357-
]
358-
},
359-
{
360-
"name": "stderr",
361-
"output_type": "stream",
362-
"text": [
363-
"127.0.0.1 - - [17/Mar/2021 09:52:00] \"\u001b[37mPOST /webhook-endpoint HTTP/1.1\u001b[0m\" 200 -\n"
364-
]
365-
},
366-
{
367-
"name": "stdout",
368-
"output_type": "stream",
369-
"text": [
370-
"=========== New Webhook Delivery ============\n",
371-
"Delivery ID: ckmdi74ew57lq063553kuzekq\n",
372-
"Event: LABEL_UPDATED\n",
373-
"Payload: {\n",
374-
" \"id\": \"ckmb8h50t008f3h683tugqsap\",\n",
375-
" \"createdAt\": \"2021-03-15T23:44:18Z\",\n",
376-
" \"updatedAt\": \"2021-03-17T13:51:59Z\",\n",
377-
" \"secondsToLabel\": 79.173,\n",
378-
" \"label\": \"{\\\"objects\\\":[{\\\"featureId\\\":\\\"ckmb8gvd9008b3h68l5tcmrt1\\\",\\\"schemaId\\\":\\\"ckm3se1a5010y0y6rcdc0bvvl\\\",\\\"title\\\":\\\"animal\\\",\\\"value\\\":\\\"animal\\\",\\\"color\\\":\\\"#1CE6FF\\\",\\\"bbox\\\":{\\\"top\\\":325,\\\"left\\\":233,\\\"height\\\":266,\\\"width\\\":413},\\\"instanceURI\\\":\\\"https://api.labelbox.com/masks/feature/ckmb8gvd9008b3h68l5tcmrt1\\\"},{\\\"featureId\\\":\\\"ckmbdp94300013h68y14zluto\\\",\\\"schemaId\\\":\\\"ckmbdol5s1ybk0y96fje86ktu\\\",\\\"title\\\":\\\"human\\\",\\\"value\\\":\\\"human\\\",\\\"color\\\":\\\"#FF34FF\\\",\\\"bbox\\\":{\\\"top\\\":75,\\\"left\\\":527,\\\"height\\\":453,\\\"width\\\":155},\\\"instanceURI\\\":\\\"https://api.labelbox.com/masks/feature/ckmbdp94300013h68y14zluto\\\"},{\\\"featureId\\\":\\\"ckmbdpdda00043h688pqrsoku\\\",\\\"schemaId\\\":\\\"ckmbdol5s1ybk0y96fje86ktu\\\",\\\"title\\\":\\\"human\\\",\\\"value\\\":\\\"human\\\",\\\"color\\\":\\\"#FF34FF\\\",\\\"bbox\\\":{\\\"top\\\":81,\\\"left\\\":666,\\\"height\\\":396,\\\"width\\\":134},\\\"instanceURI\\\":\\\"https://api.labelbox.com/masks/feature/ckmbdpdda00043h688pqrsoku\\\"},{\\\"featureId\\\":\\\"ckmbdpgd200073h68cu3vhjf2\\\",\\\"schemaId\\\":\\\"ckmbdol5s1ybk0y96fje86ktu\\\",\\\"title\\\":\\\"human\\\",\\\"value\\\":\\\"human\\\",\\\"color\\\":\\\"#FF34FF\\\",\\\"bbox\\\":{\\\"top\\\":0,\\\"left\\\":722,\\\"height\\\":535,\\\"width\\\":259},\\\"instanceURI\\\":\\\"https://api.labelbox.com/masks/feature/ckmbdpgd200073h68cu3vhjf2\\\"},{\\\"featureId\\\":\\\"ckmdi72l700043g68i52bq31i\\\",\\\"schemaId\\\":\\\"ckm3se1a5010y0y6rcdc0bvvl\\\",\\\"title\\\":\\\"animal\\\",\\\"value\\\":\\\"animal\\\",\\\"color\\\":\\\"#1CE6FF\\\",\\\"bbox\\\":{\\\"top\\\":94,\\\"left\\\":65,\\\"height\\\":104,\\\"width\\\":67},\\\"instanceURI\\\":\\\"https://api.labelbox.com/masks/feature/ckmdi72l700043g68i52bq31i\\\"}],\\\"classifications\\\":[{\\\"featureId\\\":\\\"ckmb8h0t7008e3h68hhmuf3y4\\\",\\\"schemaId\\\":\\\"ckm3se1a4010w0y6rd579gyl3\\\",\\\"title\\\":\\\"image\\\",\\\"value\\\":\\\"image\\\",\\\"answers\\\":[{\\\"featureId\\\":\\\"ckmb8h0t6008d3h689yq6cnm6\\\",\\\"schemaId\\\":\\\"ckm3se1aw01120y6r7zkcd93v\\\",\\\"title\\\":\\\"contains_human\\\",\\\"value\\\":\\\"contains_human\\\"}]}]}\",\n",
379-
" \"agreement\": null,\n",
380-
" \"benchmarkAgreement\": null,\n",
381-
" \"deleted\": false,\n",
382-
" \"project\": {\n",
383-
" \"id\": \"ckm4xyfncfgja0760vpfdxoro\",\n",
384-
" \"createdAt\": \"2021-03-11T14:03:12Z\",\n",
385-
" \"updatedAt\": \"2021-03-11T18:22:08.523Z\",\n",
386-
" \"name\": \"animal_demo_proj\",\n",
387-
" \"description\": \"\",\n",
388-
" \"deleted\": false\n",
389-
" },\n",
390-
" \"dataRow\": {\n",
391-
" \"id\": \"ckm4y6s5a1s7e0rb6bgf00oqa\",\n",
392-
" \"createdAt\": \"2021-03-11T14:09:41Z\",\n",
393-
" \"updatedAt\": \"2021-03-11T14:09:41Z\",\n",
394-
" \"deletedAt\": null,\n",
395-
" \"externalId\": \"uploaded_images/177.jpg\",\n",
396-
" \"rowData\": \"https://storage.labelbox.com/ckk4q1vgapsau07324awnsjq2%2F7b7f4198-3ea4-68db-9bf7-01dfd0bf3e8c-177.jpg?Expires=1617198719&KeyName=labelbox-assets-key-1&Signature=9mjtUoc61rooqsI8I2unQNU4N-o=\"\n",
397-
" },\n",
398-
" \"dataset\": {\n",
399-
" \"id\": \"ckm4xyfua04cf0z7a3wz58kgj\",\n",
400-
" \"createdAt\": \"2021-03-11T14:03:12Z\",\n",
401-
" \"updatedAt\": \"2021-03-11T14:03:12Z\",\n",
402-
" \"name\": \"animal_demo_ds\",\n",
403-
" \"description\": \"\",\n",
404-
" \"deleted\": false\n",
405-
" },\n",
406-
" \"user\": {\n",
407-
" \"id\": \"ckm570mgm7q880795an0rfzmz\",\n",
408-
" \"email\": \"amanda+1@labelbox.com\"\n",
409-
" }\n",
410-
"}\n"
411-
]
412-
}
413-
],
310+
"outputs": [],
414311
"source": [
415312
"# url, topics, and status can all be updated\n",
416313
"updated_url = f\"{public_url}/webhook-endpoint\"\n",
@@ -431,7 +328,7 @@
431328
},
432329
{
433330
"cell_type": "code",
434-
"execution_count": 16,
331+
"execution_count": null,
435332
"id": "distant-commitment",
436333
"metadata": {},
437334
"outputs": [],
@@ -468,7 +365,7 @@
468365
"name": "python",
469366
"nbconvert_exporter": "python",
470367
"pygments_lexer": "ipython3",
471-
"version": "3.9.2"
368+
"version": "3.8.2"
472369
}
473370
},
474371
"nbformat": 4,

0 commit comments

Comments
 (0)