label-studio-sdk 1.0.8__py3-none-any.whl → 1.0.10__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.
Potentially problematic release.
This version of label-studio-sdk might be problematic. Click here for more details.
- label_studio_sdk/__init__.py +20 -7
- label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +16 -4
- label_studio_sdk/_extensions/pager_ext.py +8 -0
- label_studio_sdk/actions/client.py +91 -40
- label_studio_sdk/actions/types/actions_create_request_filters.py +14 -24
- label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +16 -26
- label_studio_sdk/actions/types/actions_create_request_filters_items_item_value.py +3 -1
- label_studio_sdk/actions/types/actions_create_request_selected_items.py +1 -2
- label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +15 -25
- label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +15 -25
- label_studio_sdk/annotations/__init__.py +2 -2
- label_studio_sdk/annotations/client.py +278 -104
- label_studio_sdk/annotations/types/__init__.py +2 -1
- label_studio_sdk/annotations/types/annotations_create_bulk_request_selected_items.py +34 -0
- label_studio_sdk/annotations/types/annotations_create_bulk_response_item.py +11 -21
- label_studio_sdk/base_client.py +46 -27
- label_studio_sdk/client.py +1 -0
- label_studio_sdk/comments/client.py +190 -44
- label_studio_sdk/converter/converter.py +56 -13
- label_studio_sdk/converter/imports/yolo.py +1 -1
- label_studio_sdk/converter/utils.py +3 -2
- label_studio_sdk/core/__init__.py +21 -4
- label_studio_sdk/core/client_wrapper.py +9 -10
- label_studio_sdk/core/file.py +37 -8
- label_studio_sdk/core/http_client.py +52 -28
- label_studio_sdk/core/jsonable_encoder.py +33 -31
- label_studio_sdk/core/pagination.py +5 -4
- label_studio_sdk/core/pydantic_utilities.py +272 -4
- label_studio_sdk/core/query_encoder.py +38 -13
- label_studio_sdk/core/request_options.py +3 -0
- label_studio_sdk/core/serialization.py +272 -0
- label_studio_sdk/errors/bad_request_error.py +2 -3
- label_studio_sdk/export_storage/azure/client.py +228 -58
- label_studio_sdk/export_storage/azure/types/azure_create_response.py +19 -29
- label_studio_sdk/export_storage/azure/types/azure_update_response.py +19 -29
- label_studio_sdk/export_storage/client.py +48 -18
- label_studio_sdk/export_storage/gcs/client.py +228 -58
- label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +19 -29
- label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +19 -29
- label_studio_sdk/export_storage/local/client.py +222 -56
- label_studio_sdk/export_storage/local/types/local_create_response.py +17 -27
- label_studio_sdk/export_storage/local/types/local_update_response.py +17 -27
- label_studio_sdk/export_storage/redis/client.py +228 -58
- label_studio_sdk/export_storage/redis/types/redis_create_response.py +20 -30
- label_studio_sdk/export_storage/redis/types/redis_update_response.py +20 -30
- label_studio_sdk/export_storage/s3/client.py +228 -58
- label_studio_sdk/export_storage/s3/types/s3create_response.py +27 -35
- label_studio_sdk/export_storage/s3/types/s3update_response.py +27 -35
- label_studio_sdk/export_storage/s3s/client.py +187 -43
- label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +11 -21
- label_studio_sdk/files/client.py +172 -56
- label_studio_sdk/import_storage/azure/client.py +223 -53
- label_studio_sdk/import_storage/azure/types/azure_create_response.py +22 -32
- label_studio_sdk/import_storage/azure/types/azure_update_response.py +22 -32
- label_studio_sdk/import_storage/client.py +48 -18
- label_studio_sdk/import_storage/gcs/client.py +223 -53
- label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +22 -32
- label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +22 -32
- label_studio_sdk/import_storage/local/client.py +223 -53
- label_studio_sdk/import_storage/local/types/local_create_response.py +17 -27
- label_studio_sdk/import_storage/local/types/local_update_response.py +17 -27
- label_studio_sdk/import_storage/redis/client.py +223 -53
- label_studio_sdk/import_storage/redis/types/redis_create_response.py +20 -30
- label_studio_sdk/import_storage/redis/types/redis_update_response.py +20 -30
- label_studio_sdk/import_storage/s3/client.py +223 -53
- label_studio_sdk/import_storage/s3/types/s3create_response.py +31 -39
- label_studio_sdk/import_storage/s3/types/s3update_response.py +31 -39
- label_studio_sdk/import_storage/s3s/client.py +222 -52
- label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +11 -21
- label_studio_sdk/label_interface/control_tags.py +1 -1
- label_studio_sdk/ml/client.py +280 -78
- label_studio_sdk/ml/types/ml_create_response.py +21 -31
- label_studio_sdk/ml/types/ml_update_response.py +21 -31
- label_studio_sdk/model_providers/client.py +173 -56
- label_studio_sdk/predictions/client.py +247 -101
- label_studio_sdk/projects/__init__.py +3 -0
- label_studio_sdk/projects/client.py +309 -115
- label_studio_sdk/projects/client_ext.py +16 -0
- label_studio_sdk/projects/exports/__init__.py +3 -0
- label_studio_sdk/projects/exports/client.py +447 -296
- label_studio_sdk/projects/exports/client_ext.py +134 -0
- label_studio_sdk/projects/exports/types/__init__.py +6 -0
- label_studio_sdk/projects/exports/types/exports_convert_response.py +24 -0
- label_studio_sdk/projects/exports/types/exports_list_formats_response_item.py +44 -0
- label_studio_sdk/projects/types/projects_create_response.py +29 -34
- label_studio_sdk/projects/types/projects_import_tasks_response.py +19 -29
- label_studio_sdk/projects/types/projects_list_response.py +11 -21
- label_studio_sdk/projects/types/projects_update_response.py +24 -34
- label_studio_sdk/prompts/client.py +309 -92
- label_studio_sdk/prompts/indicators/client.py +67 -23
- label_studio_sdk/prompts/runs/client.py +95 -40
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_request_failed_predictions_item.py +14 -24
- label_studio_sdk/prompts/types/prompts_batch_failed_predictions_response.py +11 -21
- label_studio_sdk/prompts/types/prompts_batch_predictions_request_results_item.py +26 -29
- label_studio_sdk/prompts/types/prompts_batch_predictions_response.py +11 -21
- label_studio_sdk/prompts/versions/client.py +277 -88
- label_studio_sdk/tasks/client.py +263 -90
- label_studio_sdk/tasks/types/tasks_list_response.py +15 -25
- label_studio_sdk/types/__init__.py +10 -6
- label_studio_sdk/types/annotation.py +29 -38
- label_studio_sdk/types/annotation_filter_options.py +14 -24
- label_studio_sdk/types/annotations_dm_field.py +30 -39
- label_studio_sdk/types/azure_blob_export_storage.py +28 -37
- label_studio_sdk/types/azure_blob_import_storage.py +28 -37
- label_studio_sdk/types/base_task.py +30 -39
- label_studio_sdk/types/base_task_updated_by.py +3 -1
- label_studio_sdk/types/base_user.py +14 -21
- label_studio_sdk/types/comment.py +12 -21
- label_studio_sdk/types/comment_created_by.py +1 -1
- label_studio_sdk/types/converted_format.py +12 -22
- label_studio_sdk/types/data_manager_task_serializer.py +31 -40
- label_studio_sdk/types/data_manager_task_serializer_annotators_item.py +1 -1
- label_studio_sdk/types/data_manager_task_serializer_drafts_item.py +13 -22
- label_studio_sdk/types/data_manager_task_serializer_predictions_item.py +15 -24
- label_studio_sdk/types/export.py +17 -26
- label_studio_sdk/types/export_format.py +25 -0
- label_studio_sdk/types/export_snapshot.py +45 -0
- label_studio_sdk/types/export_snapshot_status.py +5 -0
- label_studio_sdk/types/file_upload.py +11 -21
- label_studio_sdk/types/filter.py +16 -26
- label_studio_sdk/types/filter_group.py +12 -22
- label_studio_sdk/types/gcs_export_storage.py +28 -37
- label_studio_sdk/types/gcs_import_storage.py +28 -37
- label_studio_sdk/types/inference_run.py +14 -23
- label_studio_sdk/types/inference_run_cost_estimate.py +17 -27
- label_studio_sdk/types/inference_run_created_by.py +1 -1
- label_studio_sdk/types/inference_run_organization.py +1 -1
- label_studio_sdk/types/key_indicator_value.py +12 -22
- label_studio_sdk/types/key_indicators.py +0 -1
- label_studio_sdk/types/key_indicators_item.py +15 -25
- label_studio_sdk/types/key_indicators_item_additional_kpis_item.py +13 -23
- label_studio_sdk/types/key_indicators_item_extra_kpis_item.py +13 -23
- label_studio_sdk/types/local_files_export_storage.py +25 -34
- label_studio_sdk/types/local_files_import_storage.py +24 -33
- label_studio_sdk/types/ml_backend.py +23 -32
- label_studio_sdk/types/model_provider_connection.py +22 -31
- label_studio_sdk/types/model_provider_connection_created_by.py +1 -1
- label_studio_sdk/types/model_provider_connection_organization.py +1 -1
- label_studio_sdk/types/model_provider_connection_provider.py +3 -1
- label_studio_sdk/types/prediction.py +21 -30
- label_studio_sdk/types/project.py +48 -55
- label_studio_sdk/types/project_import.py +21 -30
- label_studio_sdk/types/project_label_config.py +12 -22
- label_studio_sdk/types/prompt.py +24 -32
- label_studio_sdk/types/prompt_associated_projects_item.py +6 -0
- label_studio_sdk/types/prompt_associated_projects_item_id.py +20 -0
- label_studio_sdk/types/prompt_created_by.py +1 -1
- label_studio_sdk/types/prompt_organization.py +1 -1
- label_studio_sdk/types/prompt_version.py +13 -22
- label_studio_sdk/types/prompt_version_created_by.py +1 -1
- label_studio_sdk/types/prompt_version_organization.py +1 -1
- label_studio_sdk/types/prompt_version_provider.py +3 -1
- label_studio_sdk/types/redis_export_storage.py +29 -38
- label_studio_sdk/types/redis_import_storage.py +28 -37
- label_studio_sdk/types/refined_prompt_response.py +19 -29
- label_studio_sdk/types/s3export_storage.py +36 -43
- label_studio_sdk/types/s3import_storage.py +37 -44
- label_studio_sdk/types/s3s_export_storage.py +26 -33
- label_studio_sdk/types/s3s_import_storage.py +35 -42
- label_studio_sdk/types/serialization_option.py +12 -22
- label_studio_sdk/types/serialization_options.py +18 -28
- label_studio_sdk/types/task.py +44 -47
- label_studio_sdk/types/task_annotators_item.py +1 -1
- label_studio_sdk/types/task_comment_authors_item.py +1 -1
- label_studio_sdk/types/task_filter_options.py +15 -25
- label_studio_sdk/types/user_simple.py +11 -21
- label_studio_sdk/types/view.py +16 -26
- label_studio_sdk/types/webhook.py +19 -28
- label_studio_sdk/types/webhook_serializer_for_update.py +19 -28
- label_studio_sdk/types/workspace.py +22 -31
- label_studio_sdk/users/client.py +257 -63
- label_studio_sdk/users/types/users_get_token_response.py +12 -22
- label_studio_sdk/users/types/users_reset_token_response.py +12 -22
- label_studio_sdk/version.py +0 -1
- label_studio_sdk/versions/__init__.py +5 -0
- label_studio_sdk/versions/client.py +112 -0
- label_studio_sdk/versions/types/__init__.py +6 -0
- label_studio_sdk/versions/types/versions_get_response.py +73 -0
- label_studio_sdk/versions/types/versions_get_response_edition.py +5 -0
- label_studio_sdk/views/client.py +219 -52
- label_studio_sdk/views/types/views_create_request_data.py +13 -23
- label_studio_sdk/views/types/views_create_request_data_filters.py +14 -24
- label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +16 -26
- label_studio_sdk/views/types/views_create_request_data_filters_items_item_value.py +3 -1
- label_studio_sdk/views/types/views_update_request_data.py +13 -23
- label_studio_sdk/views/types/views_update_request_data_filters.py +14 -24
- label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +16 -26
- label_studio_sdk/views/types/views_update_request_data_filters_items_item_value.py +3 -1
- label_studio_sdk/webhooks/client.py +191 -61
- label_studio_sdk/workspaces/client.py +164 -41
- label_studio_sdk/workspaces/members/client.py +109 -31
- label_studio_sdk/workspaces/members/types/members_create_response.py +12 -22
- label_studio_sdk/workspaces/members/types/members_list_response_item.py +12 -22
- {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/METADATA +7 -5
- {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/RECORD +197 -184
- {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/WHEEL +1 -1
- label_studio_sdk/types/export_convert.py +0 -32
- label_studio_sdk/types/export_create.py +0 -54
- label_studio_sdk/types/export_create_status.py +0 -5
- {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/LICENSE +0 -0
label_studio_sdk/tasks/client.py
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
-
from
|
|
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
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
11
5
|
from ..core.request_options import RequestOptions
|
|
12
|
-
from ..types.base_task import BaseTask
|
|
13
|
-
from ..types.data_manager_task_serializer import DataManagerTaskSerializer
|
|
14
6
|
from ..types.project_import import ProjectImport
|
|
15
|
-
from ..
|
|
7
|
+
from ..core.jsonable_encoder import jsonable_encoder
|
|
8
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
9
|
+
from json.decoder import JSONDecodeError
|
|
10
|
+
from ..core.api_error import ApiError
|
|
16
11
|
from .types.tasks_list_request_fields import TasksListRequestFields
|
|
12
|
+
from ..core.pagination import SyncPager
|
|
13
|
+
from ..types.task import Task
|
|
17
14
|
from .types.tasks_list_response import TasksListResponse
|
|
15
|
+
from ..types.base_task import BaseTask
|
|
16
|
+
from ..types.data_manager_task_serializer import DataManagerTaskSerializer
|
|
17
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
18
|
+
from ..core.pagination import AsyncPager
|
|
18
19
|
|
|
19
20
|
# this is used as the default value for optional parameters
|
|
20
21
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -28,6 +29,7 @@ class TasksClient:
|
|
|
28
29
|
self, id: int, import_pk: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
29
30
|
) -> ProjectImport:
|
|
30
31
|
"""
|
|
32
|
+
|
|
31
33
|
Get information about an async project import operation. This can be especially useful to monitor status, as large import jobs can take time.
|
|
32
34
|
|
|
33
35
|
You will need the project ID and the unique ID of the import operation.
|
|
@@ -53,7 +55,7 @@ class TasksClient:
|
|
|
53
55
|
|
|
54
56
|
Examples
|
|
55
57
|
--------
|
|
56
|
-
from label_studio_sdk
|
|
58
|
+
from label_studio_sdk import LabelStudio
|
|
57
59
|
|
|
58
60
|
client = LabelStudio(
|
|
59
61
|
api_key="YOUR_API_KEY",
|
|
@@ -70,7 +72,13 @@ class TasksClient:
|
|
|
70
72
|
)
|
|
71
73
|
try:
|
|
72
74
|
if 200 <= _response.status_code < 300:
|
|
73
|
-
return
|
|
75
|
+
return typing.cast(
|
|
76
|
+
ProjectImport,
|
|
77
|
+
parse_obj_as(
|
|
78
|
+
type_=ProjectImport, # type: ignore
|
|
79
|
+
object_=_response.json(),
|
|
80
|
+
),
|
|
81
|
+
)
|
|
74
82
|
_response_json = _response.json()
|
|
75
83
|
except JSONDecodeError:
|
|
76
84
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -78,6 +86,7 @@ class TasksClient:
|
|
|
78
86
|
|
|
79
87
|
def delete_all_tasks(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
80
88
|
"""
|
|
89
|
+
|
|
81
90
|
Delete all tasks from a specific project.
|
|
82
91
|
|
|
83
92
|
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).
|
|
@@ -96,7 +105,7 @@ class TasksClient:
|
|
|
96
105
|
|
|
97
106
|
Examples
|
|
98
107
|
--------
|
|
99
|
-
from label_studio_sdk
|
|
108
|
+
from label_studio_sdk import LabelStudio
|
|
100
109
|
|
|
101
110
|
client = LabelStudio(
|
|
102
111
|
api_key="YOUR_API_KEY",
|
|
@@ -106,7 +115,9 @@ class TasksClient:
|
|
|
106
115
|
)
|
|
107
116
|
"""
|
|
108
117
|
_response = self._client_wrapper.httpx_client.request(
|
|
109
|
-
f"api/projects/{jsonable_encoder(id)}/tasks/",
|
|
118
|
+
f"api/projects/{jsonable_encoder(id)}/tasks/",
|
|
119
|
+
method="DELETE",
|
|
120
|
+
request_options=request_options,
|
|
110
121
|
)
|
|
111
122
|
try:
|
|
112
123
|
if 200 <= _response.status_code < 300:
|
|
@@ -131,6 +142,7 @@ class TasksClient:
|
|
|
131
142
|
request_options: typing.Optional[RequestOptions] = None,
|
|
132
143
|
) -> SyncPager[Task]:
|
|
133
144
|
"""
|
|
145
|
+
|
|
134
146
|
Retrieve a list of tasks.
|
|
135
147
|
|
|
136
148
|
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.
|
|
@@ -166,10 +178,10 @@ class TasksClient:
|
|
|
166
178
|
query : typing.Optional[str]
|
|
167
179
|
Additional query to filter tasks. It must be JSON encoded string of dict containing one of the following parameters: `{"filters": ..., "selectedItems": ..., "ordering": ...}`. Check [Data Manager > Create View > see `data` field](#tag/Data-Manager/operation/api_dm_views_create) for more details about filters, selectedItems and ordering.
|
|
168
180
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
* **filters**: dict with `"conjunction"` string (`"or"` or `"and"`) and list of filters in `"items"` array. Each filter is a dictionary with keys: `"filter"`, `"operator"`, `"type"`, `"value"`. [Read more about available filters](https://labelstud.io/sdk/data_manager.html)<br/> Example: `{"conjunction": "or", "items": [{"filter": "filter:tasks:completed_at", "operator": "greater", "type": "Datetime", "value": "2021-01-01T00:00:00.000Z"}]}`
|
|
182
|
+
* **selectedItems**: dictionary with keys: `"all"`, `"included"`, `"excluded"`. If "all" is `false`, `"included"` must be used. If "all" is `true`, `"excluded"` must be used.<br/> Examples: `{"all": false, "included": [1, 2, 3]}` or `{"all": true, "excluded": [4, 5]}`
|
|
183
|
+
* **ordering**: list of fields to order by. Currently, ordering is supported by only one parameter. <br/>
|
|
184
|
+
Example: `["completed_at"]`
|
|
173
185
|
|
|
174
186
|
request_options : typing.Optional[RequestOptions]
|
|
175
187
|
Request-specific configuration.
|
|
@@ -181,7 +193,7 @@ class TasksClient:
|
|
|
181
193
|
|
|
182
194
|
Examples
|
|
183
195
|
--------
|
|
184
|
-
from label_studio_sdk
|
|
196
|
+
from label_studio_sdk import LabelStudio
|
|
185
197
|
|
|
186
198
|
client = LabelStudio(
|
|
187
199
|
api_key="YOUR_API_KEY",
|
|
@@ -193,7 +205,7 @@ class TasksClient:
|
|
|
193
205
|
for page in response.iter_pages():
|
|
194
206
|
yield page
|
|
195
207
|
"""
|
|
196
|
-
page = page
|
|
208
|
+
page = page if page is not None else 1
|
|
197
209
|
_response = self._client_wrapper.httpx_client.request(
|
|
198
210
|
"api/tasks/",
|
|
199
211
|
method="GET",
|
|
@@ -212,7 +224,13 @@ class TasksClient:
|
|
|
212
224
|
)
|
|
213
225
|
try:
|
|
214
226
|
if 200 <= _response.status_code < 300:
|
|
215
|
-
_parsed_response =
|
|
227
|
+
_parsed_response = typing.cast(
|
|
228
|
+
TasksListResponse,
|
|
229
|
+
parse_obj_as(
|
|
230
|
+
type_=TasksListResponse, # type: ignore
|
|
231
|
+
object_=_response.json(),
|
|
232
|
+
),
|
|
233
|
+
)
|
|
216
234
|
_has_next = True
|
|
217
235
|
_get_next = lambda: self.list(
|
|
218
236
|
page=page + 1,
|
|
@@ -236,11 +254,12 @@ class TasksClient:
|
|
|
236
254
|
def create(
|
|
237
255
|
self,
|
|
238
256
|
*,
|
|
239
|
-
data: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
257
|
+
data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
240
258
|
project: typing.Optional[int] = OMIT,
|
|
241
259
|
request_options: typing.Optional[RequestOptions] = None,
|
|
242
260
|
) -> BaseTask:
|
|
243
261
|
"""
|
|
262
|
+
|
|
244
263
|
Create a new labeling task in Label Studio.
|
|
245
264
|
|
|
246
265
|
The data you provide depends on your labeling config and data type.
|
|
@@ -249,7 +268,7 @@ class TasksClient:
|
|
|
249
268
|
|
|
250
269
|
Parameters
|
|
251
270
|
----------
|
|
252
|
-
data : typing.Optional[typing.Dict[str, typing.Any]]
|
|
271
|
+
data : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
253
272
|
Task data dictionary with arbitrary keys and values
|
|
254
273
|
|
|
255
274
|
project : typing.Optional[int]
|
|
@@ -265,7 +284,7 @@ class TasksClient:
|
|
|
265
284
|
|
|
266
285
|
Examples
|
|
267
286
|
--------
|
|
268
|
-
from label_studio_sdk
|
|
287
|
+
from label_studio_sdk import LabelStudio
|
|
269
288
|
|
|
270
289
|
client = LabelStudio(
|
|
271
290
|
api_key="YOUR_API_KEY",
|
|
@@ -278,13 +297,25 @@ class TasksClient:
|
|
|
278
297
|
_response = self._client_wrapper.httpx_client.request(
|
|
279
298
|
"api/tasks/",
|
|
280
299
|
method="POST",
|
|
281
|
-
json={
|
|
300
|
+
json={
|
|
301
|
+
"data": data,
|
|
302
|
+
"project": project,
|
|
303
|
+
},
|
|
304
|
+
headers={
|
|
305
|
+
"content-type": "application/json",
|
|
306
|
+
},
|
|
282
307
|
request_options=request_options,
|
|
283
308
|
omit=OMIT,
|
|
284
309
|
)
|
|
285
310
|
try:
|
|
286
311
|
if 200 <= _response.status_code < 300:
|
|
287
|
-
return
|
|
312
|
+
return typing.cast(
|
|
313
|
+
BaseTask,
|
|
314
|
+
parse_obj_as(
|
|
315
|
+
type_=BaseTask, # type: ignore
|
|
316
|
+
object_=_response.json(),
|
|
317
|
+
),
|
|
318
|
+
)
|
|
288
319
|
_response_json = _response.json()
|
|
289
320
|
except JSONDecodeError:
|
|
290
321
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -292,6 +323,7 @@ class TasksClient:
|
|
|
292
323
|
|
|
293
324
|
def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> DataManagerTaskSerializer:
|
|
294
325
|
"""
|
|
326
|
+
|
|
295
327
|
Get task data, metadata, annotations and other attributes for a specific labeling task by task ID.
|
|
296
328
|
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).
|
|
297
329
|
|
|
@@ -310,7 +342,7 @@ class TasksClient:
|
|
|
310
342
|
|
|
311
343
|
Examples
|
|
312
344
|
--------
|
|
313
|
-
from label_studio_sdk
|
|
345
|
+
from label_studio_sdk import LabelStudio
|
|
314
346
|
|
|
315
347
|
client = LabelStudio(
|
|
316
348
|
api_key="YOUR_API_KEY",
|
|
@@ -320,11 +352,19 @@ class TasksClient:
|
|
|
320
352
|
)
|
|
321
353
|
"""
|
|
322
354
|
_response = self._client_wrapper.httpx_client.request(
|
|
323
|
-
f"api/tasks/{jsonable_encoder(id)}/",
|
|
355
|
+
f"api/tasks/{jsonable_encoder(id)}/",
|
|
356
|
+
method="GET",
|
|
357
|
+
request_options=request_options,
|
|
324
358
|
)
|
|
325
359
|
try:
|
|
326
360
|
if 200 <= _response.status_code < 300:
|
|
327
|
-
return
|
|
361
|
+
return typing.cast(
|
|
362
|
+
DataManagerTaskSerializer,
|
|
363
|
+
parse_obj_as(
|
|
364
|
+
type_=DataManagerTaskSerializer, # type: ignore
|
|
365
|
+
object_=_response.json(),
|
|
366
|
+
),
|
|
367
|
+
)
|
|
328
368
|
_response_json = _response.json()
|
|
329
369
|
except JSONDecodeError:
|
|
330
370
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -332,6 +372,7 @@ class TasksClient:
|
|
|
332
372
|
|
|
333
373
|
def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
334
374
|
"""
|
|
375
|
+
|
|
335
376
|
Delete a task in Label Studio.
|
|
336
377
|
|
|
337
378
|
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).
|
|
@@ -352,7 +393,7 @@ class TasksClient:
|
|
|
352
393
|
|
|
353
394
|
Examples
|
|
354
395
|
--------
|
|
355
|
-
from label_studio_sdk
|
|
396
|
+
from label_studio_sdk import LabelStudio
|
|
356
397
|
|
|
357
398
|
client = LabelStudio(
|
|
358
399
|
api_key="YOUR_API_KEY",
|
|
@@ -362,7 +403,9 @@ class TasksClient:
|
|
|
362
403
|
)
|
|
363
404
|
"""
|
|
364
405
|
_response = self._client_wrapper.httpx_client.request(
|
|
365
|
-
f"api/tasks/{jsonable_encoder(id)}/",
|
|
406
|
+
f"api/tasks/{jsonable_encoder(id)}/",
|
|
407
|
+
method="DELETE",
|
|
408
|
+
request_options=request_options,
|
|
366
409
|
)
|
|
367
410
|
try:
|
|
368
411
|
if 200 <= _response.status_code < 300:
|
|
@@ -376,11 +419,12 @@ class TasksClient:
|
|
|
376
419
|
self,
|
|
377
420
|
id: str,
|
|
378
421
|
*,
|
|
379
|
-
data: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
422
|
+
data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
380
423
|
project: typing.Optional[int] = OMIT,
|
|
381
424
|
request_options: typing.Optional[RequestOptions] = None,
|
|
382
425
|
) -> BaseTask:
|
|
383
426
|
"""
|
|
427
|
+
|
|
384
428
|
Update the attributes of an existing labeling task.
|
|
385
429
|
|
|
386
430
|
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).
|
|
@@ -390,7 +434,7 @@ class TasksClient:
|
|
|
390
434
|
id : str
|
|
391
435
|
Task ID
|
|
392
436
|
|
|
393
|
-
data : typing.Optional[typing.Dict[str, typing.Any]]
|
|
437
|
+
data : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
394
438
|
Task data dictionary with arbitrary keys and values
|
|
395
439
|
|
|
396
440
|
project : typing.Optional[int]
|
|
@@ -406,7 +450,7 @@ class TasksClient:
|
|
|
406
450
|
|
|
407
451
|
Examples
|
|
408
452
|
--------
|
|
409
|
-
from label_studio_sdk
|
|
453
|
+
from label_studio_sdk import LabelStudio
|
|
410
454
|
|
|
411
455
|
client = LabelStudio(
|
|
412
456
|
api_key="YOUR_API_KEY",
|
|
@@ -420,13 +464,25 @@ class TasksClient:
|
|
|
420
464
|
_response = self._client_wrapper.httpx_client.request(
|
|
421
465
|
f"api/tasks/{jsonable_encoder(id)}/",
|
|
422
466
|
method="PATCH",
|
|
423
|
-
json={
|
|
467
|
+
json={
|
|
468
|
+
"data": data,
|
|
469
|
+
"project": project,
|
|
470
|
+
},
|
|
471
|
+
headers={
|
|
472
|
+
"content-type": "application/json",
|
|
473
|
+
},
|
|
424
474
|
request_options=request_options,
|
|
425
475
|
omit=OMIT,
|
|
426
476
|
)
|
|
427
477
|
try:
|
|
428
478
|
if 200 <= _response.status_code < 300:
|
|
429
|
-
return
|
|
479
|
+
return typing.cast(
|
|
480
|
+
BaseTask,
|
|
481
|
+
parse_obj_as(
|
|
482
|
+
type_=BaseTask, # type: ignore
|
|
483
|
+
object_=_response.json(),
|
|
484
|
+
),
|
|
485
|
+
)
|
|
430
486
|
_response_json = _response.json()
|
|
431
487
|
except JSONDecodeError:
|
|
432
488
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -441,6 +497,7 @@ class AsyncTasksClient:
|
|
|
441
497
|
self, id: int, import_pk: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
442
498
|
) -> ProjectImport:
|
|
443
499
|
"""
|
|
500
|
+
|
|
444
501
|
Get information about an async project import operation. This can be especially useful to monitor status, as large import jobs can take time.
|
|
445
502
|
|
|
446
503
|
You will need the project ID and the unique ID of the import operation.
|
|
@@ -466,15 +523,23 @@ class AsyncTasksClient:
|
|
|
466
523
|
|
|
467
524
|
Examples
|
|
468
525
|
--------
|
|
469
|
-
|
|
526
|
+
import asyncio
|
|
527
|
+
|
|
528
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
470
529
|
|
|
471
530
|
client = AsyncLabelStudio(
|
|
472
531
|
api_key="YOUR_API_KEY",
|
|
473
532
|
)
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
async def main() -> None:
|
|
536
|
+
await client.tasks.create_many_status(
|
|
537
|
+
id=1,
|
|
538
|
+
import_pk="import_pk",
|
|
539
|
+
)
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
asyncio.run(main())
|
|
478
543
|
"""
|
|
479
544
|
_response = await self._client_wrapper.httpx_client.request(
|
|
480
545
|
f"api/projects/{jsonable_encoder(id)}/imports/{jsonable_encoder(import_pk)}/",
|
|
@@ -483,7 +548,13 @@ class AsyncTasksClient:
|
|
|
483
548
|
)
|
|
484
549
|
try:
|
|
485
550
|
if 200 <= _response.status_code < 300:
|
|
486
|
-
return
|
|
551
|
+
return typing.cast(
|
|
552
|
+
ProjectImport,
|
|
553
|
+
parse_obj_as(
|
|
554
|
+
type_=ProjectImport, # type: ignore
|
|
555
|
+
object_=_response.json(),
|
|
556
|
+
),
|
|
557
|
+
)
|
|
487
558
|
_response_json = _response.json()
|
|
488
559
|
except JSONDecodeError:
|
|
489
560
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -491,6 +562,7 @@ class AsyncTasksClient:
|
|
|
491
562
|
|
|
492
563
|
async def delete_all_tasks(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
493
564
|
"""
|
|
565
|
+
|
|
494
566
|
Delete all tasks from a specific project.
|
|
495
567
|
|
|
496
568
|
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).
|
|
@@ -509,17 +581,27 @@ class AsyncTasksClient:
|
|
|
509
581
|
|
|
510
582
|
Examples
|
|
511
583
|
--------
|
|
512
|
-
|
|
584
|
+
import asyncio
|
|
585
|
+
|
|
586
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
513
587
|
|
|
514
588
|
client = AsyncLabelStudio(
|
|
515
589
|
api_key="YOUR_API_KEY",
|
|
516
590
|
)
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
)
|
|
591
|
+
|
|
592
|
+
|
|
593
|
+
async def main() -> None:
|
|
594
|
+
await client.tasks.delete_all_tasks(
|
|
595
|
+
id=1,
|
|
596
|
+
)
|
|
597
|
+
|
|
598
|
+
|
|
599
|
+
asyncio.run(main())
|
|
520
600
|
"""
|
|
521
601
|
_response = await self._client_wrapper.httpx_client.request(
|
|
522
|
-
f"api/projects/{jsonable_encoder(id)}/tasks/",
|
|
602
|
+
f"api/projects/{jsonable_encoder(id)}/tasks/",
|
|
603
|
+
method="DELETE",
|
|
604
|
+
request_options=request_options,
|
|
523
605
|
)
|
|
524
606
|
try:
|
|
525
607
|
if 200 <= _response.status_code < 300:
|
|
@@ -544,6 +626,7 @@ class AsyncTasksClient:
|
|
|
544
626
|
request_options: typing.Optional[RequestOptions] = None,
|
|
545
627
|
) -> AsyncPager[Task]:
|
|
546
628
|
"""
|
|
629
|
+
|
|
547
630
|
Retrieve a list of tasks.
|
|
548
631
|
|
|
549
632
|
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.
|
|
@@ -579,10 +662,10 @@ class AsyncTasksClient:
|
|
|
579
662
|
query : typing.Optional[str]
|
|
580
663
|
Additional query to filter tasks. It must be JSON encoded string of dict containing one of the following parameters: `{"filters": ..., "selectedItems": ..., "ordering": ...}`. Check [Data Manager > Create View > see `data` field](#tag/Data-Manager/operation/api_dm_views_create) for more details about filters, selectedItems and ordering.
|
|
581
664
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
665
|
+
* **filters**: dict with `"conjunction"` string (`"or"` or `"and"`) and list of filters in `"items"` array. Each filter is a dictionary with keys: `"filter"`, `"operator"`, `"type"`, `"value"`. [Read more about available filters](https://labelstud.io/sdk/data_manager.html)<br/> Example: `{"conjunction": "or", "items": [{"filter": "filter:tasks:completed_at", "operator": "greater", "type": "Datetime", "value": "2021-01-01T00:00:00.000Z"}]}`
|
|
666
|
+
* **selectedItems**: dictionary with keys: `"all"`, `"included"`, `"excluded"`. If "all" is `false`, `"included"` must be used. If "all" is `true`, `"excluded"` must be used.<br/> Examples: `{"all": false, "included": [1, 2, 3]}` or `{"all": true, "excluded": [4, 5]}`
|
|
667
|
+
* **ordering**: list of fields to order by. Currently, ordering is supported by only one parameter. <br/>
|
|
668
|
+
Example: `["completed_at"]`
|
|
586
669
|
|
|
587
670
|
request_options : typing.Optional[RequestOptions]
|
|
588
671
|
Request-specific configuration.
|
|
@@ -594,19 +677,27 @@ class AsyncTasksClient:
|
|
|
594
677
|
|
|
595
678
|
Examples
|
|
596
679
|
--------
|
|
597
|
-
|
|
680
|
+
import asyncio
|
|
681
|
+
|
|
682
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
598
683
|
|
|
599
684
|
client = AsyncLabelStudio(
|
|
600
685
|
api_key="YOUR_API_KEY",
|
|
601
686
|
)
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
async def main() -> None:
|
|
690
|
+
response = await client.tasks.list()
|
|
691
|
+
async for item in response:
|
|
692
|
+
yield item
|
|
693
|
+
# alternatively, you can paginate page-by-page
|
|
694
|
+
async for page in response.iter_pages():
|
|
695
|
+
yield page
|
|
696
|
+
|
|
697
|
+
|
|
698
|
+
asyncio.run(main())
|
|
608
699
|
"""
|
|
609
|
-
page = page
|
|
700
|
+
page = page if page is not None else 1
|
|
610
701
|
_response = await self._client_wrapper.httpx_client.request(
|
|
611
702
|
"api/tasks/",
|
|
612
703
|
method="GET",
|
|
@@ -625,7 +716,13 @@ class AsyncTasksClient:
|
|
|
625
716
|
)
|
|
626
717
|
try:
|
|
627
718
|
if 200 <= _response.status_code < 300:
|
|
628
|
-
_parsed_response =
|
|
719
|
+
_parsed_response = typing.cast(
|
|
720
|
+
TasksListResponse,
|
|
721
|
+
parse_obj_as(
|
|
722
|
+
type_=TasksListResponse, # type: ignore
|
|
723
|
+
object_=_response.json(),
|
|
724
|
+
),
|
|
725
|
+
)
|
|
629
726
|
_has_next = True
|
|
630
727
|
_get_next = lambda: self.list(
|
|
631
728
|
page=page + 1,
|
|
@@ -649,11 +746,12 @@ class AsyncTasksClient:
|
|
|
649
746
|
async def create(
|
|
650
747
|
self,
|
|
651
748
|
*,
|
|
652
|
-
data: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
749
|
+
data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
653
750
|
project: typing.Optional[int] = OMIT,
|
|
654
751
|
request_options: typing.Optional[RequestOptions] = None,
|
|
655
752
|
) -> BaseTask:
|
|
656
753
|
"""
|
|
754
|
+
|
|
657
755
|
Create a new labeling task in Label Studio.
|
|
658
756
|
|
|
659
757
|
The data you provide depends on your labeling config and data type.
|
|
@@ -662,7 +760,7 @@ class AsyncTasksClient:
|
|
|
662
760
|
|
|
663
761
|
Parameters
|
|
664
762
|
----------
|
|
665
|
-
data : typing.Optional[typing.Dict[str, typing.Any]]
|
|
763
|
+
data : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
666
764
|
Task data dictionary with arbitrary keys and values
|
|
667
765
|
|
|
668
766
|
project : typing.Optional[int]
|
|
@@ -678,26 +776,49 @@ class AsyncTasksClient:
|
|
|
678
776
|
|
|
679
777
|
Examples
|
|
680
778
|
--------
|
|
681
|
-
|
|
779
|
+
import asyncio
|
|
780
|
+
|
|
781
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
682
782
|
|
|
683
783
|
client = AsyncLabelStudio(
|
|
684
784
|
api_key="YOUR_API_KEY",
|
|
685
785
|
)
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
786
|
+
|
|
787
|
+
|
|
788
|
+
async def main() -> None:
|
|
789
|
+
await client.tasks.create(
|
|
790
|
+
data={
|
|
791
|
+
"image": "https://example.com/image.jpg",
|
|
792
|
+
"text": "Hello, world!",
|
|
793
|
+
},
|
|
794
|
+
project=1,
|
|
795
|
+
)
|
|
796
|
+
|
|
797
|
+
|
|
798
|
+
asyncio.run(main())
|
|
690
799
|
"""
|
|
691
800
|
_response = await self._client_wrapper.httpx_client.request(
|
|
692
801
|
"api/tasks/",
|
|
693
802
|
method="POST",
|
|
694
|
-
json={
|
|
803
|
+
json={
|
|
804
|
+
"data": data,
|
|
805
|
+
"project": project,
|
|
806
|
+
},
|
|
807
|
+
headers={
|
|
808
|
+
"content-type": "application/json",
|
|
809
|
+
},
|
|
695
810
|
request_options=request_options,
|
|
696
811
|
omit=OMIT,
|
|
697
812
|
)
|
|
698
813
|
try:
|
|
699
814
|
if 200 <= _response.status_code < 300:
|
|
700
|
-
return
|
|
815
|
+
return typing.cast(
|
|
816
|
+
BaseTask,
|
|
817
|
+
parse_obj_as(
|
|
818
|
+
type_=BaseTask, # type: ignore
|
|
819
|
+
object_=_response.json(),
|
|
820
|
+
),
|
|
821
|
+
)
|
|
701
822
|
_response_json = _response.json()
|
|
702
823
|
except JSONDecodeError:
|
|
703
824
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -707,6 +828,7 @@ class AsyncTasksClient:
|
|
|
707
828
|
self, id: str, *, request_options: typing.Optional[RequestOptions] = None
|
|
708
829
|
) -> DataManagerTaskSerializer:
|
|
709
830
|
"""
|
|
831
|
+
|
|
710
832
|
Get task data, metadata, annotations and other attributes for a specific labeling task by task ID.
|
|
711
833
|
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).
|
|
712
834
|
|
|
@@ -725,21 +847,37 @@ class AsyncTasksClient:
|
|
|
725
847
|
|
|
726
848
|
Examples
|
|
727
849
|
--------
|
|
728
|
-
|
|
850
|
+
import asyncio
|
|
851
|
+
|
|
852
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
729
853
|
|
|
730
854
|
client = AsyncLabelStudio(
|
|
731
855
|
api_key="YOUR_API_KEY",
|
|
732
856
|
)
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
)
|
|
857
|
+
|
|
858
|
+
|
|
859
|
+
async def main() -> None:
|
|
860
|
+
await client.tasks.get(
|
|
861
|
+
id="id",
|
|
862
|
+
)
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
asyncio.run(main())
|
|
736
866
|
"""
|
|
737
867
|
_response = await self._client_wrapper.httpx_client.request(
|
|
738
|
-
f"api/tasks/{jsonable_encoder(id)}/",
|
|
868
|
+
f"api/tasks/{jsonable_encoder(id)}/",
|
|
869
|
+
method="GET",
|
|
870
|
+
request_options=request_options,
|
|
739
871
|
)
|
|
740
872
|
try:
|
|
741
873
|
if 200 <= _response.status_code < 300:
|
|
742
|
-
return
|
|
874
|
+
return typing.cast(
|
|
875
|
+
DataManagerTaskSerializer,
|
|
876
|
+
parse_obj_as(
|
|
877
|
+
type_=DataManagerTaskSerializer, # type: ignore
|
|
878
|
+
object_=_response.json(),
|
|
879
|
+
),
|
|
880
|
+
)
|
|
743
881
|
_response_json = _response.json()
|
|
744
882
|
except JSONDecodeError:
|
|
745
883
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -747,6 +885,7 @@ class AsyncTasksClient:
|
|
|
747
885
|
|
|
748
886
|
async def delete(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
749
887
|
"""
|
|
888
|
+
|
|
750
889
|
Delete a task in Label Studio.
|
|
751
890
|
|
|
752
891
|
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).
|
|
@@ -767,17 +906,27 @@ class AsyncTasksClient:
|
|
|
767
906
|
|
|
768
907
|
Examples
|
|
769
908
|
--------
|
|
770
|
-
|
|
909
|
+
import asyncio
|
|
910
|
+
|
|
911
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
771
912
|
|
|
772
913
|
client = AsyncLabelStudio(
|
|
773
914
|
api_key="YOUR_API_KEY",
|
|
774
915
|
)
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
)
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
async def main() -> None:
|
|
919
|
+
await client.tasks.delete(
|
|
920
|
+
id="id",
|
|
921
|
+
)
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
asyncio.run(main())
|
|
778
925
|
"""
|
|
779
926
|
_response = await self._client_wrapper.httpx_client.request(
|
|
780
|
-
f"api/tasks/{jsonable_encoder(id)}/",
|
|
927
|
+
f"api/tasks/{jsonable_encoder(id)}/",
|
|
928
|
+
method="DELETE",
|
|
929
|
+
request_options=request_options,
|
|
781
930
|
)
|
|
782
931
|
try:
|
|
783
932
|
if 200 <= _response.status_code < 300:
|
|
@@ -791,11 +940,12 @@ class AsyncTasksClient:
|
|
|
791
940
|
self,
|
|
792
941
|
id: str,
|
|
793
942
|
*,
|
|
794
|
-
data: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
943
|
+
data: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
795
944
|
project: typing.Optional[int] = OMIT,
|
|
796
945
|
request_options: typing.Optional[RequestOptions] = None,
|
|
797
946
|
) -> BaseTask:
|
|
798
947
|
"""
|
|
948
|
+
|
|
799
949
|
Update the attributes of an existing labeling task.
|
|
800
950
|
|
|
801
951
|
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).
|
|
@@ -805,7 +955,7 @@ class AsyncTasksClient:
|
|
|
805
955
|
id : str
|
|
806
956
|
Task ID
|
|
807
957
|
|
|
808
|
-
data : typing.Optional[typing.Dict[str, typing.Any]]
|
|
958
|
+
data : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
809
959
|
Task data dictionary with arbitrary keys and values
|
|
810
960
|
|
|
811
961
|
project : typing.Optional[int]
|
|
@@ -821,27 +971,50 @@ class AsyncTasksClient:
|
|
|
821
971
|
|
|
822
972
|
Examples
|
|
823
973
|
--------
|
|
824
|
-
|
|
974
|
+
import asyncio
|
|
975
|
+
|
|
976
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
825
977
|
|
|
826
978
|
client = AsyncLabelStudio(
|
|
827
979
|
api_key="YOUR_API_KEY",
|
|
828
980
|
)
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
981
|
+
|
|
982
|
+
|
|
983
|
+
async def main() -> None:
|
|
984
|
+
await client.tasks.update(
|
|
985
|
+
id="id",
|
|
986
|
+
data={
|
|
987
|
+
"image": "https://example.com/image.jpg",
|
|
988
|
+
"text": "Hello, world!",
|
|
989
|
+
},
|
|
990
|
+
project=1,
|
|
991
|
+
)
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
asyncio.run(main())
|
|
834
995
|
"""
|
|
835
996
|
_response = await self._client_wrapper.httpx_client.request(
|
|
836
997
|
f"api/tasks/{jsonable_encoder(id)}/",
|
|
837
998
|
method="PATCH",
|
|
838
|
-
json={
|
|
999
|
+
json={
|
|
1000
|
+
"data": data,
|
|
1001
|
+
"project": project,
|
|
1002
|
+
},
|
|
1003
|
+
headers={
|
|
1004
|
+
"content-type": "application/json",
|
|
1005
|
+
},
|
|
839
1006
|
request_options=request_options,
|
|
840
1007
|
omit=OMIT,
|
|
841
1008
|
)
|
|
842
1009
|
try:
|
|
843
1010
|
if 200 <= _response.status_code < 300:
|
|
844
|
-
return
|
|
1011
|
+
return typing.cast(
|
|
1012
|
+
BaseTask,
|
|
1013
|
+
parse_obj_as(
|
|
1014
|
+
type_=BaseTask, # type: ignore
|
|
1015
|
+
object_=_response.json(),
|
|
1016
|
+
),
|
|
1017
|
+
)
|
|
845
1018
|
_response_json = _response.json()
|
|
846
1019
|
except JSONDecodeError:
|
|
847
1020
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|