label-studio-sdk 0.0.32__py3-none-any.whl → 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- label_studio_sdk/__init__.py +206 -6
- label_studio_sdk/_extensions/label_studio_tools/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +163 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/exceptions.py +2 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +228 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/params.py +45 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/__init__.py +1 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/beam.py +34 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/example.py +17 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/registry.py +67 -0
- label_studio_sdk/_extensions/label_studio_tools/postprocessing/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/postprocessing/video.py +97 -0
- label_studio_sdk/_legacy/__init__.py +11 -0
- label_studio_sdk/_legacy/client.py +471 -0
- label_studio_sdk/_legacy/exceptions.py +10 -0
- label_studio_sdk/_legacy/label_interface/__init__.py +1 -0
- label_studio_sdk/_legacy/label_interface/base.py +77 -0
- label_studio_sdk/_legacy/label_interface/control_tags.py +756 -0
- label_studio_sdk/_legacy/label_interface/data_examples.json +96 -0
- label_studio_sdk/_legacy/label_interface/interface.py +925 -0
- label_studio_sdk/_legacy/label_interface/label_tags.py +72 -0
- label_studio_sdk/_legacy/label_interface/object_tags.py +292 -0
- label_studio_sdk/_legacy/label_interface/region.py +43 -0
- label_studio_sdk/_legacy/objects.py +35 -0
- label_studio_sdk/{project.py → _legacy/project.py} +711 -258
- label_studio_sdk/_legacy/schema/label_config_schema.json +226 -0
- label_studio_sdk/{users.py → _legacy/users.py} +15 -13
- label_studio_sdk/{utils.py → _legacy/utils.py} +31 -30
- label_studio_sdk/{workspaces.py → _legacy/workspaces.py} +13 -11
- label_studio_sdk/actions/__init__.py +2 -0
- label_studio_sdk/actions/client.py +150 -0
- label_studio_sdk/annotations/__init__.py +2 -0
- label_studio_sdk/annotations/client.py +750 -0
- label_studio_sdk/client.py +164 -436
- label_studio_sdk/converter/__init__.py +7 -0
- label_studio_sdk/converter/audio.py +56 -0
- label_studio_sdk/converter/brush.py +452 -0
- label_studio_sdk/converter/converter.py +1175 -0
- label_studio_sdk/converter/exports/__init__.py +0 -0
- label_studio_sdk/converter/exports/csv.py +82 -0
- label_studio_sdk/converter/exports/csv2.py +103 -0
- label_studio_sdk/converter/funsd.py +85 -0
- label_studio_sdk/converter/imports/__init__.py +0 -0
- label_studio_sdk/converter/imports/coco.py +314 -0
- label_studio_sdk/converter/imports/colors.py +198 -0
- label_studio_sdk/converter/imports/label_config.py +45 -0
- label_studio_sdk/converter/imports/pathtrack.py +269 -0
- label_studio_sdk/converter/imports/yolo.py +236 -0
- label_studio_sdk/converter/main.py +202 -0
- label_studio_sdk/converter/utils.py +473 -0
- label_studio_sdk/core/__init__.py +33 -0
- label_studio_sdk/core/api_error.py +15 -0
- label_studio_sdk/core/client_wrapper.py +55 -0
- label_studio_sdk/core/datetime_utils.py +28 -0
- label_studio_sdk/core/file.py +38 -0
- label_studio_sdk/core/http_client.py +443 -0
- label_studio_sdk/core/jsonable_encoder.py +99 -0
- label_studio_sdk/core/pagination.py +87 -0
- label_studio_sdk/core/pydantic_utilities.py +28 -0
- label_studio_sdk/core/query_encoder.py +33 -0
- label_studio_sdk/core/remove_none_from_dict.py +11 -0
- label_studio_sdk/core/request_options.py +32 -0
- label_studio_sdk/data_manager.py +32 -23
- label_studio_sdk/environment.py +7 -0
- label_studio_sdk/errors/__init__.py +6 -0
- label_studio_sdk/errors/bad_request_error.py +8 -0
- label_studio_sdk/errors/internal_server_error.py +8 -0
- label_studio_sdk/export_storage/__init__.py +28 -0
- label_studio_sdk/export_storage/azure/__init__.py +5 -0
- label_studio_sdk/export_storage/azure/client.py +722 -0
- label_studio_sdk/export_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/export_storage/azure/types/azure_create_response.py +52 -0
- label_studio_sdk/export_storage/azure/types/azure_update_response.py +52 -0
- label_studio_sdk/export_storage/client.py +107 -0
- label_studio_sdk/export_storage/gcs/__init__.py +5 -0
- label_studio_sdk/export_storage/gcs/client.py +722 -0
- label_studio_sdk/export_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +52 -0
- label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +52 -0
- label_studio_sdk/export_storage/local/__init__.py +5 -0
- label_studio_sdk/export_storage/local/client.py +688 -0
- label_studio_sdk/export_storage/local/types/__init__.py +6 -0
- label_studio_sdk/export_storage/local/types/local_create_response.py +47 -0
- label_studio_sdk/export_storage/local/types/local_update_response.py +47 -0
- label_studio_sdk/export_storage/redis/__init__.py +5 -0
- label_studio_sdk/export_storage/redis/client.py +714 -0
- label_studio_sdk/export_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/export_storage/redis/types/redis_create_response.py +57 -0
- label_studio_sdk/export_storage/redis/types/redis_update_response.py +57 -0
- label_studio_sdk/export_storage/s3/__init__.py +5 -0
- label_studio_sdk/export_storage/s3/client.py +820 -0
- label_studio_sdk/export_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/export_storage/s3/types/s3create_response.py +74 -0
- label_studio_sdk/export_storage/s3/types/s3update_response.py +74 -0
- label_studio_sdk/export_storage/types/__init__.py +5 -0
- label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +30 -0
- label_studio_sdk/files/__init__.py +2 -0
- label_studio_sdk/files/client.py +556 -0
- label_studio_sdk/import_storage/__init__.py +28 -0
- label_studio_sdk/import_storage/azure/__init__.py +5 -0
- label_studio_sdk/import_storage/azure/client.py +812 -0
- label_studio_sdk/import_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/import_storage/azure/types/azure_create_response.py +72 -0
- label_studio_sdk/import_storage/azure/types/azure_update_response.py +72 -0
- label_studio_sdk/import_storage/client.py +107 -0
- label_studio_sdk/import_storage/gcs/__init__.py +5 -0
- label_studio_sdk/import_storage/gcs/client.py +812 -0
- label_studio_sdk/import_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +72 -0
- label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +72 -0
- label_studio_sdk/import_storage/local/__init__.py +5 -0
- label_studio_sdk/import_storage/local/client.py +690 -0
- label_studio_sdk/import_storage/local/types/__init__.py +6 -0
- label_studio_sdk/import_storage/local/types/local_create_response.py +47 -0
- label_studio_sdk/import_storage/local/types/local_update_response.py +47 -0
- label_studio_sdk/import_storage/redis/__init__.py +5 -0
- label_studio_sdk/import_storage/redis/client.py +768 -0
- label_studio_sdk/import_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/import_storage/redis/types/redis_create_response.py +62 -0
- label_studio_sdk/import_storage/redis/types/redis_update_response.py +62 -0
- label_studio_sdk/import_storage/s3/__init__.py +5 -0
- label_studio_sdk/import_storage/s3/client.py +912 -0
- label_studio_sdk/import_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/import_storage/s3/types/s3create_response.py +99 -0
- label_studio_sdk/import_storage/s3/types/s3update_response.py +99 -0
- label_studio_sdk/import_storage/types/__init__.py +5 -0
- label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +30 -0
- label_studio_sdk/ml/__init__.py +19 -0
- label_studio_sdk/ml/client.py +981 -0
- label_studio_sdk/ml/types/__init__.py +17 -0
- label_studio_sdk/ml/types/ml_create_request_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_create_response.py +78 -0
- label_studio_sdk/ml/types/ml_create_response_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_update_request_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_update_response.py +78 -0
- label_studio_sdk/ml/types/ml_update_response_auth_method.py +5 -0
- label_studio_sdk/predictions/__init__.py +2 -0
- label_studio_sdk/predictions/client.py +638 -0
- label_studio_sdk/projects/__init__.py +6 -0
- label_studio_sdk/projects/client.py +1053 -0
- label_studio_sdk/projects/exports/__init__.py +2 -0
- label_studio_sdk/projects/exports/client.py +930 -0
- label_studio_sdk/projects/types/__init__.py +7 -0
- label_studio_sdk/projects/types/projects_create_response.py +96 -0
- label_studio_sdk/projects/types/projects_import_tasks_response.py +71 -0
- label_studio_sdk/projects/types/projects_list_response.py +33 -0
- label_studio_sdk/py.typed +0 -0
- label_studio_sdk/tasks/__init__.py +5 -0
- label_studio_sdk/tasks/client.py +811 -0
- label_studio_sdk/tasks/types/__init__.py +6 -0
- label_studio_sdk/tasks/types/tasks_list_request_fields.py +5 -0
- label_studio_sdk/tasks/types/tasks_list_response.py +48 -0
- label_studio_sdk/types/__init__.py +115 -0
- label_studio_sdk/types/annotation.py +116 -0
- label_studio_sdk/types/annotation_filter_options.py +42 -0
- label_studio_sdk/types/annotation_last_action.py +19 -0
- label_studio_sdk/types/azure_blob_export_storage.py +112 -0
- label_studio_sdk/types/azure_blob_export_storage_status.py +7 -0
- label_studio_sdk/types/azure_blob_import_storage.py +113 -0
- label_studio_sdk/types/azure_blob_import_storage_status.py +7 -0
- label_studio_sdk/types/base_task.py +113 -0
- label_studio_sdk/types/base_user.py +42 -0
- label_studio_sdk/types/converted_format.py +36 -0
- label_studio_sdk/types/converted_format_status.py +5 -0
- label_studio_sdk/types/export.py +48 -0
- label_studio_sdk/types/export_convert.py +32 -0
- label_studio_sdk/types/export_create.py +54 -0
- label_studio_sdk/types/export_create_status.py +5 -0
- label_studio_sdk/types/export_status.py +5 -0
- label_studio_sdk/types/file_upload.py +30 -0
- label_studio_sdk/types/filter.py +53 -0
- label_studio_sdk/types/filter_group.py +35 -0
- label_studio_sdk/types/gcs_export_storage.py +112 -0
- label_studio_sdk/types/gcs_export_storage_status.py +7 -0
- label_studio_sdk/types/gcs_import_storage.py +113 -0
- label_studio_sdk/types/gcs_import_storage_status.py +7 -0
- label_studio_sdk/types/local_files_export_storage.py +97 -0
- label_studio_sdk/types/local_files_export_storage_status.py +7 -0
- label_studio_sdk/types/local_files_import_storage.py +92 -0
- label_studio_sdk/types/local_files_import_storage_status.py +7 -0
- label_studio_sdk/types/ml_backend.py +89 -0
- label_studio_sdk/types/ml_backend_auth_method.py +5 -0
- label_studio_sdk/types/ml_backend_state.py +5 -0
- label_studio_sdk/types/prediction.py +78 -0
- label_studio_sdk/types/project.py +198 -0
- label_studio_sdk/types/project_import.py +63 -0
- label_studio_sdk/types/project_import_status.py +5 -0
- label_studio_sdk/types/project_label_config.py +32 -0
- label_studio_sdk/types/project_sampling.py +7 -0
- label_studio_sdk/types/project_skip_queue.py +5 -0
- label_studio_sdk/types/redis_export_storage.py +117 -0
- label_studio_sdk/types/redis_export_storage_status.py +7 -0
- label_studio_sdk/types/redis_import_storage.py +112 -0
- label_studio_sdk/types/redis_import_storage_status.py +7 -0
- label_studio_sdk/types/s3export_storage.py +134 -0
- label_studio_sdk/types/s3export_storage_status.py +7 -0
- label_studio_sdk/types/s3import_storage.py +140 -0
- label_studio_sdk/types/s3import_storage_status.py +7 -0
- label_studio_sdk/types/serialization_option.py +36 -0
- label_studio_sdk/types/serialization_options.py +45 -0
- label_studio_sdk/types/task.py +157 -0
- label_studio_sdk/types/task_filter_options.py +49 -0
- label_studio_sdk/types/user_simple.py +37 -0
- label_studio_sdk/types/view.py +55 -0
- label_studio_sdk/types/webhook.py +67 -0
- label_studio_sdk/types/webhook_actions_item.py +21 -0
- label_studio_sdk/types/webhook_serializer_for_update.py +67 -0
- label_studio_sdk/types/webhook_serializer_for_update_actions_item.py +21 -0
- label_studio_sdk/users/__init__.py +5 -0
- label_studio_sdk/users/client.py +830 -0
- label_studio_sdk/users/types/__init__.py +6 -0
- label_studio_sdk/users/types/users_get_token_response.py +36 -0
- label_studio_sdk/users/types/users_reset_token_response.py +36 -0
- label_studio_sdk/version.py +4 -0
- label_studio_sdk/views/__init__.py +31 -0
- label_studio_sdk/views/client.py +564 -0
- label_studio_sdk/views/types/__init__.py +29 -0
- label_studio_sdk/views/types/views_create_request_data.py +43 -0
- label_studio_sdk/views/types/views_create_request_data_filters.py +43 -0
- label_studio_sdk/views/types/views_create_request_data_filters_conjunction.py +5 -0
- label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +47 -0
- label_studio_sdk/views/types/views_create_request_data_ordering_item.py +38 -0
- label_studio_sdk/views/types/views_create_request_data_ordering_item_direction.py +5 -0
- label_studio_sdk/views/types/views_update_request_data.py +43 -0
- label_studio_sdk/views/types/views_update_request_data_filters.py +43 -0
- label_studio_sdk/views/types/views_update_request_data_filters_conjunction.py +5 -0
- label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +47 -0
- label_studio_sdk/views/types/views_update_request_data_ordering_item.py +38 -0
- label_studio_sdk/views/types/views_update_request_data_ordering_item_direction.py +5 -0
- label_studio_sdk/webhooks/__init__.py +5 -0
- label_studio_sdk/webhooks/client.py +636 -0
- label_studio_sdk/webhooks/types/__init__.py +5 -0
- label_studio_sdk/webhooks/types/webhooks_update_request_actions_item.py +21 -0
- label_studio_sdk-1.0.0.dist-info/METADATA +307 -0
- label_studio_sdk-1.0.0.dist-info/RECORD +239 -0
- {label_studio_sdk-0.0.32.dist-info → label_studio_sdk-1.0.0.dist-info}/WHEEL +1 -2
- docs/__init__.py +0 -3
- label_studio_sdk-0.0.32.dist-info/LICENSE +0 -201
- label_studio_sdk-0.0.32.dist-info/METADATA +0 -22
- label_studio_sdk-0.0.32.dist-info/RECORD +0 -15
- label_studio_sdk-0.0.32.dist-info/top_level.txt +0 -3
- tests/test_client.py +0 -26
- {tests → label_studio_sdk/_extensions}/__init__.py +0 -0
|
@@ -0,0 +1,811 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
9
|
+
from ..core.pagination import AsyncPager, SyncPager
|
|
10
|
+
from ..core.pydantic_utilities import pydantic_v1
|
|
11
|
+
from ..core.request_options import RequestOptions
|
|
12
|
+
from ..types.base_task import BaseTask
|
|
13
|
+
from ..types.project_import import ProjectImport
|
|
14
|
+
from ..types.task import Task
|
|
15
|
+
from .types.tasks_list_request_fields import TasksListRequestFields
|
|
16
|
+
from .types.tasks_list_response import TasksListResponse
|
|
17
|
+
|
|
18
|
+
# this is used as the default value for optional parameters
|
|
19
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TasksClient:
|
|
23
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
24
|
+
self._client_wrapper = client_wrapper
|
|
25
|
+
|
|
26
|
+
def create_many_status(
|
|
27
|
+
self, id: int, import_pk: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
28
|
+
) -> ProjectImport:
|
|
29
|
+
"""
|
|
30
|
+
Get information about an async project import operation. This can be especially useful to monitor status, as large import jobs can take time.
|
|
31
|
+
|
|
32
|
+
You will need the project ID and the unique ID of the import operation.
|
|
33
|
+
|
|
34
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
35
|
+
|
|
36
|
+
The import ID is returned as part of the response when you call [Import tasks](import-tasks).
|
|
37
|
+
|
|
38
|
+
Parameters
|
|
39
|
+
----------
|
|
40
|
+
id : int
|
|
41
|
+
The project ID.
|
|
42
|
+
|
|
43
|
+
import_pk : str
|
|
44
|
+
|
|
45
|
+
request_options : typing.Optional[RequestOptions]
|
|
46
|
+
Request-specific configuration.
|
|
47
|
+
|
|
48
|
+
Returns
|
|
49
|
+
-------
|
|
50
|
+
ProjectImport
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Examples
|
|
54
|
+
--------
|
|
55
|
+
from label_studio_sdk.client import LabelStudio
|
|
56
|
+
|
|
57
|
+
client = LabelStudio(
|
|
58
|
+
api_key="YOUR_API_KEY",
|
|
59
|
+
)
|
|
60
|
+
client.tasks.create_many_status(
|
|
61
|
+
id=1,
|
|
62
|
+
import_pk="import_pk",
|
|
63
|
+
)
|
|
64
|
+
"""
|
|
65
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
66
|
+
f"api/projects/{jsonable_encoder(id)}/imports/{jsonable_encoder(import_pk)}/",
|
|
67
|
+
method="GET",
|
|
68
|
+
request_options=request_options,
|
|
69
|
+
)
|
|
70
|
+
if 200 <= _response.status_code < 300:
|
|
71
|
+
return pydantic_v1.parse_obj_as(ProjectImport, _response.json()) # type: ignore
|
|
72
|
+
try:
|
|
73
|
+
_response_json = _response.json()
|
|
74
|
+
except JSONDecodeError:
|
|
75
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
76
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
77
|
+
|
|
78
|
+
def delete_all_tasks(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
79
|
+
"""
|
|
80
|
+
Delete all tasks from a specific project.
|
|
81
|
+
|
|
82
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
id : int
|
|
87
|
+
A unique integer value identifying this project.
|
|
88
|
+
|
|
89
|
+
request_options : typing.Optional[RequestOptions]
|
|
90
|
+
Request-specific configuration.
|
|
91
|
+
|
|
92
|
+
Returns
|
|
93
|
+
-------
|
|
94
|
+
None
|
|
95
|
+
|
|
96
|
+
Examples
|
|
97
|
+
--------
|
|
98
|
+
from label_studio_sdk.client import LabelStudio
|
|
99
|
+
|
|
100
|
+
client = LabelStudio(
|
|
101
|
+
api_key="YOUR_API_KEY",
|
|
102
|
+
)
|
|
103
|
+
client.tasks.delete_all_tasks(
|
|
104
|
+
id=1,
|
|
105
|
+
)
|
|
106
|
+
"""
|
|
107
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
108
|
+
f"api/projects/{jsonable_encoder(id)}/tasks/", method="DELETE", request_options=request_options
|
|
109
|
+
)
|
|
110
|
+
if 200 <= _response.status_code < 300:
|
|
111
|
+
return
|
|
112
|
+
try:
|
|
113
|
+
_response_json = _response.json()
|
|
114
|
+
except JSONDecodeError:
|
|
115
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
116
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
117
|
+
|
|
118
|
+
def list(
|
|
119
|
+
self,
|
|
120
|
+
*,
|
|
121
|
+
page: typing.Optional[int] = None,
|
|
122
|
+
page_size: typing.Optional[int] = None,
|
|
123
|
+
view: typing.Optional[int] = None,
|
|
124
|
+
project: typing.Optional[int] = None,
|
|
125
|
+
resolve_uri: typing.Optional[bool] = None,
|
|
126
|
+
fields: typing.Optional[TasksListRequestFields] = None,
|
|
127
|
+
review: typing.Optional[bool] = None,
|
|
128
|
+
include: typing.Optional[str] = None,
|
|
129
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
130
|
+
) -> SyncPager[Task]:
|
|
131
|
+
"""
|
|
132
|
+
Retrieve a list of tasks.
|
|
133
|
+
|
|
134
|
+
You can use the query parameters to filter the list by project and/or view (a tab within the Data Manager). You can also optionally add pagination to make the response easier to parse.
|
|
135
|
+
|
|
136
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list). The view ID can be found using [List views](../views/list).
|
|
137
|
+
|
|
138
|
+
Parameters
|
|
139
|
+
----------
|
|
140
|
+
page : typing.Optional[int]
|
|
141
|
+
A page number within the paginated result set.
|
|
142
|
+
|
|
143
|
+
page_size : typing.Optional[int]
|
|
144
|
+
Number of results to return per page.
|
|
145
|
+
|
|
146
|
+
view : typing.Optional[int]
|
|
147
|
+
View ID
|
|
148
|
+
|
|
149
|
+
project : typing.Optional[int]
|
|
150
|
+
Project ID
|
|
151
|
+
|
|
152
|
+
resolve_uri : typing.Optional[bool]
|
|
153
|
+
Resolve task data URIs using Cloud Storage
|
|
154
|
+
|
|
155
|
+
fields : typing.Optional[TasksListRequestFields]
|
|
156
|
+
Set to "all" if you want to include annotations and predictions in the response
|
|
157
|
+
|
|
158
|
+
review : typing.Optional[bool]
|
|
159
|
+
Get tasks for review
|
|
160
|
+
|
|
161
|
+
include : typing.Optional[str]
|
|
162
|
+
Specify which fields to include in the response
|
|
163
|
+
|
|
164
|
+
request_options : typing.Optional[RequestOptions]
|
|
165
|
+
Request-specific configuration.
|
|
166
|
+
|
|
167
|
+
Returns
|
|
168
|
+
-------
|
|
169
|
+
SyncPager[Task]
|
|
170
|
+
List of Tasks
|
|
171
|
+
|
|
172
|
+
Examples
|
|
173
|
+
--------
|
|
174
|
+
from label_studio_sdk.client import LabelStudio
|
|
175
|
+
|
|
176
|
+
client = LabelStudio(
|
|
177
|
+
api_key="YOUR_API_KEY",
|
|
178
|
+
)
|
|
179
|
+
client.tasks.list()
|
|
180
|
+
"""
|
|
181
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
182
|
+
"api/tasks/",
|
|
183
|
+
method="GET",
|
|
184
|
+
params={
|
|
185
|
+
"page": page,
|
|
186
|
+
"page_size": page_size,
|
|
187
|
+
"view": view,
|
|
188
|
+
"project": project,
|
|
189
|
+
"resolve_uri": resolve_uri,
|
|
190
|
+
"fields": fields,
|
|
191
|
+
"review": review,
|
|
192
|
+
"include": include,
|
|
193
|
+
},
|
|
194
|
+
request_options=request_options,
|
|
195
|
+
)
|
|
196
|
+
if 200 <= _response.status_code < 300:
|
|
197
|
+
_parsed_response = pydantic_v1.parse_obj_as(TasksListResponse, _response.json()) # type: ignore
|
|
198
|
+
_has_next = True
|
|
199
|
+
_get_next = lambda: self.list(
|
|
200
|
+
page=page + 1 if page is not None else 1,
|
|
201
|
+
page_size=page_size,
|
|
202
|
+
view=view,
|
|
203
|
+
project=project,
|
|
204
|
+
resolve_uri=resolve_uri,
|
|
205
|
+
fields=fields,
|
|
206
|
+
review=review,
|
|
207
|
+
include=include,
|
|
208
|
+
request_options=request_options,
|
|
209
|
+
)
|
|
210
|
+
_items = _parsed_response.tasks
|
|
211
|
+
return SyncPager(has_next=_has_next, items=_items, get_next=_get_next)
|
|
212
|
+
try:
|
|
213
|
+
_response_json = _response.json()
|
|
214
|
+
except JSONDecodeError:
|
|
215
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
216
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
217
|
+
|
|
218
|
+
def create(
|
|
219
|
+
self,
|
|
220
|
+
*,
|
|
221
|
+
data: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
222
|
+
project: typing.Optional[int] = OMIT,
|
|
223
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
224
|
+
) -> BaseTask:
|
|
225
|
+
"""
|
|
226
|
+
Create a new labeling task in Label Studio.
|
|
227
|
+
|
|
228
|
+
The data you provide depends on your labeling config and data type.
|
|
229
|
+
|
|
230
|
+
You will also need to provide a project ID. The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
231
|
+
|
|
232
|
+
Parameters
|
|
233
|
+
----------
|
|
234
|
+
data : typing.Optional[typing.Dict[str, typing.Any]]
|
|
235
|
+
Task data dictionary with arbitrary keys and values
|
|
236
|
+
|
|
237
|
+
project : typing.Optional[int]
|
|
238
|
+
Project ID
|
|
239
|
+
|
|
240
|
+
request_options : typing.Optional[RequestOptions]
|
|
241
|
+
Request-specific configuration.
|
|
242
|
+
|
|
243
|
+
Returns
|
|
244
|
+
-------
|
|
245
|
+
BaseTask
|
|
246
|
+
Created task
|
|
247
|
+
|
|
248
|
+
Examples
|
|
249
|
+
--------
|
|
250
|
+
from label_studio_sdk.client import LabelStudio
|
|
251
|
+
|
|
252
|
+
client = LabelStudio(
|
|
253
|
+
api_key="YOUR_API_KEY",
|
|
254
|
+
)
|
|
255
|
+
client.tasks.create(
|
|
256
|
+
data={"image": "https://example.com/image.jpg", "text": "Hello, world!"},
|
|
257
|
+
project=1,
|
|
258
|
+
)
|
|
259
|
+
"""
|
|
260
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
261
|
+
"api/tasks/",
|
|
262
|
+
method="POST",
|
|
263
|
+
json={"data": data, "project": project},
|
|
264
|
+
request_options=request_options,
|
|
265
|
+
omit=OMIT,
|
|
266
|
+
)
|
|
267
|
+
if 200 <= _response.status_code < 300:
|
|
268
|
+
return pydantic_v1.parse_obj_as(BaseTask, _response.json()) # type: ignore
|
|
269
|
+
try:
|
|
270
|
+
_response_json = _response.json()
|
|
271
|
+
except JSONDecodeError:
|
|
272
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
273
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
274
|
+
|
|
275
|
+
def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> BaseTask:
|
|
276
|
+
"""
|
|
277
|
+
Get task data, metadata, annotations and other attributes for a specific labeling task by task ID.
|
|
278
|
+
The task ID is available from the Label Studio URL when viewing the task, or you can retrieve it programmatically with [Get task list](list).
|
|
279
|
+
|
|
280
|
+
Parameters
|
|
281
|
+
----------
|
|
282
|
+
id : str
|
|
283
|
+
Task ID
|
|
284
|
+
|
|
285
|
+
request_options : typing.Optional[RequestOptions]
|
|
286
|
+
Request-specific configuration.
|
|
287
|
+
|
|
288
|
+
Returns
|
|
289
|
+
-------
|
|
290
|
+
BaseTask
|
|
291
|
+
Task
|
|
292
|
+
|
|
293
|
+
Examples
|
|
294
|
+
--------
|
|
295
|
+
from label_studio_sdk.client import LabelStudio
|
|
296
|
+
|
|
297
|
+
client = LabelStudio(
|
|
298
|
+
api_key="YOUR_API_KEY",
|
|
299
|
+
)
|
|
300
|
+
client.tasks.get(
|
|
301
|
+
id="id",
|
|
302
|
+
)
|
|
303
|
+
"""
|
|
304
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
305
|
+
f"api/tasks/{jsonable_encoder(id)}/", method="GET", request_options=request_options
|
|
306
|
+
)
|
|
307
|
+
if 200 <= _response.status_code < 300:
|
|
308
|
+
return pydantic_v1.parse_obj_as(BaseTask, _response.json()) # type: ignore
|
|
309
|
+
try:
|
|
310
|
+
_response_json = _response.json()
|
|
311
|
+
except JSONDecodeError:
|
|
312
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
313
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
314
|
+
|
|
315
|
+
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
316
|
+
"""
|
|
317
|
+
Delete a task in Label Studio.
|
|
318
|
+
|
|
319
|
+
You will need the task ID. This is available from the Label Studio URL when viewing the task, or you can retrieve it programmatically with [Get task list](list).
|
|
320
|
+
|
|
321
|
+
<Warning>This action cannot be undone.</Warning>
|
|
322
|
+
|
|
323
|
+
Parameters
|
|
324
|
+
----------
|
|
325
|
+
id : str
|
|
326
|
+
Task ID
|
|
327
|
+
|
|
328
|
+
request_options : typing.Optional[RequestOptions]
|
|
329
|
+
Request-specific configuration.
|
|
330
|
+
|
|
331
|
+
Returns
|
|
332
|
+
-------
|
|
333
|
+
None
|
|
334
|
+
|
|
335
|
+
Examples
|
|
336
|
+
--------
|
|
337
|
+
from label_studio_sdk.client import LabelStudio
|
|
338
|
+
|
|
339
|
+
client = LabelStudio(
|
|
340
|
+
api_key="YOUR_API_KEY",
|
|
341
|
+
)
|
|
342
|
+
client.tasks.delete(
|
|
343
|
+
id="id",
|
|
344
|
+
)
|
|
345
|
+
"""
|
|
346
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
347
|
+
f"api/tasks/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
|
|
348
|
+
)
|
|
349
|
+
if 200 <= _response.status_code < 300:
|
|
350
|
+
return
|
|
351
|
+
try:
|
|
352
|
+
_response_json = _response.json()
|
|
353
|
+
except JSONDecodeError:
|
|
354
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
355
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
356
|
+
|
|
357
|
+
def update(
|
|
358
|
+
self,
|
|
359
|
+
id: str,
|
|
360
|
+
*,
|
|
361
|
+
data: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
362
|
+
project: typing.Optional[int] = OMIT,
|
|
363
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
364
|
+
) -> BaseTask:
|
|
365
|
+
"""
|
|
366
|
+
Update the attributes of an existing labeling task.
|
|
367
|
+
|
|
368
|
+
You will need the task ID. This is available from the Label Studio URL when viewing the task, or you can retrieve it programmatically with [Get task list](list).
|
|
369
|
+
|
|
370
|
+
Parameters
|
|
371
|
+
----------
|
|
372
|
+
id : str
|
|
373
|
+
Task ID
|
|
374
|
+
|
|
375
|
+
data : typing.Optional[typing.Dict[str, typing.Any]]
|
|
376
|
+
Task data dictionary with arbitrary keys and values
|
|
377
|
+
|
|
378
|
+
project : typing.Optional[int]
|
|
379
|
+
Project ID
|
|
380
|
+
|
|
381
|
+
request_options : typing.Optional[RequestOptions]
|
|
382
|
+
Request-specific configuration.
|
|
383
|
+
|
|
384
|
+
Returns
|
|
385
|
+
-------
|
|
386
|
+
BaseTask
|
|
387
|
+
Updated task
|
|
388
|
+
|
|
389
|
+
Examples
|
|
390
|
+
--------
|
|
391
|
+
from label_studio_sdk.client import LabelStudio
|
|
392
|
+
|
|
393
|
+
client = LabelStudio(
|
|
394
|
+
api_key="YOUR_API_KEY",
|
|
395
|
+
)
|
|
396
|
+
client.tasks.update(
|
|
397
|
+
id="id",
|
|
398
|
+
data={"image": "https://example.com/image.jpg", "text": "Hello, world!"},
|
|
399
|
+
project=1,
|
|
400
|
+
)
|
|
401
|
+
"""
|
|
402
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
403
|
+
f"api/tasks/{jsonable_encoder(id)}/",
|
|
404
|
+
method="PATCH",
|
|
405
|
+
json={"data": data, "project": project},
|
|
406
|
+
request_options=request_options,
|
|
407
|
+
omit=OMIT,
|
|
408
|
+
)
|
|
409
|
+
if 200 <= _response.status_code < 300:
|
|
410
|
+
return pydantic_v1.parse_obj_as(BaseTask, _response.json()) # type: ignore
|
|
411
|
+
try:
|
|
412
|
+
_response_json = _response.json()
|
|
413
|
+
except JSONDecodeError:
|
|
414
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
415
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
416
|
+
|
|
417
|
+
|
|
418
|
+
class AsyncTasksClient:
|
|
419
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
420
|
+
self._client_wrapper = client_wrapper
|
|
421
|
+
|
|
422
|
+
async def create_many_status(
|
|
423
|
+
self, id: int, import_pk: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
424
|
+
) -> ProjectImport:
|
|
425
|
+
"""
|
|
426
|
+
Get information about an async project import operation. This can be especially useful to monitor status, as large import jobs can take time.
|
|
427
|
+
|
|
428
|
+
You will need the project ID and the unique ID of the import operation.
|
|
429
|
+
|
|
430
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
431
|
+
|
|
432
|
+
The import ID is returned as part of the response when you call [Import tasks](import-tasks).
|
|
433
|
+
|
|
434
|
+
Parameters
|
|
435
|
+
----------
|
|
436
|
+
id : int
|
|
437
|
+
The project ID.
|
|
438
|
+
|
|
439
|
+
import_pk : str
|
|
440
|
+
|
|
441
|
+
request_options : typing.Optional[RequestOptions]
|
|
442
|
+
Request-specific configuration.
|
|
443
|
+
|
|
444
|
+
Returns
|
|
445
|
+
-------
|
|
446
|
+
ProjectImport
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
Examples
|
|
450
|
+
--------
|
|
451
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
452
|
+
|
|
453
|
+
client = AsyncLabelStudio(
|
|
454
|
+
api_key="YOUR_API_KEY",
|
|
455
|
+
)
|
|
456
|
+
await client.tasks.create_many_status(
|
|
457
|
+
id=1,
|
|
458
|
+
import_pk="import_pk",
|
|
459
|
+
)
|
|
460
|
+
"""
|
|
461
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
462
|
+
f"api/projects/{jsonable_encoder(id)}/imports/{jsonable_encoder(import_pk)}/",
|
|
463
|
+
method="GET",
|
|
464
|
+
request_options=request_options,
|
|
465
|
+
)
|
|
466
|
+
if 200 <= _response.status_code < 300:
|
|
467
|
+
return pydantic_v1.parse_obj_as(ProjectImport, _response.json()) # type: ignore
|
|
468
|
+
try:
|
|
469
|
+
_response_json = _response.json()
|
|
470
|
+
except JSONDecodeError:
|
|
471
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
472
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
473
|
+
|
|
474
|
+
async def delete_all_tasks(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
475
|
+
"""
|
|
476
|
+
Delete all tasks from a specific project.
|
|
477
|
+
|
|
478
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
479
|
+
|
|
480
|
+
Parameters
|
|
481
|
+
----------
|
|
482
|
+
id : int
|
|
483
|
+
A unique integer value identifying this project.
|
|
484
|
+
|
|
485
|
+
request_options : typing.Optional[RequestOptions]
|
|
486
|
+
Request-specific configuration.
|
|
487
|
+
|
|
488
|
+
Returns
|
|
489
|
+
-------
|
|
490
|
+
None
|
|
491
|
+
|
|
492
|
+
Examples
|
|
493
|
+
--------
|
|
494
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
495
|
+
|
|
496
|
+
client = AsyncLabelStudio(
|
|
497
|
+
api_key="YOUR_API_KEY",
|
|
498
|
+
)
|
|
499
|
+
await client.tasks.delete_all_tasks(
|
|
500
|
+
id=1,
|
|
501
|
+
)
|
|
502
|
+
"""
|
|
503
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
504
|
+
f"api/projects/{jsonable_encoder(id)}/tasks/", method="DELETE", request_options=request_options
|
|
505
|
+
)
|
|
506
|
+
if 200 <= _response.status_code < 300:
|
|
507
|
+
return
|
|
508
|
+
try:
|
|
509
|
+
_response_json = _response.json()
|
|
510
|
+
except JSONDecodeError:
|
|
511
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
512
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
513
|
+
|
|
514
|
+
async def list(
|
|
515
|
+
self,
|
|
516
|
+
*,
|
|
517
|
+
page: typing.Optional[int] = None,
|
|
518
|
+
page_size: typing.Optional[int] = None,
|
|
519
|
+
view: typing.Optional[int] = None,
|
|
520
|
+
project: typing.Optional[int] = None,
|
|
521
|
+
resolve_uri: typing.Optional[bool] = None,
|
|
522
|
+
fields: typing.Optional[TasksListRequestFields] = None,
|
|
523
|
+
review: typing.Optional[bool] = None,
|
|
524
|
+
include: typing.Optional[str] = None,
|
|
525
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
526
|
+
) -> AsyncPager[Task]:
|
|
527
|
+
"""
|
|
528
|
+
Retrieve a list of tasks.
|
|
529
|
+
|
|
530
|
+
You can use the query parameters to filter the list by project and/or view (a tab within the Data Manager). You can also optionally add pagination to make the response easier to parse.
|
|
531
|
+
|
|
532
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list). The view ID can be found using [List views](../views/list).
|
|
533
|
+
|
|
534
|
+
Parameters
|
|
535
|
+
----------
|
|
536
|
+
page : typing.Optional[int]
|
|
537
|
+
A page number within the paginated result set.
|
|
538
|
+
|
|
539
|
+
page_size : typing.Optional[int]
|
|
540
|
+
Number of results to return per page.
|
|
541
|
+
|
|
542
|
+
view : typing.Optional[int]
|
|
543
|
+
View ID
|
|
544
|
+
|
|
545
|
+
project : typing.Optional[int]
|
|
546
|
+
Project ID
|
|
547
|
+
|
|
548
|
+
resolve_uri : typing.Optional[bool]
|
|
549
|
+
Resolve task data URIs using Cloud Storage
|
|
550
|
+
|
|
551
|
+
fields : typing.Optional[TasksListRequestFields]
|
|
552
|
+
Set to "all" if you want to include annotations and predictions in the response
|
|
553
|
+
|
|
554
|
+
review : typing.Optional[bool]
|
|
555
|
+
Get tasks for review
|
|
556
|
+
|
|
557
|
+
include : typing.Optional[str]
|
|
558
|
+
Specify which fields to include in the response
|
|
559
|
+
|
|
560
|
+
request_options : typing.Optional[RequestOptions]
|
|
561
|
+
Request-specific configuration.
|
|
562
|
+
|
|
563
|
+
Returns
|
|
564
|
+
-------
|
|
565
|
+
AsyncPager[Task]
|
|
566
|
+
List of Tasks
|
|
567
|
+
|
|
568
|
+
Examples
|
|
569
|
+
--------
|
|
570
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
571
|
+
|
|
572
|
+
client = AsyncLabelStudio(
|
|
573
|
+
api_key="YOUR_API_KEY",
|
|
574
|
+
)
|
|
575
|
+
await client.tasks.list()
|
|
576
|
+
"""
|
|
577
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
578
|
+
"api/tasks/",
|
|
579
|
+
method="GET",
|
|
580
|
+
params={
|
|
581
|
+
"page": page,
|
|
582
|
+
"page_size": page_size,
|
|
583
|
+
"view": view,
|
|
584
|
+
"project": project,
|
|
585
|
+
"resolve_uri": resolve_uri,
|
|
586
|
+
"fields": fields,
|
|
587
|
+
"review": review,
|
|
588
|
+
"include": include,
|
|
589
|
+
},
|
|
590
|
+
request_options=request_options,
|
|
591
|
+
)
|
|
592
|
+
if 200 <= _response.status_code < 300:
|
|
593
|
+
_parsed_response = pydantic_v1.parse_obj_as(TasksListResponse, _response.json()) # type: ignore
|
|
594
|
+
_has_next = True
|
|
595
|
+
_get_next = lambda: self.list(
|
|
596
|
+
page=page + 1 if page is not None else 1,
|
|
597
|
+
page_size=page_size,
|
|
598
|
+
view=view,
|
|
599
|
+
project=project,
|
|
600
|
+
resolve_uri=resolve_uri,
|
|
601
|
+
fields=fields,
|
|
602
|
+
review=review,
|
|
603
|
+
include=include,
|
|
604
|
+
request_options=request_options,
|
|
605
|
+
)
|
|
606
|
+
_items = _parsed_response.tasks
|
|
607
|
+
return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next)
|
|
608
|
+
try:
|
|
609
|
+
_response_json = _response.json()
|
|
610
|
+
except JSONDecodeError:
|
|
611
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
612
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
613
|
+
|
|
614
|
+
async def create(
|
|
615
|
+
self,
|
|
616
|
+
*,
|
|
617
|
+
data: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
618
|
+
project: typing.Optional[int] = OMIT,
|
|
619
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
620
|
+
) -> BaseTask:
|
|
621
|
+
"""
|
|
622
|
+
Create a new labeling task in Label Studio.
|
|
623
|
+
|
|
624
|
+
The data you provide depends on your labeling config and data type.
|
|
625
|
+
|
|
626
|
+
You will also need to provide a project ID. The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
627
|
+
|
|
628
|
+
Parameters
|
|
629
|
+
----------
|
|
630
|
+
data : typing.Optional[typing.Dict[str, typing.Any]]
|
|
631
|
+
Task data dictionary with arbitrary keys and values
|
|
632
|
+
|
|
633
|
+
project : typing.Optional[int]
|
|
634
|
+
Project ID
|
|
635
|
+
|
|
636
|
+
request_options : typing.Optional[RequestOptions]
|
|
637
|
+
Request-specific configuration.
|
|
638
|
+
|
|
639
|
+
Returns
|
|
640
|
+
-------
|
|
641
|
+
BaseTask
|
|
642
|
+
Created task
|
|
643
|
+
|
|
644
|
+
Examples
|
|
645
|
+
--------
|
|
646
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
647
|
+
|
|
648
|
+
client = AsyncLabelStudio(
|
|
649
|
+
api_key="YOUR_API_KEY",
|
|
650
|
+
)
|
|
651
|
+
await client.tasks.create(
|
|
652
|
+
data={"image": "https://example.com/image.jpg", "text": "Hello, world!"},
|
|
653
|
+
project=1,
|
|
654
|
+
)
|
|
655
|
+
"""
|
|
656
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
657
|
+
"api/tasks/",
|
|
658
|
+
method="POST",
|
|
659
|
+
json={"data": data, "project": project},
|
|
660
|
+
request_options=request_options,
|
|
661
|
+
omit=OMIT,
|
|
662
|
+
)
|
|
663
|
+
if 200 <= _response.status_code < 300:
|
|
664
|
+
return pydantic_v1.parse_obj_as(BaseTask, _response.json()) # type: ignore
|
|
665
|
+
try:
|
|
666
|
+
_response_json = _response.json()
|
|
667
|
+
except JSONDecodeError:
|
|
668
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
669
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
670
|
+
|
|
671
|
+
async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> BaseTask:
|
|
672
|
+
"""
|
|
673
|
+
Get task data, metadata, annotations and other attributes for a specific labeling task by task ID.
|
|
674
|
+
The task ID is available from the Label Studio URL when viewing the task, or you can retrieve it programmatically with [Get task list](list).
|
|
675
|
+
|
|
676
|
+
Parameters
|
|
677
|
+
----------
|
|
678
|
+
id : str
|
|
679
|
+
Task ID
|
|
680
|
+
|
|
681
|
+
request_options : typing.Optional[RequestOptions]
|
|
682
|
+
Request-specific configuration.
|
|
683
|
+
|
|
684
|
+
Returns
|
|
685
|
+
-------
|
|
686
|
+
BaseTask
|
|
687
|
+
Task
|
|
688
|
+
|
|
689
|
+
Examples
|
|
690
|
+
--------
|
|
691
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
692
|
+
|
|
693
|
+
client = AsyncLabelStudio(
|
|
694
|
+
api_key="YOUR_API_KEY",
|
|
695
|
+
)
|
|
696
|
+
await client.tasks.get(
|
|
697
|
+
id="id",
|
|
698
|
+
)
|
|
699
|
+
"""
|
|
700
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
701
|
+
f"api/tasks/{jsonable_encoder(id)}/", method="GET", request_options=request_options
|
|
702
|
+
)
|
|
703
|
+
if 200 <= _response.status_code < 300:
|
|
704
|
+
return pydantic_v1.parse_obj_as(BaseTask, _response.json()) # type: ignore
|
|
705
|
+
try:
|
|
706
|
+
_response_json = _response.json()
|
|
707
|
+
except JSONDecodeError:
|
|
708
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
709
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
710
|
+
|
|
711
|
+
async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
712
|
+
"""
|
|
713
|
+
Delete a task in Label Studio.
|
|
714
|
+
|
|
715
|
+
You will need the task ID. This is available from the Label Studio URL when viewing the task, or you can retrieve it programmatically with [Get task list](list).
|
|
716
|
+
|
|
717
|
+
<Warning>This action cannot be undone.</Warning>
|
|
718
|
+
|
|
719
|
+
Parameters
|
|
720
|
+
----------
|
|
721
|
+
id : str
|
|
722
|
+
Task ID
|
|
723
|
+
|
|
724
|
+
request_options : typing.Optional[RequestOptions]
|
|
725
|
+
Request-specific configuration.
|
|
726
|
+
|
|
727
|
+
Returns
|
|
728
|
+
-------
|
|
729
|
+
None
|
|
730
|
+
|
|
731
|
+
Examples
|
|
732
|
+
--------
|
|
733
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
734
|
+
|
|
735
|
+
client = AsyncLabelStudio(
|
|
736
|
+
api_key="YOUR_API_KEY",
|
|
737
|
+
)
|
|
738
|
+
await client.tasks.delete(
|
|
739
|
+
id="id",
|
|
740
|
+
)
|
|
741
|
+
"""
|
|
742
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
743
|
+
f"api/tasks/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
|
|
744
|
+
)
|
|
745
|
+
if 200 <= _response.status_code < 300:
|
|
746
|
+
return
|
|
747
|
+
try:
|
|
748
|
+
_response_json = _response.json()
|
|
749
|
+
except JSONDecodeError:
|
|
750
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
751
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
752
|
+
|
|
753
|
+
async def update(
|
|
754
|
+
self,
|
|
755
|
+
id: str,
|
|
756
|
+
*,
|
|
757
|
+
data: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
758
|
+
project: typing.Optional[int] = OMIT,
|
|
759
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
760
|
+
) -> BaseTask:
|
|
761
|
+
"""
|
|
762
|
+
Update the attributes of an existing labeling task.
|
|
763
|
+
|
|
764
|
+
You will need the task ID. This is available from the Label Studio URL when viewing the task, or you can retrieve it programmatically with [Get task list](list).
|
|
765
|
+
|
|
766
|
+
Parameters
|
|
767
|
+
----------
|
|
768
|
+
id : str
|
|
769
|
+
Task ID
|
|
770
|
+
|
|
771
|
+
data : typing.Optional[typing.Dict[str, typing.Any]]
|
|
772
|
+
Task data dictionary with arbitrary keys and values
|
|
773
|
+
|
|
774
|
+
project : typing.Optional[int]
|
|
775
|
+
Project ID
|
|
776
|
+
|
|
777
|
+
request_options : typing.Optional[RequestOptions]
|
|
778
|
+
Request-specific configuration.
|
|
779
|
+
|
|
780
|
+
Returns
|
|
781
|
+
-------
|
|
782
|
+
BaseTask
|
|
783
|
+
Updated task
|
|
784
|
+
|
|
785
|
+
Examples
|
|
786
|
+
--------
|
|
787
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
788
|
+
|
|
789
|
+
client = AsyncLabelStudio(
|
|
790
|
+
api_key="YOUR_API_KEY",
|
|
791
|
+
)
|
|
792
|
+
await client.tasks.update(
|
|
793
|
+
id="id",
|
|
794
|
+
data={"image": "https://example.com/image.jpg", "text": "Hello, world!"},
|
|
795
|
+
project=1,
|
|
796
|
+
)
|
|
797
|
+
"""
|
|
798
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
799
|
+
f"api/tasks/{jsonable_encoder(id)}/",
|
|
800
|
+
method="PATCH",
|
|
801
|
+
json={"data": data, "project": project},
|
|
802
|
+
request_options=request_options,
|
|
803
|
+
omit=OMIT,
|
|
804
|
+
)
|
|
805
|
+
if 200 <= _response.status_code < 300:
|
|
806
|
+
return pydantic_v1.parse_obj_as(BaseTask, _response.json()) # type: ignore
|
|
807
|
+
try:
|
|
808
|
+
_response_json = _response.json()
|
|
809
|
+
except JSONDecodeError:
|
|
810
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
811
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|