LoadingLoading
Date2020-05-22 22:16
Read7min

How to chain annotation projects with webhooks on Kili

In this tutorial, we will show how to use webhooks with Kili, to monitor actions (such as label creation).

How to chain annotation projects with webhooks on Kili

In this tutorial, we will show how to use webhooks with Kili, to monitor actions (such as label creation). The goal of this tutorial is to illustrate some basic components and concepts of Kili in a simple way, but also to dive into the actual process of iteratively developing real applications in Kili.

Additionally:

For an overview of Kili, visit kili-technology.com You can also check out the Kili documentation: https://docs.kili-technology.com/. Our goal is to export labels that can be used to train a model that will predict whether an image contains a Porsche or a Tesla.

The tutorial is divided into two parts:

  1. Why use webhooks?

  2. Using Kili's webhook in Python

Why use webhooks?

You can configure webhooks to react to particular actions in Kili's database by triggering a callback whenever an action is completed. For instance, every time a label is created in frontend, the label can be logged in Python:

Using Kili's webhook in Python

Kili Playground exposes the label_created_or_updated method that you can use to listen for all actions on labels:

  • creation of a new label

  • update of an existing label

First of all, you need to authenticate:

!pip install kili

from kili.client import Kili

export KILI_API_KEY="<YOUR API KEY>"
export KILI_API_ENDPOINT="https://cloud.kili-technology.com/api/label/v2/graphql"

kili = Kili()

Then you can define a callback that will be triggered each time a label gets created/updated:

project_id = '<YOUR_PROJECT_ID>'


def callback(id, data):

    print(f'New data: {data}\n')

kili.label_created_or_updated(project_id=project_id, callback=callback)

Summary

In this tutorial, we've accomplished the following:

We've introduced the concept of a webhook and we used label_created_or_updated to trigger a webhook.

You can also visit the Kili website or Kili documentation for more info!

Get started

Get Started

Get started! Build better data, now.