Kili Docs

Kili Docs

›Recipes

Introduction to Kili Technology

  • Introduction to Kili Technology
  • Kili Technology allows
  • Compatible browser

Getting Started

  • Getting started with Kili - Classification

Hosting

  • SaaS
  • On-Premise Data
  • On-Premise Entreprise

Concepts

  • Definitions
  • Status Lifecycle
  • Architecture

Users and roles

  • Roles by project
  • Users
  • Users and roles management

Projects

  • Audit labelers
  • Customize interface
  • Dataset
  • New project
  • Project overview
  • Projects
  • Projects list
  • Settings
  • Shortcuts

Image interfaces

  • Bounding Box
  • Classification
  • Point
  • Polygon
  • Polyline
  • Segmentation
  • Simple and intuitive interfaces

Text & PDF interfaces

  • Classification
  • Image transcription / OCR
  • Named entities recognition
  • Relations extraction

Video interfaces

  • Classification
  • Multi-frames classification
  • Multi-frames object detection
  • Transcription

Audio interfaces

  • Voice transcription / Speech to text

Data ingestion

  • Data ingestion made easy
  • Load data from a workstation
  • Load data from a public cloud
  • Data on premise or on private cloud
  • How to generate non-expiring signed URLs on AWS

Quality management

  • Consensus
  • Honeypot or Gold Standard
  • Instructions
  • Quality KPIs
  • Quality management
  • Questions and Issues
  • Review Process
  • Workload distribution

Automation

  • Human in the loop
  • Model based preannotation
  • Online learning
  • Queue prioritisation

Data export

  • Data export
  • Data format
  • Example

Python - GraphQL API

  • GraphQL API
  • Python API

Code snippets

  • Authentication
  • Create a Honeypot
  • Create a user
  • Creating Consensus
  • Delete the data
  • Export data
  • Export labels
  • Import data
  • Import labels
  • Prioritize assets
  • See the Consensus of an annotation
  • See the Honeypot of an annotation
  • Throttling

Recipes

  • AutoML for faster labeling with Kili Technology
  • Create a project
  • Exporting a training set
  • Importing medical data into a frame project
  • Importing assets
  • Import rich-text assets
  • Importing predictions
  • Reading and uploading dicom image data
  • How to query using the API
  • Labelled Image Data & Transfer Learning
  • Webhooks

Change log

  • Change log

How to query using the API

Kili Tutorial: How to query using the API

In this tutorial, we will show query useful information through Kili's API, interacting directly with the database.

There are 6 different types of data you could be interested in querying, and it is higly customizable :

  1. Your organization's info
  2. The organization's users
  3. KPI's and labeling data for different projectUsers
  4. The whole project or selected parts
  5. The assets themselves
  6. Obviously, the labels

All those queries request, among other arguments, a skip and first argument, that control the number of results retrieved. skipis the rank at which the result start, and first is the extent of the query.

Additionally, for an overview of Kili, visit the website, you can also check out the Kili documentation, or some other recipes.

For more information, the architecture of our API is available here, all fields are precisely detailled and can be queried, except those related to authentication. Let's sign in, create a project, upload some assets and import predictions, if you need precisions on the steps carried-out below, you can refer to the mentionned recipes.

We now have a project ready, which information is in a project_example dictionnary, and which data we are going to query.

#!pip install kili 
from kili.client import Kili
import os

api_key = os.getenv('KILI_USER_API_KEY')
api_endpoint = os.getenv('KILI_API_ENDPOINT')
kili = Kili(api_key=api_key, api_endpoint=api_endpoint)

project_example = {
    'title': 'Porsche or Tesla recognition',
    'description': 'Identify and locate cars',
    'input_type': 'IMAGE',
    'json_interface': {
        "jobs": {
            "JOB_0": {
                "mlTask": "OBJECT_DETECTION",
                "tools": [
                    "rectangle"
                ],
                "instruction": "What car brand ?",
                "required": 1,
                "isChild": False,
                "content": {
                    "categories": {
                        "TESLA": {"name": "Tesla"},
                        "FERRARI": {"name": "Ferrari"}
                    },
                    "input": "radio"
                }
            }
        }
    },

    'assets_to_import': [
        "https://images.caradisiac.com/logos/3/8/6/7/253867/S0-tesla-enregistre-d-importantes-pertes-au-premier-trimestre-175948.jpg",
        "https://img.sportauto.fr/news/2018/11/28/1533574/1920%7C1280%7Cc096243e5460db3e5e70c773.jpg"],

    'json_response': {
        "JOB_0": {
            "annotations": [{
                "boundingPoly": [{
                    "normalizedVertices": [
                        {"x": 0.16, "y": 0.82},
                        {"x": 0.16, "y": 0.32},
                        {"x": 0.82, "y": 0.32},
                        {"x": 0.82, "y": 0.82}
                    ]}
                ],
                "categories": [{"name": "TESLA", "confidence": 100}],
            }]
        }
    },
    'model_name': 'car-brand-localisation-v0.0.1'
}
project = kili.create_project(
    title=project_example['title'],
    description=project_example['description'],
    input_type=project_example['input_type'],
    json_interface=project_example['json_interface']
)
kili.append_many_to_dataset(
    project_id=project['id'],
    content_array=project_example['assets_to_import'],
    external_id_array=['ex1', 'ex2'])
