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