Open pure-almaz opened 2 years ago
Import kili
pip install kili
Authenticate the operating system using user API and endpoints.
If you use the saas platform, your API endpoint will be https://cloud.kili-technology.com/api/label/v2/graphql
Note: Change API version to latest kili version, at the time of writing, its version is 2.103.0
import os
from kili.client import kili
kili = Kili(api_key='YOUR_API_KEY', api_endpoint='THE_API_ENDPOINT')
Create your project
project=kili.create_project(title='Text Classification', description='Classifying texts according to underlying sentiments', input_type='TEXTS', json_interface={"jobRendererWidth": 0.3, "jobs": { "CLASSIFICATION_JOB": { "mlTask": "CLASSIFICATION", "content":{ "categories": { "POSITIVE": { "name": "Positive" }, "NEGATIVE": { "name": "Negative" }, "NEUTRAL": { "name": "Neutral" } }, "input": "checkbox" }, "required": 1,
"isChild": False, "instruction": "Label at your discreetion"} } })
print(a'Created project {project["id"]}')
Add collaborators
emails = ['email_a@domain.com', 'email_b@domain.com'] for email in emails: kili.append_to_roles( project_id=project['id'], user_email=emails, role='ADMIN')
Add assets
assets = ["file_url_or_path", "file_url_or_path", "file_url_or_path"," file_url_or_path","file_url_or_path"]
id_assets = kili.append_many_to_dataset( project_id=project['id'], content_array=assets, external_id_array=['Reviews' + str(a) for a in range(len(assets))])
This issue shows you how you can create a new project on kili using python and graphql
Visit kili documentation to learn more: https://cloud.kili-technology.com/docs/python-graphql-api/recipes/create_project/