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\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
+
"source": [
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",
"source": "# Set this to a project that you want to use for the webhook\nPROJECT_ID = \"ckm4xyfncfgja0760vpfdxoro\"\n# Only update this if you have an on-prem deployment\nENDPOINT = \"https://api.labelbox.com/graphql\""
89
+
"source": [
90
+
"# Set this to a project that you want to use for the webhook\n",
91
+
"PROJECT_ID = \"ckm4xyfncfgja0760vpfdxoro\"\n",
92
+
"# Only update this if you have an on-prem deployment\n",
"source": "if not COLAB:\n res = requests.get(\"http://localhost:4040/api/tunnels\")\n assert (res.status_code == 200\n ), f\"ngrok probably isn't running. {res.status_code}, {res.text}\"\n tunnels = res.json()[\"tunnels\"]\n tunnel = [\n t for t in tunnels if t[\"config\"][\"addr\"].split(\":\")[-1] == str(WH_PORT)\n ]\n tunnel = tunnel[0] # Should only be one..\n public_url = tunnel[\"public_url\"]\nelse:\n public_url = f\"http://{socket.gethostbyname(socket.getfqdn(socket.gethostname()))}\"\nprint(public_url)"
269
+
"source": [
270
+
"if not COLAB:\n",
271
+
" res = requests.get(\"http://localhost:4040/api/tunnels\")\n",
"source": "# Set project to limit the scope to a single project\nproject = client.get_project(PROJECT_ID)\ntopics = {topic.value for topic in Webhook.Topic}\nwebhook = Webhook.create(client,\n topics=topics,\n url=public_url,\n secret=secret.decode(),\n project=project)"
291
+
"source": [
292
+
"# Set project to limit the scope to a single project\n",
293
+
"project = client.get_project(PROJECT_ID)\n",
294
+
"topics = {topic.value for topic in Webhook.Topic}\n",
295
+
"webhook = Webhook.create(client,\n",
296
+
" topics=topics,\n",
297
+
" url=public_url,\n",
298
+
" secret=secret.decode(),\n",
299
+
" project=project)"
300
+
]
195
301
},
196
302
{
197
303
"cell_type": "code",
@@ -207,15 +313,21 @@
207
313
]
208
314
}
209
315
],
210
-
"source": "# Ok so we should be configured assuming everything is setup correctly.\n# Go to the following url and make a new label to see if it works\nprint(f\"https://app.labelbox.com/projects/{PROJECT_ID}\")"
316
+
"source": [
317
+
"# Ok so we should be configured assuming everything is setup correctly.\n",
318
+
"# Go to the following url and make a new label to see if it works\n",
"source": "## Oops we made a mistake. The url was incorrect. We pointed the url to the hello world endpoint."
328
+
"source": [
329
+
"## Oops we made a mistake. The url was incorrect. We pointed the url to the hello world endpoint."
330
+
]
219
331
},
220
332
{
221
333
"cell_type": "markdown",
@@ -293,7 +405,15 @@
293
405
]
294
406
}
295
407
],
296
-
"source": "# url, topics, and status can all be updated\nupdated_url = f\"{public_url}/webhook-endpoint\"\nprint(updated_url)\nwebhook.update(url=updated_url)\n# Go to the following url and try one last time.\n# Any supported action should work (create, delete, update a label, or create, update, or delete a review)\nprint(f\"https://app.labelbox.com/projects/{PROJECT_ID}\")"
"source": "# DELETE:\nwebhook.update(status=Webhook.Status.INACTIVE.value)\n\n# FETCH ALL WEBHOOKS:\norg = client.get_organization()\nwebhooks = org.webhooks()\n\n# Run this to clear all.\n# WARNING!!! THIS WILL DELETE ALL WEBHOOKS FOR YOUR ORG\n# ONLY RUN THIS IS YOU KNOW WHAT YOU ARE DOING.\n# for webhook in webhooks:\n# print(webhook)\n# webhook.update(status = Webhook.Status.INACTIVE.value)"
0 commit comments