Project module
Queries
Set of Project queries.
Source code in kili/queries/project/__init__.py
class QueriesProject:
"""Set of Project queries."""
# pylint: disable=too-many-arguments,too-many-locals
def __init__(self, auth):
"""Initialize the subclass.
Args:
auth: KiliAuth object
"""
self.auth = auth
# pylint: disable=dangerous-default-value
@Compatible(['v1', 'v2'])
@typechecked
def projects(self,
project_id: Optional[str] = None,
search_query: Optional[str] = None,
should_relaunch_kpi_computation: Optional[bool] = None,
updated_at_gte: Optional[str] = None,
updated_at_lte: Optional[str] = None,
skip: int = 0,
fields: List[str] = [
'consensusTotCoverage',
'id',
'inputType',
'jsonInterface',
'minConsensusSize',
'reviewCoverage',
'roles.id',
'roles.role',
'roles.user.email',
'roles.user.id',
'title'],
first: int = 100,
disable_tqdm: bool = False,
as_generator: bool = False) -> Union[List[dict], Generator[dict, None, None]]:
# pylint: disable=line-too-long
"""Get a generator or a list of projects that match a set of criteria.
Args:
project_id: Select a specific project through its project_id.
search_query: Returned projects with a title or a description matching this string.
should_relaunch_kpi_computation : Technical field, added to indicate changes in honeypot or consensus settings.
updated_at_gte: Returned projects should have a label whose update date is greater or equal
to this date.
updated_at_lte: Returned projects should have a label whose update date is lower or equal to this date.
skip: Number of projects to skip (they are ordered by their creation).
fields: All the fields to request among the possible fields for the projects.
See [the documentation](https://docs.kili-technology.com/reference/graphql-api#project) for all possible fields.
first: Maximum number of projects to return.
disable_tqdm: If `True`, the progress bar will be disabled
as_generator: If `True`, a generator on the projects is returned.
!!! info "Dates format"
Date strings should have format: "YYYY-MM-DD"
Returns:
A result object which contains the query if it was successful,
or an error message.
Examples:
>>> # List all my projects
>>> kili.projects()
"""
saved_args = locals()
count_args = {
k: v
for (k, v) in saved_args.items() if k in [
'project_id',
'search_query',
'should_relaunch_kpi_computation',
'updated_at_gte',
'updated_at_lte'
]
}
disable_tqdm = disable_tqdm or as_generator
payload_query = {
'where': {
'id': project_id,
'searchQuery': search_query,
'shouldRelaunchKpiComputation': should_relaunch_kpi_computation,
'updatedAtGte': updated_at_gte,
'updatedAtLte': updated_at_lte,
},
}
projects_generator = row_generator_from_paginated_calls(
skip,
first,
self.count_projects,
count_args,
self._query_projects,
payload_query,
fields,
disable_tqdm
)
if as_generator:
return projects_generator
return list(projects_generator)
def _query_projects(self,
skip: int,
first: int,
payload: dict,
fields: List[str]):
payload.update({'skip': skip, 'first': first})
_gql_projects = gql_projects(fragment_builder(fields, Project))
result = self.auth.client.execute(_gql_projects, payload)
return format_result('data', result)
@Compatible(['v1', 'v2'])
@typechecked
def count_projects(
self,
project_id: Optional[str] = None,
search_query: Optional[str] = None,
should_relaunch_kpi_computation: Optional[bool] = None,
updated_at_gte: Optional[str] = None,
updated_at_lte: Optional[str] = None) -> int:
"""
Counts the number of projects with a search_query
Args:
project_id: Select a specific project through its project_id.
search_query: Returned projects have a title or a description that matches this string.
should_relaunch_kpi_computation : Technical field, added to indicate changes in honeypot
or consensus settings
updated_at_gte: Returned projects should have a label
whose update date is greater
or equal to this date.
updated_at_lte: Returned projects should have a label
whose update date is lower or equal to this date.
!!! info "Dates format"
Date strings should have format: "YYYY-MM-DD"
Returns:
The number of projects with the parameters provided
"""
variables = {
'where': {
'id': project_id,
'searchQuery': search_query,
'shouldRelaunchKpiComputation': should_relaunch_kpi_computation,
'updatedAtGte': updated_at_gte,
'updatedAtLte': updated_at_lte,
}
}
result = self.auth.client.execute(GQL_PROJECTS_COUNT, variables)
count = format_result('data', result)
return count
count_projects(self, project_id=None, search_query=None, should_relaunch_kpi_computation=None, updated_at_gte=None, updated_at_lte=None)
Counts the number of projects with a search_query
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id |
Optional[str] |
Select a specific project through its project_id. |
None |
search_query |
Optional[str] |
Returned projects have a title or a description that matches this string. |
None |
should_relaunch_kpi_computation |
Technical field, added to indicate changes in honeypot or consensus settings |
None |
|
updated_at_gte |
Optional[str] |
Returned projects should have a label whose update date is greater or equal to this date. |
None |
updated_at_lte |
Optional[str] |
Returned projects should have a label whose update date is lower or equal to this date. |
None |
Dates format
Date strings should have format: "YYYY-MM-DD"
Returns:
Type | Description |
---|---|
int |
The number of projects with the parameters provided |
Source code in kili/queries/project/__init__.py
@Compatible(['v1', 'v2'])
@typechecked
def count_projects(
self,
project_id: Optional[str] = None,
search_query: Optional[str] = None,
should_relaunch_kpi_computation: Optional[bool] = None,
updated_at_gte: Optional[str] = None,
updated_at_lte: Optional[str] = None) -> int:
"""
Counts the number of projects with a search_query
Args:
project_id: Select a specific project through its project_id.
search_query: Returned projects have a title or a description that matches this string.
should_relaunch_kpi_computation : Technical field, added to indicate changes in honeypot
or consensus settings
updated_at_gte: Returned projects should have a label
whose update date is greater
or equal to this date.
updated_at_lte: Returned projects should have a label
whose update date is lower or equal to this date.
!!! info "Dates format"
Date strings should have format: "YYYY-MM-DD"
Returns:
The number of projects with the parameters provided
"""
variables = {
'where': {
'id': project_id,
'searchQuery': search_query,
'shouldRelaunchKpiComputation': should_relaunch_kpi_computation,
'updatedAtGte': updated_at_gte,
'updatedAtLte': updated_at_lte,
}
}
result = self.auth.client.execute(GQL_PROJECTS_COUNT, variables)
count = format_result('data', result)
return count
projects(self, project_id=None, search_query=None, should_relaunch_kpi_computation=None, updated_at_gte=None, updated_at_lte=None, skip=0, fields=['consensusTotCoverage', 'id', 'inputType', 'jsonInterface', 'minConsensusSize', 'reviewCoverage', 'roles.id', 'roles.role', 'roles.user.email', 'roles.user.id', 'title'], first=100, disable_tqdm=False, as_generator=False)
Get a generator or a list of projects that match a set of criteria.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id |
Optional[str] |
Select a specific project through its project_id. |
None |
search_query |
Optional[str] |
Returned projects with a title or a description matching this string. |
None |
should_relaunch_kpi_computation |
Technical field, added to indicate changes in honeypot or consensus settings. |
None |
|
updated_at_gte |
Optional[str] |
Returned projects should have a label whose update date is greater or equal to this date. |
None |
updated_at_lte |
Optional[str] |
Returned projects should have a label whose update date is lower or equal to this date. |
None |
skip |
int |
Number of projects to skip (they are ordered by their creation). |
0 |
fields |
List[str] |
All the fields to request among the possible fields for the projects. See the documentation for all possible fields. |
['consensusTotCoverage', 'id', 'inputType', 'jsonInterface', 'minConsensusSize', 'reviewCoverage', 'roles.id', 'roles.role', 'roles.user.email', 'roles.user.id', 'title'] |
first |
int |
Maximum number of projects to return. |
100 |
disable_tqdm |
bool |
If |
False |
as_generator |
bool |
If |
False |
Dates format
Date strings should have format: "YYYY-MM-DD"
Returns:
Type | Description |
---|---|
Union[List[dict], Generator[dict, NoneType]] |
A result object which contains the query if it was successful, or an error message. |
Examples:
>>> # List all my projects
>>> kili.projects()
Source code in kili/queries/project/__init__.py
@Compatible(['v1', 'v2'])
@typechecked
def projects(self,
project_id: Optional[str] = None,
search_query: Optional[str] = None,
should_relaunch_kpi_computation: Optional[bool] = None,
updated_at_gte: Optional[str] = None,
updated_at_lte: Optional[str] = None,
skip: int = 0,
fields: List[str] = [
'consensusTotCoverage',
'id',
'inputType',
'jsonInterface',
'minConsensusSize',
'reviewCoverage',
'roles.id',
'roles.role',
'roles.user.email',
'roles.user.id',
'title'],
first: int = 100,
disable_tqdm: bool = False,
as_generator: bool = False) -> Union[List[dict], Generator[dict, None, None]]:
# pylint: disable=line-too-long
"""Get a generator or a list of projects that match a set of criteria.
Args:
project_id: Select a specific project through its project_id.
search_query: Returned projects with a title or a description matching this string.
should_relaunch_kpi_computation : Technical field, added to indicate changes in honeypot or consensus settings.
updated_at_gte: Returned projects should have a label whose update date is greater or equal
to this date.
updated_at_lte: Returned projects should have a label whose update date is lower or equal to this date.
skip: Number of projects to skip (they are ordered by their creation).
fields: All the fields to request among the possible fields for the projects.
See [the documentation](https://docs.kili-technology.com/reference/graphql-api#project) for all possible fields.
first: Maximum number of projects to return.
disable_tqdm: If `True`, the progress bar will be disabled
as_generator: If `True`, a generator on the projects is returned.
!!! info "Dates format"
Date strings should have format: "YYYY-MM-DD"
Returns:
A result object which contains the query if it was successful,
or an error message.
Examples:
>>> # List all my projects
>>> kili.projects()
"""
saved_args = locals()
count_args = {
k: v
for (k, v) in saved_args.items() if k in [
'project_id',
'search_query',
'should_relaunch_kpi_computation',
'updated_at_gte',
'updated_at_lte'
]
}
disable_tqdm = disable_tqdm or as_generator
payload_query = {
'where': {
'id': project_id,
'searchQuery': search_query,
'shouldRelaunchKpiComputation': should_relaunch_kpi_computation,
'updatedAtGte': updated_at_gte,
'updatedAtLte': updated_at_lte,
},
}
projects_generator = row_generator_from_paginated_calls(
skip,
first,
self.count_projects,
count_args,
self._query_projects,
payload_query,
fields,
disable_tqdm
)
if as_generator:
return projects_generator
return list(projects_generator)
Mutations
Set of Project mutations.
Source code in kili/mutations/project/__init__.py
class MutationsProject:
""" Set of Project mutations."""
# pylint: disable=too-many-arguments,too-many-locals
def __init__(self, auth):
"""Initialize the subclass.
Args:
auth: KiliAuth object
"""
self.auth = auth
@Compatible(['v1', 'v2'])
@typechecked
def append_to_roles(self, project_id: str, user_email: str, role: str = 'LABELER'):
"""Add a user to a project.
!!! info
If the user does not exist in your organization, he/she is invited and added
both to your organization and project. This function can also be used to change
the role of the user in the project.
Args:
project_id: Identifier of the project
user_email: The email of the user.
This email is used as the unique identifier of the user.
role: One of {"ADMIN", "TEAM_MANAGER", "REVIEWER", "LABELER"}.
Returns:
A result object which indicates if the mutation was successful,
or an error message.
Examples:
>>> kili.append_to_roles(project_id=project_id, user_email='john@doe.com')
"""
variables = {
'data': {'role': role,
'userEmail': user_email},
'where': {'id': project_id}
}
result = self.auth.client.execute(GQL_APPEND_TO_ROLES, variables)
return format_result('data', result)
@Compatible(['v1', 'v2'])
@typechecked
def update_properties_in_project(self, project_id: str,
consensus_mark: Optional[float] = None,
consensus_tot_coverage: Optional[int] = None,
description: Optional[str] = None,
honeypot_mark: Optional[float] = None,
instructions: Optional[str] = None,
input_type: Optional[str] = None,
json_interface: Optional[dict] = None,
min_consensus_size: Optional[int] = None,
number_of_assets: Optional[int] = None,
number_of_assets_with_empty_labels: Optional[int] = None,
number_of_remaining_assets: Optional[int] = None,
number_of_reviewed_assets: Optional[int] = None,
review_coverage: Optional[int] = None,
should_relaunch_kpi_computation: Optional[bool] = None,
title: Optional[str] = None,
use_honeypot: Optional[bool] = None):
"""Update properties of a project.
Args:
project_id: Identifier of the project.
consensus_mark: Should be between 0 and 1.
consensus_tot_coverage: Should be between 0 and 100.
It is the percentage of the dataset that will be annotated several times.
description : Description of the project.
honeypot_mark : Should be between 0 and 1
instructions : Instructions of the project.
interface_category: Always use 'IV2'.
input_type: Currently, one of `AUDIO`, `FRAME`, `IMAGE`, `PDF`, `TEXT`, `VIDEO`, `NA`.
json_interface: The json parameters of the project, see Edit your interface.
min_consensus_size: Should be between 1 and 10
Number of people that will annotate the same asset, for consensus computation.
number_of_assets: Defaults to 0
number_of_assets_with_empty_labels: Defaults to 0
number_of_remaining_assets: Defaults to 0
number_of_reviewed_assets: Defaults to 0
review_coverage: Allow to set the percentage of assets
that will be queued in the review interface.
Should be between 0 and 100
should_relaunch_kpi_computation: Technical field, added to indicate changes
in honeypot or consensus settings
title: Title of the project
use_honeypot: Activate / Deactivate the use of honeypot in the project
Returns:
A result object which indicates if the mutation was successful,
or an error message.
Examples:
>>> kili.update_properties_in_project(project_id=project_id, title='New title')
"""
verify_argument_ranges(consensus_tot_coverage,
min_consensus_size,
review_coverage)
variables = {
'consensusMark': consensus_mark,
'consensusTotCoverage': consensus_tot_coverage,
'description': description,
'honeypotMark': honeypot_mark,
'instructions': instructions,
'inputType': input_type,
'jsonInterface': dumps(json_interface) if json_interface is not None else None,
'minConsensusSize': min_consensus_size,
'numberOfAssets': number_of_assets,
'numberOfAssetsWithSkippedLabels': number_of_assets_with_empty_labels,
'numberOfRemainingAssets': number_of_remaining_assets,
'numberOfReviewedAssets': number_of_reviewed_assets,
'projectID': project_id,
'reviewCoverage': review_coverage,
'shouldRelaunchKpiComputation': should_relaunch_kpi_computation,
'title': title,
'useHoneyPot': use_honeypot
}
result = self.auth.client.execute(
GQL_UPDATE_PROPERTIES_IN_PROJECT, variables)
return format_result('data', result)
@Compatible(endpoints=['v2'])
@typechecked
def create_project(self, input_type: str, json_interface: dict,
title: str, description: str = '',
project_type: Optional[str] = None):
# pylint: disable=line-too-long
"""Create a project.
Args:
input_type : Currently, one of {AUDIO, IMAGE, PDF, TEXT, URL, VIDEO, NA}
json_interface: The json parameters of the project, see Edit your interface.
title : Title of the project
description : Description of the project
project_type:
Currently, one of {
`IMAGE_CLASSIFICATION_SINGLE`,
`IMAGE_CLASSIFICATION_MULTI`,
`IMAGE_OBJECT_DETECTION_RECTANGLE`,
`IMAGE_OBJECT_DETECTION_POLYGON`,
`IMAGE_OBJECT_DETECTION_SEMANTIC`,
`OCR, PDF_CLASSIFICATION_SINGLE`,
`PDF_CLASSIFICATION_MULTI`,
`TEXT_CLASSIFICATION_SINGLE`,
`TEXT_CLASSIFICATION_MULTI`,
`TEXT_TRANSCRIPTION, TEXT_NER`,
`VIDEO_CLASSIFICATION_SINGLE`,
`VIDEO_FRAME_CLASSIFICATION`,
`VIDEO_FRAME_OBJECT_TRACKING`,
`SPEECH_TO_TEXT`
}
Returns:
A result object which indicates if the mutation was successful,
or an error message.
Examples:
>>> kili.create_project(input_type='IMAGE', json_interface=json_interface, title='Example')
!!! example "Recipe"
For more detailed examples on how to create projects,
see [the recipe](https://github.com/kili-technology/kili-python-sdk/blob/master/recipes/create_project.ipynb).
"""
variables = {
'data': {'description': description,
'inputType': input_type,
'jsonInterface': dumps(json_interface),
'projectType': project_type,
'title': title}
}
result = self.auth.client.execute(GQL_CREATE_PROJECT, variables)
return format_result('data', result)
@Compatible(['v2'])
@typechecked
def make_project_public(self, project_id: str):
"""
Make a project public.
!!! warning
This action is permanent and irreversible.
Args:
project_id: Identifier of the project
Returns:
The public token to provide in the public URL
"""
variables = {'where': {'id': project_id}}
result = self.auth.client.execute(GQL_MAKE_PROJECT_PUBLIC, variables)
return format_result('data', result)
@Compatible(['v1', 'v2'])
@typechecked
def update_properties_in_role(self, role_id: str,
project_id: str, user_id: str, role: str):
"""Update properties of a role.
!!! info
To be able to change someone's role, you must be either of:
- an admin of the project
- a team manager of the project
- an admin of the organization
Args:
role_id: Role identifier of the user. E.g. : 'to-be-deactivated'
project_id: Identifier of the project
user_id: The email or identifier of the user with updated role
role: The new role.
Possible choices are: `ADMIN`, `TEAM_MANAGER`, `REVIEWER`, `LABELER`
Returns:
A result object which indicates if the mutation was successful,
or an error message.
"""
variables = {
'roleID': role_id,
'projectID': project_id,
'userID': user_id,
'role': role
}
result = self.auth.client.execute(
GQL_UPDATE_PROPERTIES_IN_ROLE, variables)
return format_result('data', result)
@Compatible(['v1', 'v2'])
@typechecked
def delete_from_roles(self, role_id: str):
"""Delete users by their role_id.
Args:
role_id : Identifier of the project user (not the ID of the user)
Returns:
A result object which indicates if the mutation was successful,
or an error message.
"""
variables = {'where': {'id': role_id}}
result = self.auth.client.execute(GQL_DELETE_FROM_ROLES, variables)
return format_result('data', result)
@Compatible(['v2'])
@typechecked
def update_properties_in_project_user(self, project_user_id: str,
consensus_mark: Optional[float] = None,
honeypot_mark: Optional[float] = None,
number_of_labeled_assets: Optional[int] = None,
starred: Optional[bool] = None,
total_duration: Optional[int] = None):
"""
Update properties of a project-user tuple
Args:
project_user_id : Identifier of the project user
consensus_mark: Should be between 0 and 1.
honeypot_mark: Should be between 0 and 1.
number_of_labeled_assets: Number of assets the user labeled in the project.
starred: Whether to star the project in the project list.
total_duration: Total time the user spent in the project.
Returns:
A result object which indicates if the mutation was successful,
or an error message.
Examples:
>>> for project_user in project_users:
... kili.update_properties_in_project_user(
project_user_id=project_user['id'],
honeypot_mark=0)
"""
variables = {
'consensusMark': consensus_mark,
'honeypotMark': honeypot_mark,
'numberOfLabeledAssets': number_of_labeled_assets,
'projectUserID': project_user_id,
'starred': starred,
'totalDuration': total_duration,
}
result = self.auth.client.execute(
GQL_GQL_UPDATE_PROPERTIES_IN_PROJECT_USER, variables)
return format_result('data', result)
@Compatible(['v1', 'v2'])
@typechecked
def internal_delete_project(self, project_id: str):
"""Delete project permanently.
WARNING: This resolver is for internal use by Kili Technology only.
Args:
project_id: Identifier of the project
Returns:
A result object which indicates if the mutation was successful,
or an error message.
"""
variables = {'projectID': project_id}
result = self.auth.client.execute(GQL_DELETE_PROJECT, variables)
return format_result('data', result)
@Compatible(['v1', 'v2'])
@typechecked
def delete_project(self, project_id: str):
"""
Delete a project permanently.
Args:
project_id: Identifier of the project
Returns:
A result object which indicates if the mutation was successful,
or an error message.
"""
variables = {'where': {'id': project_id}}
result = self.auth.client.execute(
GQL_PROJECT_DELETE_ASYNCHRONOUSLY, variables)
return format_result('data', result)
__init__(self, auth)
special
Initialize the subclass.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
auth |
KiliAuth object |
required |
Source code in kili/mutations/project/__init__.py
def __init__(self, auth):
"""Initialize the subclass.
Args:
auth: KiliAuth object
"""
self.auth = auth
append_to_roles(self, project_id, user_email, role='LABELER')
Add a user to a project.
Info
If the user does not exist in your organization, he/she is invited and added both to your organization and project. This function can also be used to change the role of the user in the project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id |
str |
Identifier of the project |
required |
user_email |
str |
The email of the user. This email is used as the unique identifier of the user. |
required |
role |
str |
One of {"ADMIN", "TEAM_MANAGER", "REVIEWER", "LABELER"}. |
'LABELER' |
Returns:
Type | Description |
---|---|
A result object which indicates if the mutation was successful, or an error message. |
Examples:
>>> kili.append_to_roles(project_id=project_id, user_email='john@doe.com')
Source code in kili/mutations/project/__init__.py
@Compatible(['v1', 'v2'])
@typechecked
def append_to_roles(self, project_id: str, user_email: str, role: str = 'LABELER'):
"""Add a user to a project.
!!! info
If the user does not exist in your organization, he/she is invited and added
both to your organization and project. This function can also be used to change
the role of the user in the project.
Args:
project_id: Identifier of the project
user_email: The email of the user.
This email is used as the unique identifier of the user.
role: One of {"ADMIN", "TEAM_MANAGER", "REVIEWER", "LABELER"}.
Returns:
A result object which indicates if the mutation was successful,
or an error message.
Examples:
>>> kili.append_to_roles(project_id=project_id, user_email='john@doe.com')
"""
variables = {
'data': {'role': role,
'userEmail': user_email},
'where': {'id': project_id}
}
result = self.auth.client.execute(GQL_APPEND_TO_ROLES, variables)
return format_result('data', result)
create_project(self, input_type, json_interface, title, description='', project_type=None)
Create a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_type |
Currently, one of {AUDIO, IMAGE, PDF, TEXT, URL, VIDEO, NA} |
required | |
json_interface |
dict |
The json parameters of the project, see Edit your interface. |
required |
title |
Title of the project |
required | |
description |
Description of the project |
'' |
|
project_type |
Optional[str] |
Currently, one of {
|
None |
Returns:
Type | Description |
---|---|
A result object which indicates if the mutation was successful, or an error message. |
Examples:
>>> kili.create_project(input_type='IMAGE', json_interface=json_interface, title='Example')
Recipe
For more detailed examples on how to create projects, see the recipe.
Source code in kili/mutations/project/__init__.py
@Compatible(endpoints=['v2'])
@typechecked
def create_project(self, input_type: str, json_interface: dict,
title: str, description: str = '',
project_type: Optional[str] = None):
# pylint: disable=line-too-long
"""Create a project.
Args:
input_type : Currently, one of {AUDIO, IMAGE, PDF, TEXT, URL, VIDEO, NA}
json_interface: The json parameters of the project, see Edit your interface.
title : Title of the project
description : Description of the project
project_type:
Currently, one of {
`IMAGE_CLASSIFICATION_SINGLE`,
`IMAGE_CLASSIFICATION_MULTI`,
`IMAGE_OBJECT_DETECTION_RECTANGLE`,
`IMAGE_OBJECT_DETECTION_POLYGON`,
`IMAGE_OBJECT_DETECTION_SEMANTIC`,
`OCR, PDF_CLASSIFICATION_SINGLE`,
`PDF_CLASSIFICATION_MULTI`,
`TEXT_CLASSIFICATION_SINGLE`,
`TEXT_CLASSIFICATION_MULTI`,
`TEXT_TRANSCRIPTION, TEXT_NER`,
`VIDEO_CLASSIFICATION_SINGLE`,
`VIDEO_FRAME_CLASSIFICATION`,
`VIDEO_FRAME_OBJECT_TRACKING`,
`SPEECH_TO_TEXT`
}
Returns:
A result object which indicates if the mutation was successful,
or an error message.
Examples:
>>> kili.create_project(input_type='IMAGE', json_interface=json_interface, title='Example')
!!! example "Recipe"
For more detailed examples on how to create projects,
see [the recipe](https://github.com/kili-technology/kili-python-sdk/blob/master/recipes/create_project.ipynb).
"""
variables = {
'data': {'description': description,
'inputType': input_type,
'jsonInterface': dumps(json_interface),
'projectType': project_type,
'title': title}
}
result = self.auth.client.execute(GQL_CREATE_PROJECT, variables)
return format_result('data', result)
delete_from_roles(self, role_id)
Delete users by their role_id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role_id |
Identifier of the project user (not the ID of the user) |
required |
Returns:
Type | Description |
---|---|
A result object which indicates if the mutation was successful, or an error message. |
Source code in kili/mutations/project/__init__.py
@Compatible(['v1', 'v2'])
@typechecked
def delete_from_roles(self, role_id: str):
"""Delete users by their role_id.
Args:
role_id : Identifier of the project user (not the ID of the user)
Returns:
A result object which indicates if the mutation was successful,
or an error message.
"""
variables = {'where': {'id': role_id}}
result = self.auth.client.execute(GQL_DELETE_FROM_ROLES, variables)
return format_result('data', result)
delete_project(self, project_id)
Delete a project permanently.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id |
str |
Identifier of the project |
required |
Returns:
Type | Description |
---|---|
A result object which indicates if the mutation was successful, or an error message. |
Source code in kili/mutations/project/__init__.py
@Compatible(['v1', 'v2'])
@typechecked
def delete_project(self, project_id: str):
"""
Delete a project permanently.
Args:
project_id: Identifier of the project
Returns:
A result object which indicates if the mutation was successful,
or an error message.
"""
variables = {'where': {'id': project_id}}
result = self.auth.client.execute(
GQL_PROJECT_DELETE_ASYNCHRONOUSLY, variables)
return format_result('data', result)
make_project_public(self, project_id)
Make a project public.
Warning
This action is permanent and irreversible.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id |
str |
Identifier of the project |
required |
Returns:
Type | Description |
---|---|
The public token to provide in the public URL |
Source code in kili/mutations/project/__init__.py
@Compatible(['v2'])
@typechecked
def make_project_public(self, project_id: str):
"""
Make a project public.
!!! warning
This action is permanent and irreversible.
Args:
project_id: Identifier of the project
Returns:
The public token to provide in the public URL
"""
variables = {'where': {'id': project_id}}
result = self.auth.client.execute(GQL_MAKE_PROJECT_PUBLIC, variables)
return format_result('data', result)
update_properties_in_project(self, project_id, consensus_mark=None, consensus_tot_coverage=None, description=None, honeypot_mark=None, instructions=None, input_type=None, json_interface=None, min_consensus_size=None, number_of_assets=None, number_of_assets_with_empty_labels=None, number_of_remaining_assets=None, number_of_reviewed_assets=None, review_coverage=None, should_relaunch_kpi_computation=None, title=None, use_honeypot=None)
Update properties of a project.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_id |
str |
Identifier of the project. |
required |
consensus_mark |
Optional[float] |
Should be between 0 and 1. |
None |
consensus_tot_coverage |
Optional[int] |
Should be between 0 and 100. It is the percentage of the dataset that will be annotated several times. |
None |
description |
Description of the project. |
None |
|
honeypot_mark |
Should be between 0 and 1 |
None |
|
instructions |
Instructions of the project. |
None |
|
interface_category |
Always use 'IV2'. |
required | |
input_type |
Optional[str] |
Currently, one of |
None |
json_interface |
Optional[dict] |
The json parameters of the project, see Edit your interface. |
None |
min_consensus_size |
Optional[int] |
Should be between 1 and 10 Number of people that will annotate the same asset, for consensus computation. |
None |
number_of_assets |
Optional[int] |
Defaults to 0 |
None |
number_of_assets_with_empty_labels |
Optional[int] |
Defaults to 0 |
None |
number_of_remaining_assets |
Optional[int] |
Defaults to 0 |
None |
number_of_reviewed_assets |
Optional[int] |
Defaults to 0 |
None |
review_coverage |
Optional[int] |
Allow to set the percentage of assets that will be queued in the review interface. Should be between 0 and 100 |
None |
should_relaunch_kpi_computation |
Optional[bool] |
Technical field, added to indicate changes in honeypot or consensus settings |
None |
title |
Optional[str] |
Title of the project |
None |
use_honeypot |
Optional[bool] |
Activate / Deactivate the use of honeypot in the project |
None |
Returns:
Type | Description |
---|---|
A result object which indicates if the mutation was successful, or an error message. |
Examples:
>>> kili.update_properties_in_project(project_id=project_id, title='New title')
Source code in kili/mutations/project/__init__.py
@Compatible(['v1', 'v2'])
@typechecked
def update_properties_in_project(self, project_id: str,
consensus_mark: Optional[float] = None,
consensus_tot_coverage: Optional[int] = None,
description: Optional[str] = None,
honeypot_mark: Optional[float] = None,
instructions: Optional[str] = None,
input_type: Optional[str] = None,
json_interface: Optional[dict] = None,
min_consensus_size: Optional[int] = None,
number_of_assets: Optional[int] = None,
number_of_assets_with_empty_labels: Optional[int] = None,
number_of_remaining_assets: Optional[int] = None,
number_of_reviewed_assets: Optional[int] = None,
review_coverage: Optional[int] = None,
should_relaunch_kpi_computation: Optional[bool] = None,
title: Optional[str] = None,
use_honeypot: Optional[bool] = None):
"""Update properties of a project.
Args:
project_id: Identifier of the project.
consensus_mark: Should be between 0 and 1.
consensus_tot_coverage: Should be between 0 and 100.
It is the percentage of the dataset that will be annotated several times.
description : Description of the project.
honeypot_mark : Should be between 0 and 1
instructions : Instructions of the project.
interface_category: Always use 'IV2'.
input_type: Currently, one of `AUDIO`, `FRAME`, `IMAGE`, `PDF`, `TEXT`, `VIDEO`, `NA`.
json_interface: The json parameters of the project, see Edit your interface.
min_consensus_size: Should be between 1 and 10
Number of people that will annotate the same asset, for consensus computation.
number_of_assets: Defaults to 0
number_of_assets_with_empty_labels: Defaults to 0
number_of_remaining_assets: Defaults to 0
number_of_reviewed_assets: Defaults to 0
review_coverage: Allow to set the percentage of assets
that will be queued in the review interface.
Should be between 0 and 100
should_relaunch_kpi_computation: Technical field, added to indicate changes
in honeypot or consensus settings
title: Title of the project
use_honeypot: Activate / Deactivate the use of honeypot in the project
Returns:
A result object which indicates if the mutation was successful,
or an error message.
Examples:
>>> kili.update_properties_in_project(project_id=project_id, title='New title')
"""
verify_argument_ranges(consensus_tot_coverage,
min_consensus_size,
review_coverage)
variables = {
'consensusMark': consensus_mark,
'consensusTotCoverage': consensus_tot_coverage,
'description': description,
'honeypotMark': honeypot_mark,
'instructions': instructions,
'inputType': input_type,
'jsonInterface': dumps(json_interface) if json_interface is not None else None,
'minConsensusSize': min_consensus_size,
'numberOfAssets': number_of_assets,
'numberOfAssetsWithSkippedLabels': number_of_assets_with_empty_labels,
'numberOfRemainingAssets': number_of_remaining_assets,
'numberOfReviewedAssets': number_of_reviewed_assets,
'projectID': project_id,
'reviewCoverage': review_coverage,
'shouldRelaunchKpiComputation': should_relaunch_kpi_computation,
'title': title,
'useHoneyPot': use_honeypot
}
result = self.auth.client.execute(
GQL_UPDATE_PROPERTIES_IN_PROJECT, variables)
return format_result('data', result)
update_properties_in_project_user(self, project_user_id, consensus_mark=None, honeypot_mark=None, number_of_labeled_assets=None, starred=None, total_duration=None)
Update properties of a project-user tuple
Parameters:
Name | Type | Description | Default |
---|---|---|---|
project_user_id |
Identifier of the project user |
required | |
consensus_mark |
Optional[float] |
Should be between 0 and 1. |
None |
honeypot_mark |
Optional[float] |
Should be between 0 and 1. |
None |
number_of_labeled_assets |
Optional[int] |
Number of assets the user labeled in the project. |
None |
starred |
Optional[bool] |
Whether to star the project in the project list. |
None |
total_duration |
Optional[int] |
Total time the user spent in the project. |
None |
Returns:
Type | Description |
---|---|
A result object which indicates if the mutation was successful, or an error message. |
Examples:
>>> for project_user in project_users:
... kili.update_properties_in_project_user(
project_user_id=project_user['id'],
honeypot_mark=0)
Source code in kili/mutations/project/__init__.py
@Compatible(['v2'])
@typechecked
def update_properties_in_project_user(self, project_user_id: str,
consensus_mark: Optional[float] = None,
honeypot_mark: Optional[float] = None,
number_of_labeled_assets: Optional[int] = None,
starred: Optional[bool] = None,
total_duration: Optional[int] = None):
"""
Update properties of a project-user tuple
Args:
project_user_id : Identifier of the project user
consensus_mark: Should be between 0 and 1.
honeypot_mark: Should be between 0 and 1.
number_of_labeled_assets: Number of assets the user labeled in the project.
starred: Whether to star the project in the project list.
total_duration: Total time the user spent in the project.
Returns:
A result object which indicates if the mutation was successful,
or an error message.
Examples:
>>> for project_user in project_users:
... kili.update_properties_in_project_user(
project_user_id=project_user['id'],
honeypot_mark=0)
"""
variables = {
'consensusMark': consensus_mark,
'honeypotMark': honeypot_mark,
'numberOfLabeledAssets': number_of_labeled_assets,
'projectUserID': project_user_id,
'starred': starred,
'totalDuration': total_duration,
}
result = self.auth.client.execute(
GQL_GQL_UPDATE_PROPERTIES_IN_PROJECT_USER, variables)
return format_result('data', result)
update_properties_in_role(self, role_id, project_id, user_id, role)
Update properties of a role.
Info
To be able to change someone's role, you must be either of:
- an admin of the project
- a team manager of the project
- an admin of the organization
Parameters:
Name | Type | Description | Default |
---|---|---|---|
role_id |
str |
Role identifier of the user. E.g. : 'to-be-deactivated' |
required |
project_id |
str |
Identifier of the project |
required |
user_id |
str |
The email or identifier of the user with updated role |
required |
role |
str |
The new role.
Possible choices are: |
required |
Returns:
Type | Description |
---|---|
A result object which indicates if the mutation was successful, or an error message. |
Source code in kili/mutations/project/__init__.py
@Compatible(['v1', 'v2'])
@typechecked
def update_properties_in_role(self, role_id: str,
project_id: str, user_id: str, role: str):
"""Update properties of a role.
!!! info
To be able to change someone's role, you must be either of:
- an admin of the project
- a team manager of the project
- an admin of the organization
Args:
role_id: Role identifier of the user. E.g. : 'to-be-deactivated'
project_id: Identifier of the project
user_id: The email or identifier of the user with updated role
role: The new role.
Possible choices are: `ADMIN`, `TEAM_MANAGER`, `REVIEWER`, `LABELER`
Returns:
A result object which indicates if the mutation was successful,
or an error message.
"""
variables = {
'roleID': role_id,
'projectID': project_id,
'userID': user_id,
'role': role
}
result = self.auth.client.execute(
GQL_UPDATE_PROPERTIES_IN_ROLE, variables)
return format_result('data', result)