diff --git a/examples/project_configuration/README.md b/examples/project_configuration/README.md
deleted file mode 100644
index a907bd5ce..000000000
--- a/examples/project_configuration/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-- This section describes advanced usage of project configuration.
-- Make sure you are comfortable with the basics/project section first.
diff --git a/examples/project_configuration/project_setup.ipynb b/examples/project_configuration/project_setup.ipynb
index 19538c905..198e5bbdf 100644
--- a/examples/project_configuration/project_setup.ipynb
+++ b/examples/project_configuration/project_setup.ipynb
@@ -1,242 +1,178 @@
{
- "nbformat": 4,
- "nbformat_minor": 5,
- "metadata": {},
- "cells": [
- {
- "metadata": {},
- "source": [
- "
\n",
- " \n",
- " | "
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "\n",
- "\n",
- " | \n",
- "\n",
- "\n",
- "\n",
- " | "
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# Project Setup\n",
- "* This notebok describes how to create and configure a project\n",
- "* This is the same as creating a new project in the editor and going through all of the steps."
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "* When a user creates a project with client.create_project() the project is not ready for labeling.\n",
- " * An ontology must be set\n",
- " * A Batch must be created"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "!pip install labelbox[data]"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "import labelbox as lb\n",
- "from labelbox.schema.quality_mode import QualityMode\n",
- "import uuid"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# API Key and Client\n",
- "Provide a valid api key below in order to properly connect to the Labelbox Client."
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# Add your api key\n",
- "API_KEY=\"\"\n",
- "client = lb.Client(api_key=API_KEY)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "### Create Dataset\n",
- "* Create dataset and attach data\n",
- "* More details on attaching data can be found [here](https://github.com/Labelbox/labelbox-python/blob/master/examples/basics/data_rows.ipynb)"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "dataset = client.create_dataset(name=\"project_setup_demo\")\n",
- "global_keys = [\"id1\", \"id2\", \"id3\", \"id4\"]\n",
- "## Example image\n",
- "uploads = []\n",
- "# Generate data rows\n",
- "for i in range(1,5):\n",
- " uploads.append({\n",
- " 'row_data': f\"https://storage.googleapis.com/labelbox-datasets/People_Clothing_Segmentation/jpeg_images/IMAGES/img_000{i}.jpeg\",\n",
- " \"global_key\": global_keys[i-1]\n",
- " })\n",
- "task = dataset.create_data_rows(uploads)\n",
- "task.wait_till_done()\n",
- "print(\"ERRORS: \" , task.errors)\n",
- "print(\"RESULT URL: \", task.result_url)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "### Create Or Select an Ontology\n",
- "* Optionally create an ontology or select from an existing one.\n",
- "* More details on ontology management can be found [here](https://github.com/Labelbox/labelbox-python/blob/master/examples/basics/ontologies.ipynb)\n",
- " "
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# Create\n",
- "ontology_builder = lb.OntologyBuilder(\n",
- " tools=[lb.Tool(name=\"cat\", tool=lb.Tool.Type.BBOX)])\n",
- "ontology = client.create_ontology(\"project-setup-demo-ontology\",\n",
- " ontology_builder.asdict())\n",
- "# Select existing ontology\n",
- "#ontology = client.get_ontology(\"\")\n",
- "#ontology = existing_project.ontology()"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "### Create Project and Setup the Editor\n",
- "* Setting up a project will add an ontology and will enable labeling to begin\n",
- "* Creating batches will add all data_rows belonging to the dataset to the queue."
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "\n",
- "batch_project = client.create_project(name=\"Project Setup Demo\",\n",
- " quality_mode=QualityMode.Consensus, # For benchmarks use quality_mode = QualityMode.Benchmark\n",
- " media_type=lb.MediaType.Image)\n",
- "\n",
- "\n",
- "batch_project.setup_editor(ontology)\n"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Add data to your projects "
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "\n",
- "## When creating a batch you can also setup the data rows priority\n",
- "batch = batch_project.create_batch(\n",
- " \"batch-demo-4\", # Each batch in a project must have a unique name\n",
- " global_keys=global_keys, # A list of data rows or data row ids\n",
- " priority=5, # priority between 1(Highest) - 5(lowest)\n",
- " consensus_settings={\n",
- " \"number_of_labels\": 2,\n",
- " \"coverage_percentage\": 1\n",
- " }\n",
- ")\n",
- "print(\"Batch: \", batch)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "### Review"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# Note setup_complete will be None if it fails.\n",
- "print(batch_project.setup_complete)\n",
- "print(batch_project.ontology())\n",
- "print([ds.name for ds in batch_project.batches()])\n"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "print(f\"https://app.labelbox.com/projects/{batch_project.uid}\")"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Cleanup"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# batch_project.delete()\n",
- "# dataset_project.delete()\n",
- "# dataset.delete()"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- }
- ]
+ "nbformat": 4,
+ "nbformat_minor": 5,
+ "metadata": {},
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "db768cda",
+ "metadata": {},
+ "source": [
+ "",
+ " ",
+ " | "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "cb5611d0",
+ "metadata": {},
+ "source": [
+ "",
+ "",
+ " | ",
+ "\n",
+ "",
+ "",
+ " | "
+ ]
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# Project Setup\n",
+ "* This notebok describes how to create and configure a project\n",
+ "* This is the same as creating a new project in the editor and going through all of the steps."
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": [
+ "* When a user creates a project with client.create_project() the project is not ready for labeling.\n",
+ " * An ontology must be set\n",
+ " * A Batch must be created"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "%pip install labelbox[data]",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "import labelbox as lb\nfrom labelbox.schema.quality_mode import QualityMode\nimport uuid",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# API Key and Client\n",
+ "Provide a valid api key below in order to properly connect to the Labelbox Client."
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "# Add your api key\nAPI_KEY = \"\"\nclient = lb.Client(api_key=API_KEY)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### Create Dataset\n",
+ "* Create dataset and attach data\n",
+ "* More details on attaching data can be found [here](https://github.com/Labelbox/labelbox-python/blob/master/examples/basics/data_rows.ipynb)"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "dataset = client.create_dataset(name=\"project_setup_demo\")\nglobal_keys = [\"id1\", \"id2\", \"id3\", \"id4\"]\n## Example image\nuploads = []\n# Generate data rows\nfor i in range(1, 5):\n uploads.append({\n \"row_data\":\n f\"https://storage.googleapis.com/labelbox-datasets/People_Clothing_Segmentation/jpeg_images/IMAGES/img_000{i}.jpeg\",\n \"global_key\":\n global_keys[i - 1],\n })\ntask = dataset.create_data_rows(uploads)\ntask.wait_till_done()\nprint(\"ERRORS: \", task.errors)\nprint(\"RESULT URL: \", task.result_url)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### Create Or Select an Ontology\n",
+ "* Optionally create an ontology or select from an existing one.\n",
+ "* More details on ontology management can be found [here](https://github.com/Labelbox/labelbox-python/blob/master/examples/basics/ontologies.ipynb)\n",
+ " "
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "# Create\nontology_builder = lb.OntologyBuilder(\n tools=[lb.Tool(name=\"cat\", tool=lb.Tool.Type.BBOX)])\nontology = client.create_ontology(\"project-setup-demo-ontology\",\n ontology_builder.asdict())\n# Select existing ontology\n# ontology = client.get_ontology(\"\")\n# ontology = existing_project.ontology()",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### Create Project and Setup the Editor\n",
+ "* Setting up a project will add an ontology and will enable labeling to begin\n",
+ "* Creating batches will add all data_rows belonging to the dataset to the queue."
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "batch_project = client.create_project(\n name=\"Project Setup Demo\",\n quality_mode=QualityMode.\n Consensus, # For benchmarks use quality_mode = QualityMode.Benchmark\n media_type=lb.MediaType.Image,\n)\n\nbatch_project.setup_editor(ontology)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# Add data to your projects "
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "## When creating a batch you can also setup the data rows priority\nbatch = batch_project.create_batch(\n \"batch-demo-4\", # Each batch in a project must have a unique name\n global_keys=global_keys, # A list of data rows or data row ids\n priority=5, # priority between 1(Highest) - 5(lowest)\n consensus_settings={\n \"number_of_labels\": 2,\n \"coverage_percentage\": 1\n },\n)\nprint(\"Batch: \", batch)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### Review"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "# Note setup_complete will be None if it fails.\nprint(batch_project.setup_complete)\nprint(batch_project.ontology())\nprint([ds.name for ds in batch_project.batches()])",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "print(f\"https://app.labelbox.com/projects/{batch_project.uid}\")",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# Cleanup"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "# batch_project.delete()\n# dataset_project.delete()\n# dataset.delete()",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ }
+ ]
}
\ No newline at end of file
diff --git a/examples/project_configuration/queue_management.ipynb b/examples/project_configuration/queue_management.ipynb
index 26a03b14c..fd5fad0dc 100644
--- a/examples/project_configuration/queue_management.ipynb
+++ b/examples/project_configuration/queue_management.ipynb
@@ -1,366 +1,208 @@
{
- "nbformat": 4,
- "nbformat_minor": 5,
- "metadata": {},
- "cells": [
- {
- "metadata": {},
- "source": [
- "\n",
- " \n",
- " | "
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "\n",
- "\n",
- " | \n",
- "\n",
- "\n",
- "\n",
- " | "
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# Queue Management"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "* The queue is used to task labelers with specific assets\n",
- "* We can do any of the following:\n",
- " * Set quality settings\n",
- " * Set the order of items in the queue\n",
- " * Set the percent of assets to review"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "%pip install -q \"labelbox[data]\"\n",
- "%pip install -q numpy"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "import labelbox as lb\n",
- "from labelbox.schema.quality_mode import QualityMode\n",
- "from uuid import uuid4\n",
- "import json"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# API Key and Client\n",
- "See the developer guide for [creating an API key](https://docs.labelbox.com/reference/create-api-key)."
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# Add your API key\n",
- "API_KEY = \"\"\n",
- "client = lb.Client(api_key=API_KEY)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "### Set up demo project"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "#### Create project"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# Create Labelbox project\n",
- "\n",
- "project = client.create_project(\n",
- " name=\"batch-test-project\",\n",
- " description=\"a description\",\n",
- " quality_mode=QualityMode.\n",
- " Benchmark, # For Consensus projects use quality_mode = QualityMode.Consensus\n",
- " media_type=lb.MediaType.Image,\n",
- ")\n",
- "\n",
- "dataset = client.create_dataset(name=\"queue_dataset\")"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "#### Create ontology and attach to project"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "classification_features = [\n",
- " lb.Classification(\n",
- " class_type=lb.Classification.Type.CHECKLIST,\n",
- " name=\"Quality Issues\",\n",
- " options=[\n",
- " lb.Option(value=\"blurry\", label=\"Blurry\"),\n",
- " lb.Option(value=\"distorted\", label=\"Distorted\"),\n",
- " ],\n",
- " )\n",
- "]\n",
- "\n",
- "ontology_builder = lb.OntologyBuilder(\n",
- " tools=[], classifications=classification_features\n",
- ")\n",
- "\n",
- "ontology = client.create_ontology(\n",
- " \"Ontology from new features\",\n",
- " ontology_builder.asdict(),\n",
- " media_type=lb.MediaType.Image,\n",
- ")\n",
- "\n",
- "project.setup_editor(ontology)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Add data to your dataset"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "## Example image\n",
- "uploads = []\n",
- "global_keys = []\n",
- "# Generate data rows\n",
- "for i in range(1, 5):\n",
- " global_key = str(uuid4())\n",
- " row = {\n",
- " \"row_data\":\n",
- " f\"https://storage.googleapis.com/labelbox-datasets/People_Clothing_Segmentation/jpeg_images/IMAGES/img_000{i}.jpeg\",\n",
- " \"global_key\":\n",
- " global_key,\n",
- " }\n",
- " global_keys.append(global_key)\n",
- " uploads.append(row)\n",
- "\n",
- "data_rows = dataset.create_data_rows(uploads)\n",
- "data_rows.wait_till_done()\n",
- "print(\"Errors\", data_rows.errors)\n",
- "print(\"Dataset status: \", data_rows.status)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Attach data to your project and set data row priority"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "######## Create batches\n",
- "\n",
- "# Create the batch\n",
- "\n",
- "batch = project.create_batch(\n",
- " \"batch-demo\", # Each batch in a project must have a unique name\n",
- " global_keys=global_keys[\n",
- " 0:2], # A list of data rows, data row ids or global keys\n",
- " priority=\n",
- " 5, # priority between 1(Highest) - 5(lowest) 5 is the max priority that can be set\n",
- ")\n",
- "\n",
- "batch2 = project.create_batch(\n",
- " \"batch-demo-2\", # Each batch in a project must have a unique name\n",
- " # Provide a slice of the data since you can't import assets with global keys that already exist in the project.\n",
- " global_keys=global_keys[\n",
- " 2:4], # A list of data rows, data row ids or global keys\n",
- " priority=\n",
- " 1, # priority between 1(Highest) - 5(lowest) 5 is the max priority that can be set\n",
- ")\n",
- "\n",
- "print(\"Batch: \", batch)\n",
- "print(\"Batch2: \", batch2)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "print(\n",
- " \"View the results here:\", f\"https://app.labelbox.com/projects/{project.uid}\"\n",
- ")\n",
- "# Click `start labeling` to see the images in order"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "## Queue Order\n",
- "- Add priority for each data row\n",
- "- Update priority for each data row"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "export_task = project.export()\n",
- "export_task.wait_till_done()"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Get data rows from project\n",
- "data_rows = []\n",
- "\n",
- "\n",
- "def json_stream_handler(output: lb.JsonConverterOutput):\n",
- " data_row = json.loads(output.json_str)\n",
- " data_rows.append(\n",
- " lb.GlobalKey(data_row[\"data_row\"][\"global_key\"])\n",
- " ) # Convert json data row into data row identifier object\n",
- "\n",
- "\n",
- "if export_task.has_errors():\n",
- " export_task.get_stream(\n",
- " converter=lb.JsonConverter(), stream_type=lb.StreamType.ERRORS\n",
- " ).start(stream_handler=lambda error: print(error))\n",
- "\n",
- "if export_task.has_result():\n",
- " export_json = export_task.get_stream(\n",
- " converter=lb.JsonConverter(), stream_type=lb.StreamType.RESULT\n",
- " ).start(stream_handler=json_stream_handler)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Get label parameter overrides (LPOs)\n",
- "project_lpos = project.labeling_parameter_overrides()\n",
- "\n",
- "for lpo in project_lpos:\n",
- " print(lpo)\n",
- " print(\"Data row:\", lpo.data_row().uid)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Add LPOs\n",
- "lpos = []\n",
- "priority = 1\n",
- "for data_row in data_rows:\n",
- " lpos.append((data_row, priority))\n",
- " priority += 1\n",
- "\n",
- "project.set_labeling_parameter_overrides(lpos)\n",
- "\n",
- "# Check results\n",
- "project_lpos = list(project.labeling_parameter_overrides())\n",
- "\n",
- "for lpo in project_lpos:\n",
- " print(lpo)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Update LPOs\n",
- "global_keys = []\n",
- "for data_row in data_rows:\n",
- " global_keys.append(data_row.key)\n",
- "\n",
- "project.update_data_row_labeling_priority(\n",
- " data_rows=lb.GlobalKeys(global_keys), priority=1\n",
- ")\n",
- "\n",
- "# Check results\n",
- "project_lpos = list(project.labeling_parameter_overrides())\n",
- "\n",
- "for lpo in project_lpos:\n",
- " print(lpo)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Cleanup"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# project.delete()\n",
- "# dataset.delete()"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- }
- ]
+ "nbformat": 4,
+ "nbformat_minor": 5,
+ "metadata": {},
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "db768cda",
+ "metadata": {},
+ "source": [
+ "",
+ " ",
+ " | "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "cb5611d0",
+ "metadata": {},
+ "source": [
+ "",
+ "",
+ " | ",
+ "\n",
+ "",
+ "",
+ " | "
+ ]
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# Queue Management"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": [
+ "* The queue is used to task labelers with specific assets\n",
+ "* We can do any of the following:\n",
+ " * Set quality settings\n",
+ " * Set the order of items in the queue\n",
+ " * Set the percent of assets to review"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "%pip install -q \"labelbox[data]\"\n%pip install -q numpy",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "import labelbox as lb\nfrom labelbox.schema.quality_mode import QualityMode\nfrom uuid import uuid4\nimport json",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# API Key and Client\n",
+ "See the developer guide for [creating an API key](https://docs.labelbox.com/reference/create-api-key)."
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "# Add your API key\nAPI_KEY = \"\"\nclient = lb.Client(api_key=API_KEY)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### Set up demo project"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": [
+ "#### Create project"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "# Create Labelbox project\n\nproject = client.create_project(\n name=\"batch-test-project\",\n description=\"a description\",\n quality_mode=QualityMode.\n Benchmark, # For Consensus projects use quality_mode = QualityMode.Consensus\n media_type=lb.MediaType.Image,\n)\n\ndataset = client.create_dataset(name=\"queue_dataset\")",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "#### Create ontology and attach to project"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "classification_features = [\n lb.Classification(\n class_type=lb.Classification.Type.CHECKLIST,\n name=\"Quality Issues\",\n options=[\n lb.Option(value=\"blurry\", label=\"Blurry\"),\n lb.Option(value=\"distorted\", label=\"Distorted\"),\n ],\n )\n]\n\nontology_builder = lb.OntologyBuilder(tools=[],\n classifications=classification_features)\n\nontology = client.create_ontology(\n \"Ontology from new features\",\n ontology_builder.asdict(),\n media_type=lb.MediaType.Image,\n)\n\nproject.setup_editor(ontology)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# Add data to your dataset"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "## Example image\nuploads = []\nglobal_keys = []\n# Generate data rows\nfor i in range(1, 5):\n global_key = str(uuid4())\n row = {\n \"row_data\":\n f\"https://storage.googleapis.com/labelbox-datasets/People_Clothing_Segmentation/jpeg_images/IMAGES/img_000{i}.jpeg\",\n \"global_key\":\n global_key,\n }\n global_keys.append(global_key)\n uploads.append(row)\n\ndata_rows = dataset.create_data_rows(uploads)\ndata_rows.wait_till_done()\nprint(\"Errors\", data_rows.errors)\nprint(\"Dataset status: \", data_rows.status)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# Attach data to your project and set data row priority"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "######## Create batches\n\n# Create the batch\n\nbatch = project.create_batch(\n \"batch-demo\", # Each batch in a project must have a unique name\n global_keys=global_keys[\n 0:2], # A list of data rows, data row ids or global keys\n priority=\n 5, # priority between 1(Highest) - 5(lowest) 5 is the max priority that can be set\n)\n\nbatch2 = project.create_batch(\n \"batch-demo-2\", # Each batch in a project must have a unique name\n # Provide a slice of the data since you can't import assets with global keys that already exist in the project.\n global_keys=global_keys[\n 2:4], # A list of data rows, data row ids or global keys\n priority=\n 1, # priority between 1(Highest) - 5(lowest) 5 is the max priority that can be set\n)\n\nprint(\"Batch: \", batch)\nprint(\"Batch2: \", batch2)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "print(\"View the results here:\",\n f\"https://app.labelbox.com/projects/{project.uid}\")\n# Click `start labeling` to see the images in order",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "## Queue Order\n",
+ "- Add priority for each data row\n",
+ "- Update priority for each data row"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "export_task = project.export()\nexport_task.wait_till_done()",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "# Get data rows from project\ndata_rows = []\n\n\ndef json_stream_handler(output: lb.JsonConverterOutput):\n data_row = json.loads(output.json_str)\n data_rows.append(lb.GlobalKey(data_row[\"data_row\"][\"global_key\"])\n ) # Convert json data row into data row identifier object\n\n\nif export_task.has_errors():\n export_task.get_stream(converter=lb.JsonConverter(),\n stream_type=lb.StreamType.ERRORS).start(\n stream_handler=lambda error: print(error))\n\nif export_task.has_result():\n export_json = export_task.get_stream(\n converter=lb.JsonConverter(), stream_type=lb.StreamType.RESULT).start(\n stream_handler=json_stream_handler)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "# Get label parameter overrides (LPOs)\nproject_lpos = project.labeling_parameter_overrides()\n\nfor lpo in project_lpos:\n print(lpo)\n print(\"Data row:\", lpo.data_row().uid)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "# Add LPOs\nlpos = []\npriority = 1\nfor data_row in data_rows:\n lpos.append((data_row, priority))\n priority += 1\n\nproject.set_labeling_parameter_overrides(lpos)\n\n# Check results\nproject_lpos = list(project.labeling_parameter_overrides())\n\nfor lpo in project_lpos:\n print(lpo)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "# Update LPOs\nglobal_keys = []\nfor data_row in data_rows:\n global_keys.append(data_row.key)\n\nproject.update_data_row_labeling_priority(data_rows=lb.GlobalKeys(global_keys),\n priority=1)\n\n# Check results\nproject_lpos = list(project.labeling_parameter_overrides())\n\nfor lpo in project_lpos:\n print(lpo)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# Cleanup"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "# project.delete()\n# dataset.delete()",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ }
+ ]
}
\ No newline at end of file
diff --git a/examples/project_configuration/webhooks.ipynb b/examples/project_configuration/webhooks.ipynb
index ec54de860..f69472e60 100644
--- a/examples/project_configuration/webhooks.ipynb
+++ b/examples/project_configuration/webhooks.ipynb
@@ -1,344 +1,212 @@
{
- "nbformat": 4,
- "nbformat_minor": 5,
- "metadata": {},
- "cells": [
- {
- "metadata": {},
- "source": [
- "\n",
- " \n",
- " | "
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "\n",
- "\n",
- " | \n",
- "\n",
- "\n",
- "\n",
- " | "
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# Webhook Configuration"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "Webhooks are supported for the following events:\n",
- "* label_created\n",
- "* label_updated\n",
- "* label_deleted"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "!pip install labelbox\n",
- "!pip install requests\n",
- "!pip install hmac\n",
- "!pip install hashlib\n",
- "!pip install flask\n",
- "!pip install Werkzeug"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "import labelbox as lb\n",
- "from flask import Flask, request\n",
- "import hmac\n",
- "import hashlib\n",
- "import threading\n",
- "from werkzeug.serving import run_simple\n",
- "import json\n",
- "import requests\n",
- "import os\n",
- "from getpass import getpass\n",
- "import socket"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "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",
- "\n",
- "COLAB = \"google.colab\" in str(get_ipython())\n",
- "if COLAB:\n",
- " !pip install colab-env -qU\n",
- " from colab_env import envvar_handler\n",
- "\n",
- " envvar_handler.envload()\n",
- "\n",
- "API_KEY = os.environ.get(\"LABELBOX_API_KEY\")\n",
- "if 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)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "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
- },
- {
- "metadata": {},
- "source": [
- "client = lb.Client(api_key=API_KEY, endpoint=ENDPOINT)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "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
- },
- {
- "metadata": {},
- "source": [
- "### Configure NGROK (Optional)\n",
- "* If you do not have a public ip address then follow along\n",
- "\n",
- "1. Create an account:\n",
- " https://dashboard.ngrok.com/get-started/setup\n",
- "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"
- },
- {
- "metadata": {},
- "source": [
- "if not COLAB:\n",
- " os.system(f\"ngrok http {WH_PORT} &\")"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "### Configure server to receive requests"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "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
- },
- {
- "metadata": {},
- "source": [
- "app = Flask(__name__)\n",
- "\n",
- "\n",
- "@app.route(\"/\")\n",
- "def hello_world():\n",
- " return \"Hello, World!\"\n",
- "\n",
- "\n",
- "@app.route(\"/webhook-endpoint\", methods=[\"POST\"])\n",
- "def print_webhook_info():\n",
- " payload = request.data\n",
- " computed_signature = hmac.new(secret, msg=payload,\n",
- " digestmod=hashlib.sha1).hexdigest()\n",
- " if request.headers[\"X-Hub-Signature\"] != \"sha1=\" + computed_signature:\n",
- " print(\n",
- " \"Error: computed_signature does not match signature provided in the headers\"\n",
- " )\n",
- " return \"Error\", 500, 200\n",
- "\n",
- " print(\"=========== New Webhook Delivery ============\")\n",
- " print(\"Delivery ID: %s\" % request.headers[\"X-Labelbox-Id\"])\n",
- " print(\"Event: %s\" % request.headers[\"X-Labelbox-Event\"])\n",
- " print(\"Payload: %s\" %\n",
- " json.dumps(json.loads(payload.decode(\"utf8\")), indent=4))\n",
- " return \"Success\"\n",
- "\n",
- "\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
- },
- {
- "metadata": {},
- "source": [
- "#### Test server"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "print(requests.get(\"http://localhost:3001\").text)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "### Create Webhook"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "- Set ip address if your ip is publicly accessible.\n",
- "- Otherwise use the following to get ngrok public_url"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "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\"]\n",
- "else:\n",
- " public_url = f\"http://{socket.gethostbyname(socket.getfqdn(socket.gethostname()))}\"\n",
- "print(public_url)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "# Set project to limit the scope to a single project\n",
- "project = client.get_project(PROJECT_ID)\n",
- "topics = {topic.value for topic in lb.Webhook.Topic}\n",
- "# For Global Webhooks (Global = per workspace) project = None\n",
- "webhook = lb.Webhook.create(client,\n",
- " topics=topics,\n",
- " url=public_url,\n",
- " secret=secret.decode(),\n",
- " project=project)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "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
- },
- {
- "metadata": {},
- "source": [
- "### Update Webhook"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "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, or update a label)\n",
- "print(f\"https://app.labelbox.com/projects/{PROJECT_ID}\")"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- },
- {
- "metadata": {},
- "source": [
- "### List and delete all webhooks"
- ],
- "cell_type": "markdown"
- },
- {
- "metadata": {},
- "source": [
- "# DELETE:\n",
- "webhook.update(status=lb.Webhook.Status.INACTIVE.value)\n",
- "\n",
- "# FETCH ALL WEBHOOKS:\n",
- "org = client.get_organization()\n",
- "webhooks = 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 = lb.Webhook.Status.INACTIVE.value)"
- ],
- "cell_type": "code",
- "outputs": [],
- "execution_count": null
- }
- ]
+ "nbformat": 4,
+ "nbformat_minor": 5,
+ "metadata": {},
+ "cells": [
+ {
+ "cell_type": "markdown",
+ "id": "db768cda",
+ "metadata": {},
+ "source": [
+ "",
+ " ",
+ " | "
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "id": "cb5611d0",
+ "metadata": {},
+ "source": [
+ "",
+ "",
+ " | ",
+ "\n",
+ "",
+ "",
+ " | "
+ ]
+ },
+ {
+ "metadata": {},
+ "source": [
+ "# Webhook Configuration"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": [
+ "Webhooks are supported for the following events:\n",
+ "* label_created\n",
+ "* label_updated\n",
+ "* label_deleted"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "%pip install labelbox\n%pip install requests\n%pip install hmac\n%pip install hashlib\n%pip install flask\n%pip install Werkzeug",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "import labelbox as lb\nfrom flask import Flask, request\nimport hmac\nimport hashlib\nimport threading\nfrom werkzeug.serving import run_simple\nimport json\nimport requests\nimport os\nfrom getpass import getpass\nimport socket",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "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)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "# Set this to a project that you want to use for the webhook\nPROJECT_ID = \"\"\n# Only update this if you have an on-prem deployment\nENDPOINT = \"https://api.labelbox.com/graphql\"",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "client = lb.Client(api_key=API_KEY, endpoint=ENDPOINT)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "# We are using port 3001 for this example.\n# Feel free to set to whatever port you want\nWH_PORT = 3001",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### Configure NGROK (Optional)\n",
+ "* If you do not have a public ip address then follow along\n",
+ "\n",
+ "1. Create an account:\n",
+ " https://dashboard.ngrok.com/get-started/setup\n",
+ "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"
+ },
+ {
+ "metadata": {},
+ "source": "if not COLAB:\n os.system(f\"ngrok http {WH_PORT} &\")",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### Configure server to receive requests"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "# This can be any secret that matches your webhook config (we will set later)\nsecret = b\"example_secret\"",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "app = Flask(__name__)\n\n\n@app.route(\"/\")\ndef hello_world():\n return \"Hello, World!\"\n\n\n@app.route(\"/webhook-endpoint\", methods=[\"POST\"])\ndef print_webhook_info():\n payload = request.data\n computed_signature = hmac.new(secret, msg=payload,\n digestmod=hashlib.sha1).hexdigest()\n if request.headers[\"X-Hub-Signature\"] != \"sha1=\" + computed_signature:\n print(\n \"Error: computed_signature does not match signature provided in the headers\"\n )\n return \"Error\", 500, 200\n\n print(\"=========== New Webhook Delivery ============\")\n print(\"Delivery ID: %s\" % request.headers[\"X-Labelbox-Id\"])\n print(\"Event: %s\" % request.headers[\"X-Labelbox-Event\"])\n print(\"Payload: %s\" %\n json.dumps(json.loads(payload.decode(\"utf8\")), indent=4))\n return \"Success\"\n\n\nthread = threading.Thread(target=lambda: run_simple(\"0.0.0.0\", WH_PORT, app))\nthread.start()",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "#### Test server"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "print(requests.get(\"http://localhost:3001\").text)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### Create Webhook"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": [
+ "- Set ip address if your ip is publicly accessible.\n",
+ "- Otherwise use the following to get ngrok public_url"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "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 = (\n f\"http://{socket.gethostbyname(socket.getfqdn(socket.gethostname()))}\")\nprint(public_url)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": "# Set project to limit the scope to a single project\nproject = client.get_project(PROJECT_ID)\ntopics = {topic.value for topic in lb.Webhook.Topic}\n# For Global Webhooks (Global = per workspace) project = None\nwebhook = lb.Webhook.create(\n client,\n topics=topics,\n url=public_url,\n secret=secret.decode(),\n project=project,\n)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "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}\")",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### Update Webhook"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "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, or update a label)\nprint(f\"https://app.labelbox.com/projects/{PROJECT_ID}\")",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ },
+ {
+ "metadata": {},
+ "source": [
+ "### List and delete all webhooks"
+ ],
+ "cell_type": "markdown"
+ },
+ {
+ "metadata": {},
+ "source": "# DELETE:\nwebhook.update(status=lb.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 = lb.Webhook.Status.INACTIVE.value)",
+ "cell_type": "code",
+ "outputs": [],
+ "execution_count": null
+ }
+ ]
}
\ No newline at end of file