kili.create_predictions(
    project_id=project['id'],
    external_id_array=['ex1'],
    model_name_array=[project_example['model_name']],
    json_response_array=[project_example['json_response']])

1. Organization info

We can query the information for the organization for specific users, and check that those parameters are correctly configured, either by providing

  • the id of the organization
  • a specific email

Another argument is the fields that need to be returned, that can be customized using our graphQL doc here

email = os.getenv('KILI_USER_EMAIL')
fields = ['id', 'name','address','country','zipCode','city']
kili.organizations(email=email, fields=fields, first=3, skip= 0)

2. User info

We can query the information for an user, and check that those parameters are correctly configured, either by providing

  • the email of the user
  • the organization_id of the users

Another argument is the fields that need to be returned, that can be customized using our graphQL doc here. Notice that the nested requests are possible, to retrieve the information at the organization's level.

fields =['id','activated','createdAt','email','name', 'organization.name', 'organization.city','organizationRole','updatedAt']
kili.users(email=email, fields=fields, skip=0, first=10)

3. ProjectUser info

We can query the information for a projectUser, and check that those parameters are correctly configured, either by providing

  • the email of the projectUser
  • the id of the organization
  • the id of the project
  • the id of the projectUser

Another argument is the fields that need to be returned, that can be customized using our graphQL doc here. Notice that the nested requests are possible, to retrieve the information at the user's level, and hence at the organization's level, always with the same syntax :

fields=['id','activated','consensusMark',"honeypotMark","numberOfAnnotations","numberOfLabels",'role',
        'user.email', 'user.name', 'user.organization.name', 'user.organization.zipCode']
kili.project_users(project_id=project['id'], fields=fields, first=10, skip=0)

4. Project info

We can query the information for a project, and check that those parameters are correctly configured, either by providing

  • the email of the projectUser
  • a part of the title of the description search_query

Another argument is the fields that need to be returned, that can be customized using our graphQL doc here. Notice that the nested requests are possible, to retrieve the information at the projectUser's level, via the role subfield, and hence, once again, at the user or the organization's level. It is also possible to query the information on the author of the project, always with the same syntax :

fields = ['id','author.name','author.email', 'author.organization.name','consensusMark', 'createdAt',
          'description','honeypotMark', 'id', 'inputType', 'interfaceCategory', 'jsonInterface', 
          'maxWorkerCount', 'minConsensusSize', 'numberOfAssets', 'numberOfRemainingAssets', 
          'roles.id','roles.consensusMark', 'roles.numberOfAnnotations', 'roles.numberOfLabeledAssets', 
          'roles.numberOfLabels', 'roles.totalDuration', 'roles.user.email', 'roles.user.id', 'roles.user.name', 
          'title','titleAndDescription','useHoneyPot']
title = kili.projects(project_id=project['id'], fields=fields, first=10, skip=0)[0]['title']
kili.projects(project_id=project['id'], fields=fields, first=10, skip=0)

5. Labels info

We can query the information of labels, in order to use it later in our pipeline, either by providing

  • the idof the label or the asset to query
  • the id of the project
  • a part of the title or the description search_query
  • many other parameters to filter the list, the details can be found here, among which a part of the externalId of the asset, the status of the asset, the honeypot mark,etc...

Another argument is the fields that need to be returned, that can be customized using our graphQL doc here. Notice that the nested requests are possible, to retrieve the information at the projectUser's level, via the role subfield, and hence, once again, at the user or the organization's level. It is also possible to query the information on the author of the project, always with the same syntax :

fields = ['id','honeypotMark','numberOfAnnotations','jsonResponse','labelType','skipped','createdAt',
        'author.email', 'author.name', 'author.organization.name', 'author.organization.zipCode']
kili.labels(project_id=project['id'], fields=fields, first=10, skip=0)

6. Assets info

We can query the information of assets, along with the labels or more info, either by providing

  • the idof the asset to query
  • the id of the project
  • a part of the title or the description search_query
  • many other parameters to filter the list, the details can be found here, among which a part of the externalId, the status, the consensus level,etc...

Another argument is the fields that need to be returned, that can be customized using our graphQL doc here. Notice that the nested requests are possible, to retrieve the information at the projectUser's level, via the role subfield, and hence, once again, at the user or the organization's level. It is also possible to query the information on the author of the project, always with the same syntax :

fields=['id', 'honeypotMark', 'project.jsonInterface','content', 'createdAt', 'priority',
        'project.author.email', 'project.author.name', 'labels.jsonResponse', 'status',
        'labels.author.email', 'labels.author.organization.name', 'project.inputType']
kili.assets(project_id=project['id'], fields=fields, first=10, skip=0)
assert project_example['title'] == title
← Reading and uploading dicom image dataLabelled Image Data & Transfer Learning →
  • 1. Organization info
  • 2. User info
  • 3. ProjectUser info
  • 4. Project info
  • 5. Labels info
  • 6. Assets info