diff --git a/examples/project_configuration/webhooks.ipynb b/examples/project_configuration/webhooks.ipynb
index 799b40e2c..904e13f91 100644
--- a/examples/project_configuration/webhooks.ipynb
+++ b/examples/project_configuration/webhooks.ipynb
@@ -1,18 +1,16 @@
{
- "nbformat": 4,
- "nbformat_minor": 5,
- "metadata": {},
"cells": [
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"
\n",
" \n",
" | "
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"\n",
@@ -24,30 +22,32 @@
" \n",
" | "
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"# Webhook Configuration"
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "markdown",
+ "id": "18fc16be",
"metadata": {},
"source": [
"Webhooks are supported for the following events:\n",
"* label_created\n",
"* label_updated\n",
- "* label_deleted\n",
- "* review_created\n",
- "* review_updated"
- ],
- "cell_type": "markdown"
+ "* label_deleted"
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "ad5486cd",
"metadata": {},
+ "outputs": [],
"source": [
"!pip install labelbox\n",
"!pip install requests\n",
@@ -55,13 +55,14 @@
"!pip install hashlib\n",
"!pip install flask\n",
"!pip install Werkzeug"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "a2a8f3b2",
"metadata": {},
+ "outputs": [],
"source": [
"import labelbox as lb\n",
"from flask import Flask, request\n",
@@ -74,13 +75,14 @@
"import os\n",
"from getpass import getpass\n",
"import socket"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "99a23b2b",
"metadata": {},
+ "outputs": [],
"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",
@@ -97,44 +99,46 @@
" API_KEY = getpass(\"Please enter your labelbox api key\")\n",
" if COLAB:\n",
" envvar_handler.add_env(\"LABELBOX_API_KEY\", API_KEY)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "ee93a4ab",
"metadata": {},
+ "outputs": [],
"source": [
"# Set this to a project that you want to use for the webhook\n",
"PROJECT_ID = \"\"\n",
"# Only update this if you have an on-prem deployment\n",
"ENDPOINT = \"https://api.labelbox.com/graphql\""
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "a161946b",
"metadata": {},
+ "outputs": [],
"source": [
"client = lb.Client(api_key=API_KEY, endpoint=ENDPOINT)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "29890bf8",
"metadata": {},
+ "outputs": [],
"source": [
"# We are using port 3001 for this example.\n",
"# Feel free to set to whatever port you want\n",
"WH_PORT = 3001"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "markdown",
+ "id": "8e48bb5f",
"metadata": {},
"source": [
"### Configure NGROK (Optional)\n",
@@ -145,38 +149,44 @@
"2. Download ngrok and extract the zip file\n",
"3. Add ngrok to your path\n",
"4. Add the authtoken `ngrok authtoken `"
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "005702a2",
"metadata": {},
+ "outputs": [],
"source": [
"if not COLAB:\n",
" os.system(f\"ngrok http {WH_PORT} &\")"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "markdown",
+ "id": "4417e81b",
"metadata": {},
"source": [
"### Configure server to receive requests"
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "4bbfd57c",
"metadata": {},
+ "outputs": [],
"source": [
"# This can be any secret that matches your webhook config (we will set later)\n",
"secret = b\"example_secret\""
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "5b98f952",
"metadata": {},
+ "outputs": [],
"source": [
"app = Flask(__name__)\n",
"\n",
@@ -207,44 +217,49 @@
"\n",
"thread = threading.Thread(target=lambda: run_simple(\"0.0.0.0\", WH_PORT, app))\n",
"thread.start()"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "markdown",
+ "id": "2a6fce6d",
"metadata": {},
"source": [
"#### Test server"
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "c53f862c",
"metadata": {},
+ "outputs": [],
"source": [
"print(requests.get(\"http://localhost:3001\").text)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "markdown",
+ "id": "b84254a8",
"metadata": {},
"source": [
"### Create Webhook"
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "markdown",
+ "id": "916f3436",
"metadata": {},
"source": [
"- Set ip address if your ip is publicly accessible.\n",
"- Otherwise use the following to get ngrok public_url"
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "41832282",
"metadata": {},
+ "outputs": [],
"source": [
"if not COLAB:\n",
" res = requests.get(\"http://localhost:4040/api/tunnels\")\n",
@@ -259,13 +274,14 @@
"else:\n",
" public_url = f\"http://{socket.gethostbyname(socket.getfqdn(socket.gethostname()))}\"\n",
"print(public_url)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "2f18123e",
"metadata": {},
+ "outputs": [],
"source": [
"# Set project to limit the scope to a single project\n",
"project = client.get_project(PROJECT_ID)\n",
@@ -276,53 +292,56 @@
" url=public_url,\n",
" secret=secret.decode(),\n",
" project=project)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "b9226f8f",
"metadata": {},
+ "outputs": [],
"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\n",
"print(f\"https://app.labelbox.com/projects/{PROJECT_ID}\")"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "markdown",
+ "id": "bae73fb4",
"metadata": {},
"source": [
"### Update Webhook"
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
+ "id": "d7070ab0",
"metadata": {},
+ "outputs": [],
"source": [
"# url, topics, and status can all be updated\n",
"updated_url = f\"{public_url}/webhook-endpoint\"\n",
"print(updated_url)\n",
"webhook.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)\n",
+ "# Any supported action should work (create, delete, or update a label)\n",
"print(f\"https://app.labelbox.com/projects/{PROJECT_ID}\")"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
},
{
+ "cell_type": "markdown",
"metadata": {},
"source": [
"### List and delete all webhooks"
- ],
- "cell_type": "markdown"
+ ]
},
{
+ "cell_type": "code",
+ "execution_count": null,
"metadata": {},
+ "outputs": [],
"source": [
"# DELETE:\n",
"webhook.update(status=lb.Webhook.Status.INACTIVE.value)\n",
@@ -337,10 +356,14 @@
"# for webhook in webhooks:\n",
"# print(webhook)\n",
"# webhook.update(status = lb.Webhook.Status.INACTIVE.value)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
+ ]
+ }
+ ],
+ "metadata": {
+ "language_info": {
+ "name": "python"
}
- ]
-}
\ No newline at end of file
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}
diff --git a/labelbox/schema/webhook.py b/labelbox/schema/webhook.py
index cdcbd811a..1f1653c52 100644
--- a/labelbox/schema/webhook.py
+++ b/labelbox/schema/webhook.py
@@ -19,7 +19,6 @@ class Webhook(DbObject, Updateable):
created_at (datetime)
url (str)
topics (str): LABEL_CREATED, LABEL_UPDATED, LABEL_DELETED
- REVIEW_CREATED, REVIEW_UPDATED, REVIEW_DELETED
status (str): ACTIVE, INACTIVE, REVOKED
"""
@@ -33,9 +32,6 @@ class Topic(Enum):
LABEL_CREATED = "LABEL_CREATED"
LABEL_UPDATED = "LABEL_UPDATED"
LABEL_DELETED = "LABEL_DELETED"
- REVIEW_CREATED = "REVIEW_CREATED"
- REVIEW_UPDATED = "REVIEW_UPDATED"
- REVIEW_DELETED = "REVIEW_DELETED"
WORKFLOW_ACTION = "WORKFLOW_ACTION"
# For backwards compatibility