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
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
import typing
|
|
4
|
+
from ..core.client_wrapper import SyncClientWrapper
|
|
5
|
+
from .exports.client import ExportsClient
|
|
6
|
+
from ..core.request_options import RequestOptions
|
|
7
|
+
from ..core.pagination import SyncPager
|
|
8
|
+
from ..types.project import Project
|
|
9
|
+
from .types.projects_list_response import ProjectsListResponse
|
|
10
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
4
11
|
from json.decoder import JSONDecodeError
|
|
5
|
-
|
|
6
12
|
from ..core.api_error import ApiError
|
|
7
|
-
from
|
|
13
|
+
from .types.projects_create_response import ProjectsCreateResponse
|
|
8
14
|
from ..core.jsonable_encoder import jsonable_encoder
|
|
9
|
-
from
|
|
10
|
-
from
|
|
11
|
-
from ..core.request_options import RequestOptions
|
|
15
|
+
from .types.projects_update_response import ProjectsUpdateResponse
|
|
16
|
+
from .types.projects_import_tasks_response import ProjectsImportTasksResponse
|
|
12
17
|
from ..errors.bad_request_error import BadRequestError
|
|
13
|
-
from ..types.project import Project
|
|
14
18
|
from ..types.project_label_config import ProjectLabelConfig
|
|
15
|
-
from .
|
|
16
|
-
from .
|
|
17
|
-
from .
|
|
18
|
-
from .types.projects_list_response import ProjectsListResponse
|
|
19
|
-
from .types.projects_update_response import ProjectsUpdateResponse
|
|
19
|
+
from ..core.client_wrapper import AsyncClientWrapper
|
|
20
|
+
from .exports.client import AsyncExportsClient
|
|
21
|
+
from ..core.pagination import AsyncPager
|
|
20
22
|
|
|
21
23
|
# this is used as the default value for optional parameters
|
|
22
24
|
OMIT = typing.cast(typing.Any, ...)
|
|
@@ -35,16 +37,17 @@ class ProjectsClient:
|
|
|
35
37
|
title: typing.Optional[str] = None,
|
|
36
38
|
page: typing.Optional[int] = None,
|
|
37
39
|
page_size: typing.Optional[int] = None,
|
|
40
|
+
workspaces: typing.Optional[int] = None,
|
|
38
41
|
request_options: typing.Optional[RequestOptions] = None,
|
|
39
42
|
) -> SyncPager[Project]:
|
|
40
43
|
"""
|
|
44
|
+
|
|
41
45
|
Return a list of the projects within your organization.
|
|
42
46
|
|
|
43
47
|
To perform most tasks with the Label Studio API, you must specify the project ID, sometimes referred to as the `pk`. The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using this API call.
|
|
44
48
|
|
|
45
49
|
To retrieve a list of your Label Studio projects, update the following command to match your own environment.
|
|
46
50
|
Replace the domain name, port, and authorization token, then run the following from the command line:
|
|
47
|
-
|
|
48
51
|
```bash
|
|
49
52
|
curl -X GET https://localhost:8080/api/projects/ -H 'Authorization: Token abc123'
|
|
50
53
|
```
|
|
@@ -66,6 +69,9 @@ class ProjectsClient:
|
|
|
66
69
|
page_size : typing.Optional[int]
|
|
67
70
|
Number of results to return per page.
|
|
68
71
|
|
|
72
|
+
workspaces : typing.Optional[int]
|
|
73
|
+
workspaces
|
|
74
|
+
|
|
69
75
|
request_options : typing.Optional[RequestOptions]
|
|
70
76
|
Request-specific configuration.
|
|
71
77
|
|
|
@@ -76,7 +82,7 @@ class ProjectsClient:
|
|
|
76
82
|
|
|
77
83
|
Examples
|
|
78
84
|
--------
|
|
79
|
-
from label_studio_sdk
|
|
85
|
+
from label_studio_sdk import LabelStudio
|
|
80
86
|
|
|
81
87
|
client = LabelStudio(
|
|
82
88
|
api_key="YOUR_API_KEY",
|
|
@@ -88,16 +94,29 @@ class ProjectsClient:
|
|
|
88
94
|
for page in response.iter_pages():
|
|
89
95
|
yield page
|
|
90
96
|
"""
|
|
91
|
-
page = page
|
|
97
|
+
page = page if page is not None else 1
|
|
92
98
|
_response = self._client_wrapper.httpx_client.request(
|
|
93
99
|
"api/projects/",
|
|
94
100
|
method="GET",
|
|
95
|
-
params={
|
|
101
|
+
params={
|
|
102
|
+
"ordering": ordering,
|
|
103
|
+
"ids": ids,
|
|
104
|
+
"title": title,
|
|
105
|
+
"page": page,
|
|
106
|
+
"page_size": page_size,
|
|
107
|
+
"workspaces": workspaces,
|
|
108
|
+
},
|
|
96
109
|
request_options=request_options,
|
|
97
110
|
)
|
|
98
111
|
try:
|
|
99
112
|
if 200 <= _response.status_code < 300:
|
|
100
|
-
_parsed_response =
|
|
113
|
+
_parsed_response = typing.cast(
|
|
114
|
+
ProjectsListResponse,
|
|
115
|
+
parse_obj_as(
|
|
116
|
+
type_=ProjectsListResponse, # type: ignore
|
|
117
|
+
object_=_response.json(),
|
|
118
|
+
),
|
|
119
|
+
)
|
|
101
120
|
_has_next = True
|
|
102
121
|
_get_next = lambda: self.list(
|
|
103
122
|
ordering=ordering,
|
|
@@ -105,6 +124,7 @@ class ProjectsClient:
|
|
|
105
124
|
title=title,
|
|
106
125
|
page=page + 1,
|
|
107
126
|
page_size=page_size,
|
|
127
|
+
workspaces=workspaces,
|
|
108
128
|
request_options=request_options,
|
|
109
129
|
)
|
|
110
130
|
_items = _parsed_response.results
|
|
@@ -129,17 +149,17 @@ class ProjectsClient:
|
|
|
129
149
|
show_collab_predictions: typing.Optional[bool] = OMIT,
|
|
130
150
|
maximum_annotations: typing.Optional[int] = OMIT,
|
|
131
151
|
color: typing.Optional[str] = OMIT,
|
|
132
|
-
control_weights: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
152
|
+
control_weights: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
133
153
|
workspace: typing.Optional[int] = OMIT,
|
|
134
154
|
model_version: typing.Optional[str] = OMIT,
|
|
135
155
|
request_options: typing.Optional[RequestOptions] = None,
|
|
136
156
|
) -> ProjectsCreateResponse:
|
|
137
157
|
"""
|
|
138
|
-
Create a project and set up the labeling interface. For more information about setting up projects, see the following:
|
|
139
158
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
159
|
+
Create a project and set up the labeling interface. For more information about setting up projects, see the following:
|
|
160
|
+
* [Create and configure projects](https://labelstud.io/guide/setup_project)
|
|
161
|
+
* [Configure labeling interface](https://labelstud.io/guide/setup)
|
|
162
|
+
* [Project settings](https://labelstud.io/guide/project_settings)
|
|
143
163
|
|
|
144
164
|
```bash
|
|
145
165
|
curl -H Content-Type:application/json -H 'Authorization: Token abc123' -X POST 'https://localhost:8080/api/projects' --data '{"label_config": "<View>[...]</View>"}'
|
|
@@ -183,7 +203,7 @@ class ProjectsClient:
|
|
|
183
203
|
color : typing.Optional[str]
|
|
184
204
|
Project color in HEX format
|
|
185
205
|
|
|
186
|
-
control_weights : typing.Optional[typing.Dict[str, typing.Any]]
|
|
206
|
+
control_weights : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
187
207
|
Dict of weights for each control tag in metric calculation. Each control tag (e.g. label or choice) will have its own key in control weight dict with weight for each label and overall weight. For example, if a bounding box annotation with a control tag named my_bbox should be included with 0.33 weight in agreement calculation, and the first label Car should be twice as important as Airplane, then you need to specify: {'my_bbox': {'type': 'RectangleLabels', 'labels': {'Car': 1.0, 'Airplane': 0.5}, 'overall': 0.33}
|
|
188
208
|
|
|
189
209
|
workspace : typing.Optional[int]
|
|
@@ -202,7 +222,7 @@ class ProjectsClient:
|
|
|
202
222
|
|
|
203
223
|
Examples
|
|
204
224
|
--------
|
|
205
|
-
from label_studio_sdk
|
|
225
|
+
from label_studio_sdk import LabelStudio
|
|
206
226
|
|
|
207
227
|
client = LabelStudio(
|
|
208
228
|
api_key="YOUR_API_KEY",
|
|
@@ -229,12 +249,21 @@ class ProjectsClient:
|
|
|
229
249
|
"workspace": workspace,
|
|
230
250
|
"model_version": model_version,
|
|
231
251
|
},
|
|
252
|
+
headers={
|
|
253
|
+
"content-type": "application/json",
|
|
254
|
+
},
|
|
232
255
|
request_options=request_options,
|
|
233
256
|
omit=OMIT,
|
|
234
257
|
)
|
|
235
258
|
try:
|
|
236
259
|
if 200 <= _response.status_code < 300:
|
|
237
|
-
return
|
|
260
|
+
return typing.cast(
|
|
261
|
+
ProjectsCreateResponse,
|
|
262
|
+
parse_obj_as(
|
|
263
|
+
type_=ProjectsCreateResponse, # type: ignore
|
|
264
|
+
object_=_response.json(),
|
|
265
|
+
),
|
|
266
|
+
)
|
|
238
267
|
_response_json = _response.json()
|
|
239
268
|
except JSONDecodeError:
|
|
240
269
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -259,7 +288,7 @@ class ProjectsClient:
|
|
|
259
288
|
|
|
260
289
|
Examples
|
|
261
290
|
--------
|
|
262
|
-
from label_studio_sdk
|
|
291
|
+
from label_studio_sdk import LabelStudio
|
|
263
292
|
|
|
264
293
|
client = LabelStudio(
|
|
265
294
|
api_key="YOUR_API_KEY",
|
|
@@ -269,11 +298,19 @@ class ProjectsClient:
|
|
|
269
298
|
)
|
|
270
299
|
"""
|
|
271
300
|
_response = self._client_wrapper.httpx_client.request(
|
|
272
|
-
f"api/projects/{jsonable_encoder(id)}/",
|
|
301
|
+
f"api/projects/{jsonable_encoder(id)}/",
|
|
302
|
+
method="GET",
|
|
303
|
+
request_options=request_options,
|
|
273
304
|
)
|
|
274
305
|
try:
|
|
275
306
|
if 200 <= _response.status_code < 300:
|
|
276
|
-
return
|
|
307
|
+
return typing.cast(
|
|
308
|
+
Project,
|
|
309
|
+
parse_obj_as(
|
|
310
|
+
type_=Project, # type: ignore
|
|
311
|
+
object_=_response.json(),
|
|
312
|
+
),
|
|
313
|
+
)
|
|
277
314
|
_response_json = _response.json()
|
|
278
315
|
except JSONDecodeError:
|
|
279
316
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -281,6 +318,7 @@ class ProjectsClient:
|
|
|
281
318
|
|
|
282
319
|
def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
283
320
|
"""
|
|
321
|
+
|
|
284
322
|
Delete a project by specified project ID. Deleting a project permanently removes all tasks, annotations, and project data from Label Studio.
|
|
285
323
|
|
|
286
324
|
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](list).
|
|
@@ -299,7 +337,7 @@ class ProjectsClient:
|
|
|
299
337
|
|
|
300
338
|
Examples
|
|
301
339
|
--------
|
|
302
|
-
from label_studio_sdk
|
|
340
|
+
from label_studio_sdk import LabelStudio
|
|
303
341
|
|
|
304
342
|
client = LabelStudio(
|
|
305
343
|
api_key="YOUR_API_KEY",
|
|
@@ -309,7 +347,9 @@ class ProjectsClient:
|
|
|
309
347
|
)
|
|
310
348
|
"""
|
|
311
349
|
_response = self._client_wrapper.httpx_client.request(
|
|
312
|
-
f"api/projects/{jsonable_encoder(id)}/",
|
|
350
|
+
f"api/projects/{jsonable_encoder(id)}/",
|
|
351
|
+
method="DELETE",
|
|
352
|
+
request_options=request_options,
|
|
313
353
|
)
|
|
314
354
|
try:
|
|
315
355
|
if 200 <= _response.status_code < 300:
|
|
@@ -335,17 +375,17 @@ class ProjectsClient:
|
|
|
335
375
|
show_collab_predictions: typing.Optional[bool] = OMIT,
|
|
336
376
|
maximum_annotations: typing.Optional[int] = OMIT,
|
|
337
377
|
color: typing.Optional[str] = OMIT,
|
|
338
|
-
control_weights: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
378
|
+
control_weights: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
339
379
|
workspace: typing.Optional[int] = OMIT,
|
|
340
380
|
model_version: typing.Optional[str] = OMIT,
|
|
341
381
|
request_options: typing.Optional[RequestOptions] = None,
|
|
342
382
|
) -> ProjectsUpdateResponse:
|
|
343
383
|
"""
|
|
344
|
-
Update the project settings for a specific project. For more information, see the following:
|
|
345
384
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
385
|
+
Update the project settings for a specific project. For more information, see the following:
|
|
386
|
+
* [Create and configure projects](https://labelstud.io/guide/setup_project)
|
|
387
|
+
* [Configure labeling interface](https://labelstud.io/guide/setup)
|
|
388
|
+
* [Project settings](https://labelstud.io/guide/project_settings)
|
|
349
389
|
|
|
350
390
|
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](list).
|
|
351
391
|
|
|
@@ -396,7 +436,7 @@ class ProjectsClient:
|
|
|
396
436
|
color : typing.Optional[str]
|
|
397
437
|
Project color in HEX format
|
|
398
438
|
|
|
399
|
-
control_weights : typing.Optional[typing.Dict[str, typing.Any]]
|
|
439
|
+
control_weights : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
400
440
|
Dict of weights for each control tag in metric calculation. Each control tag (e.g. label or choice) will have its own key in control weight dict with weight for each label and overall weight. For example, if a bounding box annotation with a control tag named my_bbox should be included with 0.33 weight in agreement calculation, and the first label Car should be twice as important as Airplane, then you need to specify: {'my_bbox': {'type': 'RectangleLabels', 'labels': {'Car': 1.0, 'Airplane': 0.5}, 'overall': 0.33}
|
|
401
441
|
|
|
402
442
|
workspace : typing.Optional[int]
|
|
@@ -415,7 +455,7 @@ class ProjectsClient:
|
|
|
415
455
|
|
|
416
456
|
Examples
|
|
417
457
|
--------
|
|
418
|
-
from label_studio_sdk
|
|
458
|
+
from label_studio_sdk import LabelStudio
|
|
419
459
|
|
|
420
460
|
client = LabelStudio(
|
|
421
461
|
api_key="YOUR_API_KEY",
|
|
@@ -444,12 +484,21 @@ class ProjectsClient:
|
|
|
444
484
|
"workspace": workspace,
|
|
445
485
|
"model_version": model_version,
|
|
446
486
|
},
|
|
487
|
+
headers={
|
|
488
|
+
"content-type": "application/json",
|
|
489
|
+
},
|
|
447
490
|
request_options=request_options,
|
|
448
491
|
omit=OMIT,
|
|
449
492
|
)
|
|
450
493
|
try:
|
|
451
494
|
if 200 <= _response.status_code < 300:
|
|
452
|
-
return
|
|
495
|
+
return typing.cast(
|
|
496
|
+
ProjectsUpdateResponse,
|
|
497
|
+
parse_obj_as(
|
|
498
|
+
type_=ProjectsUpdateResponse, # type: ignore
|
|
499
|
+
object_=_response.json(),
|
|
500
|
+
),
|
|
501
|
+
)
|
|
453
502
|
_response_json = _response.json()
|
|
454
503
|
except JSONDecodeError:
|
|
455
504
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -459,26 +508,26 @@ class ProjectsClient:
|
|
|
459
508
|
self,
|
|
460
509
|
id: int,
|
|
461
510
|
*,
|
|
462
|
-
request: typing.Sequence[typing.Dict[str, typing.Any]],
|
|
511
|
+
request: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
|
|
463
512
|
commit_to_project: typing.Optional[bool] = None,
|
|
464
513
|
return_task_ids: typing.Optional[bool] = None,
|
|
465
514
|
preannotated_from_fields: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
466
515
|
request_options: typing.Optional[RequestOptions] = None,
|
|
467
516
|
) -> ProjectsImportTasksResponse:
|
|
468
517
|
"""
|
|
518
|
+
|
|
469
519
|
Use this API endpoint to import labeling tasks in bulk. Note that each POST request is limited at 250K tasks and 200 MB.
|
|
470
|
-
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).
|
|
520
|
+
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).
|
|
471
521
|
|
|
472
522
|
<Note>
|
|
473
|
-
Imported data is verified against a project *label_config* and must include all variables that were used in the *label_config*.
|
|
523
|
+
Imported data is verified against a project *label_config* and must include all variables that were used in the *label_config*.
|
|
474
524
|
|
|
475
|
-
For example, if the label configuration has a
|
|
525
|
+
For example, if the label configuration has a *$text* variable, then each item in a data object must include a `text` field.
|
|
476
526
|
</Note>
|
|
477
527
|
|
|
478
528
|
There are three possible ways to import tasks with this endpoint:
|
|
479
529
|
|
|
480
530
|
#### 1\. **POST with data**
|
|
481
|
-
|
|
482
531
|
Send JSON tasks as POST data. Only JSON is supported for POSTing files directly.
|
|
483
532
|
|
|
484
533
|
Update this example to specify your authorization token and Label Studio instance host, then run the following from
|
|
@@ -490,7 +539,6 @@ class ProjectsClient:
|
|
|
490
539
|
```
|
|
491
540
|
|
|
492
541
|
#### 2\. **POST with files**
|
|
493
|
-
|
|
494
542
|
Send tasks as files. You can attach multiple files with different names.
|
|
495
543
|
|
|
496
544
|
- **JSON**: text files in JavaScript object notation format
|
|
@@ -507,7 +555,6 @@ class ProjectsClient:
|
|
|
507
555
|
```
|
|
508
556
|
|
|
509
557
|
#### 3\. **POST with URL**
|
|
510
|
-
|
|
511
558
|
You can also provide a URL to a file with labeling tasks. Supported file formats are the same as in option 2.
|
|
512
559
|
|
|
513
560
|
```bash
|
|
@@ -523,7 +570,7 @@ class ProjectsClient:
|
|
|
523
570
|
id : int
|
|
524
571
|
A unique integer value identifying this project.
|
|
525
572
|
|
|
526
|
-
request : typing.Sequence[typing.Dict[str, typing.Any]]
|
|
573
|
+
request : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
527
574
|
|
|
528
575
|
commit_to_project : typing.Optional[bool]
|
|
529
576
|
Set to "true" to immediately commit tasks to the project.
|
|
@@ -544,7 +591,7 @@ class ProjectsClient:
|
|
|
544
591
|
|
|
545
592
|
Examples
|
|
546
593
|
--------
|
|
547
|
-
from label_studio_sdk
|
|
594
|
+
from label_studio_sdk import LabelStudio
|
|
548
595
|
|
|
549
596
|
client = LabelStudio(
|
|
550
597
|
api_key="YOUR_API_KEY",
|
|
@@ -568,9 +615,23 @@ class ProjectsClient:
|
|
|
568
615
|
)
|
|
569
616
|
try:
|
|
570
617
|
if 200 <= _response.status_code < 300:
|
|
571
|
-
return
|
|
618
|
+
return typing.cast(
|
|
619
|
+
ProjectsImportTasksResponse,
|
|
620
|
+
parse_obj_as(
|
|
621
|
+
type_=ProjectsImportTasksResponse, # type: ignore
|
|
622
|
+
object_=_response.json(),
|
|
623
|
+
),
|
|
624
|
+
)
|
|
572
625
|
if _response.status_code == 400:
|
|
573
|
-
raise BadRequestError(
|
|
626
|
+
raise BadRequestError(
|
|
627
|
+
typing.cast(
|
|
628
|
+
typing.Optional[typing.Any],
|
|
629
|
+
parse_obj_as(
|
|
630
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
631
|
+
object_=_response.json(),
|
|
632
|
+
),
|
|
633
|
+
)
|
|
634
|
+
)
|
|
574
635
|
_response_json = _response.json()
|
|
575
636
|
except JSONDecodeError:
|
|
576
637
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -580,6 +641,7 @@ class ProjectsClient:
|
|
|
580
641
|
self, id: int, *, label_config: str, request_options: typing.Optional[RequestOptions] = None
|
|
581
642
|
) -> ProjectLabelConfig:
|
|
582
643
|
"""
|
|
644
|
+
|
|
583
645
|
Determine whether the label configuration for a specific project is valid. For more information about setting up labeling configs, see [Configure labeling interface](https://labelstud.io/guide/setup) and our [Tags reference](https://labelstud.io/tags/).
|
|
584
646
|
|
|
585
647
|
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](list).
|
|
@@ -602,7 +664,7 @@ class ProjectsClient:
|
|
|
602
664
|
|
|
603
665
|
Examples
|
|
604
666
|
--------
|
|
605
|
-
from label_studio_sdk
|
|
667
|
+
from label_studio_sdk import LabelStudio
|
|
606
668
|
|
|
607
669
|
client = LabelStudio(
|
|
608
670
|
api_key="YOUR_API_KEY",
|
|
@@ -615,13 +677,21 @@ class ProjectsClient:
|
|
|
615
677
|
_response = self._client_wrapper.httpx_client.request(
|
|
616
678
|
f"api/projects/{jsonable_encoder(id)}/validate/",
|
|
617
679
|
method="POST",
|
|
618
|
-
json={
|
|
680
|
+
json={
|
|
681
|
+
"label_config": label_config,
|
|
682
|
+
},
|
|
619
683
|
request_options=request_options,
|
|
620
684
|
omit=OMIT,
|
|
621
685
|
)
|
|
622
686
|
try:
|
|
623
687
|
if 200 <= _response.status_code < 300:
|
|
624
|
-
return
|
|
688
|
+
return typing.cast(
|
|
689
|
+
ProjectLabelConfig,
|
|
690
|
+
parse_obj_as(
|
|
691
|
+
type_=ProjectLabelConfig, # type: ignore
|
|
692
|
+
object_=_response.json(),
|
|
693
|
+
),
|
|
694
|
+
)
|
|
625
695
|
_response_json = _response.json()
|
|
626
696
|
except JSONDecodeError:
|
|
627
697
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -641,16 +711,17 @@ class AsyncProjectsClient:
|
|
|
641
711
|
title: typing.Optional[str] = None,
|
|
642
712
|
page: typing.Optional[int] = None,
|
|
643
713
|
page_size: typing.Optional[int] = None,
|
|
714
|
+
workspaces: typing.Optional[int] = None,
|
|
644
715
|
request_options: typing.Optional[RequestOptions] = None,
|
|
645
716
|
) -> AsyncPager[Project]:
|
|
646
717
|
"""
|
|
718
|
+
|
|
647
719
|
Return a list of the projects within your organization.
|
|
648
720
|
|
|
649
721
|
To perform most tasks with the Label Studio API, you must specify the project ID, sometimes referred to as the `pk`. The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using this API call.
|
|
650
722
|
|
|
651
723
|
To retrieve a list of your Label Studio projects, update the following command to match your own environment.
|
|
652
724
|
Replace the domain name, port, and authorization token, then run the following from the command line:
|
|
653
|
-
|
|
654
725
|
```bash
|
|
655
726
|
curl -X GET https://localhost:8080/api/projects/ -H 'Authorization: Token abc123'
|
|
656
727
|
```
|
|
@@ -672,6 +743,9 @@ class AsyncProjectsClient:
|
|
|
672
743
|
page_size : typing.Optional[int]
|
|
673
744
|
Number of results to return per page.
|
|
674
745
|
|
|
746
|
+
workspaces : typing.Optional[int]
|
|
747
|
+
workspaces
|
|
748
|
+
|
|
675
749
|
request_options : typing.Optional[RequestOptions]
|
|
676
750
|
Request-specific configuration.
|
|
677
751
|
|
|
@@ -682,28 +756,49 @@ class AsyncProjectsClient:
|
|
|
682
756
|
|
|
683
757
|
Examples
|
|
684
758
|
--------
|
|
685
|
-
|
|
759
|
+
import asyncio
|
|
760
|
+
|
|
761
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
686
762
|
|
|
687
763
|
client = AsyncLabelStudio(
|
|
688
764
|
api_key="YOUR_API_KEY",
|
|
689
765
|
)
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
766
|
+
|
|
767
|
+
|
|
768
|
+
async def main() -> None:
|
|
769
|
+
response = await client.projects.list()
|
|
770
|
+
async for item in response:
|
|
771
|
+
yield item
|
|
772
|
+
# alternatively, you can paginate page-by-page
|
|
773
|
+
async for page in response.iter_pages():
|
|
774
|
+
yield page
|
|
775
|
+
|
|
776
|
+
|
|
777
|
+
asyncio.run(main())
|
|
696
778
|
"""
|
|
697
|
-
page = page
|
|
779
|
+
page = page if page is not None else 1
|
|
698
780
|
_response = await self._client_wrapper.httpx_client.request(
|
|
699
781
|
"api/projects/",
|
|
700
782
|
method="GET",
|
|
701
|
-
params={
|
|
783
|
+
params={
|
|
784
|
+
"ordering": ordering,
|
|
785
|
+
"ids": ids,
|
|
786
|
+
"title": title,
|
|
787
|
+
"page": page,
|
|
788
|
+
"page_size": page_size,
|
|
789
|
+
"workspaces": workspaces,
|
|
790
|
+
},
|
|
702
791
|
request_options=request_options,
|
|
703
792
|
)
|
|
704
793
|
try:
|
|
705
794
|
if 200 <= _response.status_code < 300:
|
|
706
|
-
_parsed_response =
|
|
795
|
+
_parsed_response = typing.cast(
|
|
796
|
+
ProjectsListResponse,
|
|
797
|
+
parse_obj_as(
|
|
798
|
+
type_=ProjectsListResponse, # type: ignore
|
|
799
|
+
object_=_response.json(),
|
|
800
|
+
),
|
|
801
|
+
)
|
|
707
802
|
_has_next = True
|
|
708
803
|
_get_next = lambda: self.list(
|
|
709
804
|
ordering=ordering,
|
|
@@ -711,6 +806,7 @@ class AsyncProjectsClient:
|
|
|
711
806
|
title=title,
|
|
712
807
|
page=page + 1,
|
|
713
808
|
page_size=page_size,
|
|
809
|
+
workspaces=workspaces,
|
|
714
810
|
request_options=request_options,
|
|
715
811
|
)
|
|
716
812
|
_items = _parsed_response.results
|
|
@@ -735,17 +831,17 @@ class AsyncProjectsClient:
|
|
|
735
831
|
show_collab_predictions: typing.Optional[bool] = OMIT,
|
|
736
832
|
maximum_annotations: typing.Optional[int] = OMIT,
|
|
737
833
|
color: typing.Optional[str] = OMIT,
|
|
738
|
-
control_weights: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
834
|
+
control_weights: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
739
835
|
workspace: typing.Optional[int] = OMIT,
|
|
740
836
|
model_version: typing.Optional[str] = OMIT,
|
|
741
837
|
request_options: typing.Optional[RequestOptions] = None,
|
|
742
838
|
) -> ProjectsCreateResponse:
|
|
743
839
|
"""
|
|
744
|
-
Create a project and set up the labeling interface. For more information about setting up projects, see the following:
|
|
745
840
|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
841
|
+
Create a project and set up the labeling interface. For more information about setting up projects, see the following:
|
|
842
|
+
* [Create and configure projects](https://labelstud.io/guide/setup_project)
|
|
843
|
+
* [Configure labeling interface](https://labelstud.io/guide/setup)
|
|
844
|
+
* [Project settings](https://labelstud.io/guide/project_settings)
|
|
749
845
|
|
|
750
846
|
```bash
|
|
751
847
|
curl -H Content-Type:application/json -H 'Authorization: Token abc123' -X POST 'https://localhost:8080/api/projects' --data '{"label_config": "<View>[...]</View>"}'
|
|
@@ -789,7 +885,7 @@ class AsyncProjectsClient:
|
|
|
789
885
|
color : typing.Optional[str]
|
|
790
886
|
Project color in HEX format
|
|
791
887
|
|
|
792
|
-
control_weights : typing.Optional[typing.Dict[str, typing.Any]]
|
|
888
|
+
control_weights : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
793
889
|
Dict of weights for each control tag in metric calculation. Each control tag (e.g. label or choice) will have its own key in control weight dict with weight for each label and overall weight. For example, if a bounding box annotation with a control tag named my_bbox should be included with 0.33 weight in agreement calculation, and the first label Car should be twice as important as Airplane, then you need to specify: {'my_bbox': {'type': 'RectangleLabels', 'labels': {'Car': 1.0, 'Airplane': 0.5}, 'overall': 0.33}
|
|
794
890
|
|
|
795
891
|
workspace : typing.Optional[int]
|
|
@@ -808,12 +904,20 @@ class AsyncProjectsClient:
|
|
|
808
904
|
|
|
809
905
|
Examples
|
|
810
906
|
--------
|
|
811
|
-
|
|
907
|
+
import asyncio
|
|
908
|
+
|
|
909
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
812
910
|
|
|
813
911
|
client = AsyncLabelStudio(
|
|
814
912
|
api_key="YOUR_API_KEY",
|
|
815
913
|
)
|
|
816
|
-
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
async def main() -> None:
|
|
917
|
+
await client.projects.create()
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
asyncio.run(main())
|
|
817
921
|
"""
|
|
818
922
|
_response = await self._client_wrapper.httpx_client.request(
|
|
819
923
|
"api/projects/",
|
|
@@ -835,12 +939,21 @@ class AsyncProjectsClient:
|
|
|
835
939
|
"workspace": workspace,
|
|
836
940
|
"model_version": model_version,
|
|
837
941
|
},
|
|
942
|
+
headers={
|
|
943
|
+
"content-type": "application/json",
|
|
944
|
+
},
|
|
838
945
|
request_options=request_options,
|
|
839
946
|
omit=OMIT,
|
|
840
947
|
)
|
|
841
948
|
try:
|
|
842
949
|
if 200 <= _response.status_code < 300:
|
|
843
|
-
return
|
|
950
|
+
return typing.cast(
|
|
951
|
+
ProjectsCreateResponse,
|
|
952
|
+
parse_obj_as(
|
|
953
|
+
type_=ProjectsCreateResponse, # type: ignore
|
|
954
|
+
object_=_response.json(),
|
|
955
|
+
),
|
|
956
|
+
)
|
|
844
957
|
_response_json = _response.json()
|
|
845
958
|
except JSONDecodeError:
|
|
846
959
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -865,21 +978,37 @@ class AsyncProjectsClient:
|
|
|
865
978
|
|
|
866
979
|
Examples
|
|
867
980
|
--------
|
|
868
|
-
|
|
981
|
+
import asyncio
|
|
982
|
+
|
|
983
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
869
984
|
|
|
870
985
|
client = AsyncLabelStudio(
|
|
871
986
|
api_key="YOUR_API_KEY",
|
|
872
987
|
)
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
)
|
|
988
|
+
|
|
989
|
+
|
|
990
|
+
async def main() -> None:
|
|
991
|
+
await client.projects.get(
|
|
992
|
+
id=1,
|
|
993
|
+
)
|
|
994
|
+
|
|
995
|
+
|
|
996
|
+
asyncio.run(main())
|
|
876
997
|
"""
|
|
877
998
|
_response = await self._client_wrapper.httpx_client.request(
|
|
878
|
-
f"api/projects/{jsonable_encoder(id)}/",
|
|
999
|
+
f"api/projects/{jsonable_encoder(id)}/",
|
|
1000
|
+
method="GET",
|
|
1001
|
+
request_options=request_options,
|
|
879
1002
|
)
|
|
880
1003
|
try:
|
|
881
1004
|
if 200 <= _response.status_code < 300:
|
|
882
|
-
return
|
|
1005
|
+
return typing.cast(
|
|
1006
|
+
Project,
|
|
1007
|
+
parse_obj_as(
|
|
1008
|
+
type_=Project, # type: ignore
|
|
1009
|
+
object_=_response.json(),
|
|
1010
|
+
),
|
|
1011
|
+
)
|
|
883
1012
|
_response_json = _response.json()
|
|
884
1013
|
except JSONDecodeError:
|
|
885
1014
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -887,6 +1016,7 @@ class AsyncProjectsClient:
|
|
|
887
1016
|
|
|
888
1017
|
async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
889
1018
|
"""
|
|
1019
|
+
|
|
890
1020
|
Delete a project by specified project ID. Deleting a project permanently removes all tasks, annotations, and project data from Label Studio.
|
|
891
1021
|
|
|
892
1022
|
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](list).
|
|
@@ -905,17 +1035,27 @@ class AsyncProjectsClient:
|
|
|
905
1035
|
|
|
906
1036
|
Examples
|
|
907
1037
|
--------
|
|
908
|
-
|
|
1038
|
+
import asyncio
|
|
1039
|
+
|
|
1040
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
909
1041
|
|
|
910
1042
|
client = AsyncLabelStudio(
|
|
911
1043
|
api_key="YOUR_API_KEY",
|
|
912
1044
|
)
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
)
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
async def main() -> None:
|
|
1048
|
+
await client.projects.delete(
|
|
1049
|
+
id=1,
|
|
1050
|
+
)
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
asyncio.run(main())
|
|
916
1054
|
"""
|
|
917
1055
|
_response = await self._client_wrapper.httpx_client.request(
|
|
918
|
-
f"api/projects/{jsonable_encoder(id)}/",
|
|
1056
|
+
f"api/projects/{jsonable_encoder(id)}/",
|
|
1057
|
+
method="DELETE",
|
|
1058
|
+
request_options=request_options,
|
|
919
1059
|
)
|
|
920
1060
|
try:
|
|
921
1061
|
if 200 <= _response.status_code < 300:
|
|
@@ -941,17 +1081,17 @@ class AsyncProjectsClient:
|
|
|
941
1081
|
show_collab_predictions: typing.Optional[bool] = OMIT,
|
|
942
1082
|
maximum_annotations: typing.Optional[int] = OMIT,
|
|
943
1083
|
color: typing.Optional[str] = OMIT,
|
|
944
|
-
control_weights: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
|
|
1084
|
+
control_weights: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
945
1085
|
workspace: typing.Optional[int] = OMIT,
|
|
946
1086
|
model_version: typing.Optional[str] = OMIT,
|
|
947
1087
|
request_options: typing.Optional[RequestOptions] = None,
|
|
948
1088
|
) -> ProjectsUpdateResponse:
|
|
949
1089
|
"""
|
|
950
|
-
Update the project settings for a specific project. For more information, see the following:
|
|
951
1090
|
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
1091
|
+
Update the project settings for a specific project. For more information, see the following:
|
|
1092
|
+
* [Create and configure projects](https://labelstud.io/guide/setup_project)
|
|
1093
|
+
* [Configure labeling interface](https://labelstud.io/guide/setup)
|
|
1094
|
+
* [Project settings](https://labelstud.io/guide/project_settings)
|
|
955
1095
|
|
|
956
1096
|
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](list).
|
|
957
1097
|
|
|
@@ -1002,7 +1142,7 @@ class AsyncProjectsClient:
|
|
|
1002
1142
|
color : typing.Optional[str]
|
|
1003
1143
|
Project color in HEX format
|
|
1004
1144
|
|
|
1005
|
-
control_weights : typing.Optional[typing.Dict[str, typing.Any]]
|
|
1145
|
+
control_weights : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
1006
1146
|
Dict of weights for each control tag in metric calculation. Each control tag (e.g. label or choice) will have its own key in control weight dict with weight for each label and overall weight. For example, if a bounding box annotation with a control tag named my_bbox should be included with 0.33 weight in agreement calculation, and the first label Car should be twice as important as Airplane, then you need to specify: {'my_bbox': {'type': 'RectangleLabels', 'labels': {'Car': 1.0, 'Airplane': 0.5}, 'overall': 0.33}
|
|
1007
1147
|
|
|
1008
1148
|
workspace : typing.Optional[int]
|
|
@@ -1021,14 +1161,22 @@ class AsyncProjectsClient:
|
|
|
1021
1161
|
|
|
1022
1162
|
Examples
|
|
1023
1163
|
--------
|
|
1024
|
-
|
|
1164
|
+
import asyncio
|
|
1165
|
+
|
|
1166
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
1025
1167
|
|
|
1026
1168
|
client = AsyncLabelStudio(
|
|
1027
1169
|
api_key="YOUR_API_KEY",
|
|
1028
1170
|
)
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
)
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
async def main() -> None:
|
|
1174
|
+
await client.projects.update(
|
|
1175
|
+
id=1,
|
|
1176
|
+
)
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
asyncio.run(main())
|
|
1032
1180
|
"""
|
|
1033
1181
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1034
1182
|
f"api/projects/{jsonable_encoder(id)}/",
|
|
@@ -1050,12 +1198,21 @@ class AsyncProjectsClient:
|
|
|
1050
1198
|
"workspace": workspace,
|
|
1051
1199
|
"model_version": model_version,
|
|
1052
1200
|
},
|
|
1201
|
+
headers={
|
|
1202
|
+
"content-type": "application/json",
|
|
1203
|
+
},
|
|
1053
1204
|
request_options=request_options,
|
|
1054
1205
|
omit=OMIT,
|
|
1055
1206
|
)
|
|
1056
1207
|
try:
|
|
1057
1208
|
if 200 <= _response.status_code < 300:
|
|
1058
|
-
return
|
|
1209
|
+
return typing.cast(
|
|
1210
|
+
ProjectsUpdateResponse,
|
|
1211
|
+
parse_obj_as(
|
|
1212
|
+
type_=ProjectsUpdateResponse, # type: ignore
|
|
1213
|
+
object_=_response.json(),
|
|
1214
|
+
),
|
|
1215
|
+
)
|
|
1059
1216
|
_response_json = _response.json()
|
|
1060
1217
|
except JSONDecodeError:
|
|
1061
1218
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -1065,26 +1222,26 @@ class AsyncProjectsClient:
|
|
|
1065
1222
|
self,
|
|
1066
1223
|
id: int,
|
|
1067
1224
|
*,
|
|
1068
|
-
request: typing.Sequence[typing.Dict[str, typing.Any]],
|
|
1225
|
+
request: typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]],
|
|
1069
1226
|
commit_to_project: typing.Optional[bool] = None,
|
|
1070
1227
|
return_task_ids: typing.Optional[bool] = None,
|
|
1071
1228
|
preannotated_from_fields: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
1072
1229
|
request_options: typing.Optional[RequestOptions] = None,
|
|
1073
1230
|
) -> ProjectsImportTasksResponse:
|
|
1074
1231
|
"""
|
|
1232
|
+
|
|
1075
1233
|
Use this API endpoint to import labeling tasks in bulk. Note that each POST request is limited at 250K tasks and 200 MB.
|
|
1076
|
-
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).
|
|
1234
|
+
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).
|
|
1077
1235
|
|
|
1078
1236
|
<Note>
|
|
1079
|
-
Imported data is verified against a project *label_config* and must include all variables that were used in the *label_config*.
|
|
1237
|
+
Imported data is verified against a project *label_config* and must include all variables that were used in the *label_config*.
|
|
1080
1238
|
|
|
1081
|
-
For example, if the label configuration has a
|
|
1239
|
+
For example, if the label configuration has a *$text* variable, then each item in a data object must include a `text` field.
|
|
1082
1240
|
</Note>
|
|
1083
1241
|
|
|
1084
1242
|
There are three possible ways to import tasks with this endpoint:
|
|
1085
1243
|
|
|
1086
1244
|
#### 1\. **POST with data**
|
|
1087
|
-
|
|
1088
1245
|
Send JSON tasks as POST data. Only JSON is supported for POSTing files directly.
|
|
1089
1246
|
|
|
1090
1247
|
Update this example to specify your authorization token and Label Studio instance host, then run the following from
|
|
@@ -1096,7 +1253,6 @@ class AsyncProjectsClient:
|
|
|
1096
1253
|
```
|
|
1097
1254
|
|
|
1098
1255
|
#### 2\. **POST with files**
|
|
1099
|
-
|
|
1100
1256
|
Send tasks as files. You can attach multiple files with different names.
|
|
1101
1257
|
|
|
1102
1258
|
- **JSON**: text files in JavaScript object notation format
|
|
@@ -1113,7 +1269,6 @@ class AsyncProjectsClient:
|
|
|
1113
1269
|
```
|
|
1114
1270
|
|
|
1115
1271
|
#### 3\. **POST with URL**
|
|
1116
|
-
|
|
1117
1272
|
You can also provide a URL to a file with labeling tasks. Supported file formats are the same as in option 2.
|
|
1118
1273
|
|
|
1119
1274
|
```bash
|
|
@@ -1129,7 +1284,7 @@ class AsyncProjectsClient:
|
|
|
1129
1284
|
id : int
|
|
1130
1285
|
A unique integer value identifying this project.
|
|
1131
1286
|
|
|
1132
|
-
request : typing.Sequence[typing.Dict[str, typing.Any]]
|
|
1287
|
+
request : typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
1133
1288
|
|
|
1134
1289
|
commit_to_project : typing.Optional[bool]
|
|
1135
1290
|
Set to "true" to immediately commit tasks to the project.
|
|
@@ -1150,15 +1305,23 @@ class AsyncProjectsClient:
|
|
|
1150
1305
|
|
|
1151
1306
|
Examples
|
|
1152
1307
|
--------
|
|
1153
|
-
|
|
1308
|
+
import asyncio
|
|
1309
|
+
|
|
1310
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
1154
1311
|
|
|
1155
1312
|
client = AsyncLabelStudio(
|
|
1156
1313
|
api_key="YOUR_API_KEY",
|
|
1157
1314
|
)
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
async def main() -> None:
|
|
1318
|
+
await client.projects.import_tasks(
|
|
1319
|
+
id=1,
|
|
1320
|
+
request=[{"key": "value"}],
|
|
1321
|
+
)
|
|
1322
|
+
|
|
1323
|
+
|
|
1324
|
+
asyncio.run(main())
|
|
1162
1325
|
"""
|
|
1163
1326
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1164
1327
|
f"api/projects/{jsonable_encoder(id)}/import",
|
|
@@ -1174,9 +1337,23 @@ class AsyncProjectsClient:
|
|
|
1174
1337
|
)
|
|
1175
1338
|
try:
|
|
1176
1339
|
if 200 <= _response.status_code < 300:
|
|
1177
|
-
return
|
|
1340
|
+
return typing.cast(
|
|
1341
|
+
ProjectsImportTasksResponse,
|
|
1342
|
+
parse_obj_as(
|
|
1343
|
+
type_=ProjectsImportTasksResponse, # type: ignore
|
|
1344
|
+
object_=_response.json(),
|
|
1345
|
+
),
|
|
1346
|
+
)
|
|
1178
1347
|
if _response.status_code == 400:
|
|
1179
|
-
raise BadRequestError(
|
|
1348
|
+
raise BadRequestError(
|
|
1349
|
+
typing.cast(
|
|
1350
|
+
typing.Optional[typing.Any],
|
|
1351
|
+
parse_obj_as(
|
|
1352
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1353
|
+
object_=_response.json(),
|
|
1354
|
+
),
|
|
1355
|
+
)
|
|
1356
|
+
)
|
|
1180
1357
|
_response_json = _response.json()
|
|
1181
1358
|
except JSONDecodeError:
|
|
1182
1359
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
@@ -1186,6 +1363,7 @@ class AsyncProjectsClient:
|
|
|
1186
1363
|
self, id: int, *, label_config: str, request_options: typing.Optional[RequestOptions] = None
|
|
1187
1364
|
) -> ProjectLabelConfig:
|
|
1188
1365
|
"""
|
|
1366
|
+
|
|
1189
1367
|
Determine whether the label configuration for a specific project is valid. For more information about setting up labeling configs, see [Configure labeling interface](https://labelstud.io/guide/setup) and our [Tags reference](https://labelstud.io/tags/).
|
|
1190
1368
|
|
|
1191
1369
|
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](list).
|
|
@@ -1208,26 +1386,42 @@ class AsyncProjectsClient:
|
|
|
1208
1386
|
|
|
1209
1387
|
Examples
|
|
1210
1388
|
--------
|
|
1211
|
-
|
|
1389
|
+
import asyncio
|
|
1390
|
+
|
|
1391
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
1212
1392
|
|
|
1213
1393
|
client = AsyncLabelStudio(
|
|
1214
1394
|
api_key="YOUR_API_KEY",
|
|
1215
1395
|
)
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1396
|
+
|
|
1397
|
+
|
|
1398
|
+
async def main() -> None:
|
|
1399
|
+
await client.projects.validate_config(
|
|
1400
|
+
id=1,
|
|
1401
|
+
label_config="label_config",
|
|
1402
|
+
)
|
|
1403
|
+
|
|
1404
|
+
|
|
1405
|
+
asyncio.run(main())
|
|
1220
1406
|
"""
|
|
1221
1407
|
_response = await self._client_wrapper.httpx_client.request(
|
|
1222
1408
|
f"api/projects/{jsonable_encoder(id)}/validate/",
|
|
1223
1409
|
method="POST",
|
|
1224
|
-
json={
|
|
1410
|
+
json={
|
|
1411
|
+
"label_config": label_config,
|
|
1412
|
+
},
|
|
1225
1413
|
request_options=request_options,
|
|
1226
1414
|
omit=OMIT,
|
|
1227
1415
|
)
|
|
1228
1416
|
try:
|
|
1229
1417
|
if 200 <= _response.status_code < 300:
|
|
1230
|
-
return
|
|
1418
|
+
return typing.cast(
|
|
1419
|
+
ProjectLabelConfig,
|
|
1420
|
+
parse_obj_as(
|
|
1421
|
+
type_=ProjectLabelConfig, # type: ignore
|
|
1422
|
+
object_=_response.json(),
|
|
1423
|
+
),
|
|
1424
|
+
)
|
|
1231
1425
|
_response_json = _response.json()
|
|
1232
1426
|
except JSONDecodeError:
|
|
1233
1427
|
raise ApiError(status_code=_response.status_code, body=_response.text)
|