label-studio-sdk 1.0.8__py3-none-any.whl → 1.0.11__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.

Files changed (218) hide show
  1. label_studio_sdk/__init__.py +37 -8
  2. label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +16 -4
  3. label_studio_sdk/_extensions/label_studio_tools/core/utils/json_schema.py +5 -0
  4. label_studio_sdk/_extensions/pager_ext.py +8 -0
  5. label_studio_sdk/actions/client.py +91 -40
  6. label_studio_sdk/actions/types/actions_create_request_filters.py +14 -24
  7. label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +16 -26
  8. label_studio_sdk/actions/types/actions_create_request_filters_items_item_value.py +3 -1
  9. label_studio_sdk/actions/types/actions_create_request_selected_items.py +1 -2
  10. label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +15 -25
  11. label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +15 -25
  12. label_studio_sdk/annotations/__init__.py +2 -2
  13. label_studio_sdk/annotations/client.py +278 -104
  14. label_studio_sdk/annotations/types/__init__.py +2 -1
  15. label_studio_sdk/annotations/types/annotations_create_bulk_request_selected_items.py +34 -0
  16. label_studio_sdk/annotations/types/annotations_create_bulk_response_item.py +11 -21
  17. label_studio_sdk/base_client.py +54 -27
  18. label_studio_sdk/client.py +1 -0
  19. label_studio_sdk/comments/client.py +190 -44
  20. label_studio_sdk/converter/converter.py +56 -13
  21. label_studio_sdk/converter/imports/yolo.py +1 -1
  22. label_studio_sdk/converter/utils.py +3 -2
  23. label_studio_sdk/core/__init__.py +21 -4
  24. label_studio_sdk/core/client_wrapper.py +37 -19
  25. label_studio_sdk/core/file.py +37 -8
  26. label_studio_sdk/core/http_client.py +52 -28
  27. label_studio_sdk/core/jsonable_encoder.py +33 -31
  28. label_studio_sdk/core/pagination.py +5 -4
  29. label_studio_sdk/core/pydantic_utilities.py +272 -4
  30. label_studio_sdk/core/query_encoder.py +38 -13
  31. label_studio_sdk/core/request_options.py +3 -0
  32. label_studio_sdk/core/serialization.py +272 -0
  33. label_studio_sdk/errors/__init__.py +3 -1
  34. label_studio_sdk/errors/bad_request_error.py +2 -3
  35. label_studio_sdk/errors/not_found_error.py +9 -0
  36. label_studio_sdk/errors/unauthorized_error.py +9 -0
  37. label_studio_sdk/export_storage/azure/client.py +228 -58
  38. label_studio_sdk/export_storage/azure/types/azure_create_response.py +19 -29
  39. label_studio_sdk/export_storage/azure/types/azure_update_response.py +19 -29
  40. label_studio_sdk/export_storage/client.py +48 -18
  41. label_studio_sdk/export_storage/gcs/client.py +228 -58
  42. label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +19 -29
  43. label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +19 -29
  44. label_studio_sdk/export_storage/local/client.py +222 -56
  45. label_studio_sdk/export_storage/local/types/local_create_response.py +17 -27
  46. label_studio_sdk/export_storage/local/types/local_update_response.py +17 -27
  47. label_studio_sdk/export_storage/redis/client.py +228 -58
  48. label_studio_sdk/export_storage/redis/types/redis_create_response.py +20 -30
  49. label_studio_sdk/export_storage/redis/types/redis_update_response.py +20 -30
  50. label_studio_sdk/export_storage/s3/client.py +228 -58
  51. label_studio_sdk/export_storage/s3/types/s3create_response.py +27 -35
  52. label_studio_sdk/export_storage/s3/types/s3update_response.py +27 -35
  53. label_studio_sdk/export_storage/s3s/client.py +187 -43
  54. label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +11 -21
  55. label_studio_sdk/files/client.py +172 -56
  56. label_studio_sdk/import_storage/azure/client.py +223 -53
  57. label_studio_sdk/import_storage/azure/types/azure_create_response.py +22 -32
  58. label_studio_sdk/import_storage/azure/types/azure_update_response.py +22 -32
  59. label_studio_sdk/import_storage/client.py +48 -18
  60. label_studio_sdk/import_storage/gcs/client.py +223 -53
  61. label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +22 -32
  62. label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +22 -32
  63. label_studio_sdk/import_storage/local/client.py +223 -53
  64. label_studio_sdk/import_storage/local/types/local_create_response.py +17 -27
  65. label_studio_sdk/import_storage/local/types/local_update_response.py +17 -27
  66. label_studio_sdk/import_storage/redis/client.py +223 -53
  67. label_studio_sdk/import_storage/redis/types/redis_create_response.py +20 -30
  68. label_studio_sdk/import_storage/redis/types/redis_update_response.py +20 -30
  69. label_studio_sdk/import_storage/s3/client.py +223 -53
  70. label_studio_sdk/import_storage/s3/types/s3create_response.py +31 -39
  71. label_studio_sdk/import_storage/s3/types/s3update_response.py +31 -39
  72. label_studio_sdk/import_storage/s3s/client.py +222 -52
  73. label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +11 -21
  74. label_studio_sdk/jwt_settings/__init__.py +2 -0
  75. label_studio_sdk/jwt_settings/client.py +259 -0
  76. label_studio_sdk/label_interface/control_tags.py +16 -3
  77. label_studio_sdk/label_interface/interface.py +80 -1
  78. label_studio_sdk/label_interface/object_tags.py +2 -2
  79. label_studio_sdk/ml/client.py +280 -78
  80. label_studio_sdk/ml/types/ml_create_response.py +21 -31
  81. label_studio_sdk/ml/types/ml_update_response.py +21 -31
  82. label_studio_sdk/model_providers/client.py +173 -56
  83. label_studio_sdk/predictions/client.py +247 -101
  84. label_studio_sdk/projects/__init__.py +5 -1
  85. label_studio_sdk/projects/client.py +313 -115
  86. label_studio_sdk/projects/client_ext.py +16 -0
  87. label_studio_sdk/projects/exports/__init__.py +3 -0
  88. label_studio_sdk/projects/exports/client.py +447 -296
  89. label_studio_sdk/projects/exports/client_ext.py +200 -0
  90. label_studio_sdk/projects/exports/types/__init__.py +6 -0
  91. label_studio_sdk/projects/exports/types/exports_convert_response.py +24 -0
  92. label_studio_sdk/projects/exports/types/exports_list_formats_response_item.py +44 -0
  93. label_studio_sdk/projects/pauses/__init__.py +2 -0
  94. label_studio_sdk/projects/pauses/client.py +704 -0
  95. label_studio_sdk/projects/types/projects_create_response.py +29 -34
  96. label_studio_sdk/projects/types/projects_import_tasks_response.py +19 -29
  97. label_studio_sdk/projects/types/projects_list_response.py +11 -21
  98. label_studio_sdk/projects/types/projects_update_response.py +34 -34
  99. label_studio_sdk/prompts/client.py +309 -92
  100. label_studio_sdk/prompts/indicators/client.py +67 -23
  101. label_studio_sdk/prompts/runs/client.py +95 -40
  102. label_studio_sdk/prompts/types/prompts_batch_failed_predictions_request_failed_predictions_item.py +14 -24
  103. label_studio_sdk/prompts/types/prompts_batch_failed_predictions_response.py +11 -21
  104. label_studio_sdk/prompts/types/prompts_batch_predictions_request_results_item.py +26 -29
  105. label_studio_sdk/prompts/types/prompts_batch_predictions_response.py +11 -21
  106. label_studio_sdk/prompts/versions/client.py +277 -88
  107. label_studio_sdk/tasks/client.py +263 -90
  108. label_studio_sdk/tasks/types/tasks_list_response.py +15 -25
  109. label_studio_sdk/tokens/__init__.py +2 -0
  110. label_studio_sdk/tokens/client.py +470 -0
  111. label_studio_sdk/tokens/client_ext.py +94 -0
  112. label_studio_sdk/types/__init__.py +20 -6
  113. label_studio_sdk/types/access_token_response.py +22 -0
  114. label_studio_sdk/types/annotation.py +29 -38
  115. label_studio_sdk/types/annotation_filter_options.py +14 -24
  116. label_studio_sdk/types/annotations_dm_field.py +30 -39
  117. label_studio_sdk/types/api_token_response.py +32 -0
  118. label_studio_sdk/types/azure_blob_export_storage.py +28 -37
  119. label_studio_sdk/types/azure_blob_import_storage.py +28 -37
  120. label_studio_sdk/types/base_task.py +30 -39
  121. label_studio_sdk/types/base_task_updated_by.py +3 -1
  122. label_studio_sdk/types/base_user.py +14 -21
  123. label_studio_sdk/types/comment.py +12 -21
  124. label_studio_sdk/types/comment_created_by.py +1 -1
  125. label_studio_sdk/types/converted_format.py +12 -22
  126. label_studio_sdk/types/data_manager_task_serializer.py +31 -40
  127. label_studio_sdk/types/data_manager_task_serializer_annotators_item.py +1 -1
  128. label_studio_sdk/types/data_manager_task_serializer_drafts_item.py +13 -22
  129. label_studio_sdk/types/data_manager_task_serializer_predictions_item.py +15 -24
  130. label_studio_sdk/types/export.py +17 -26
  131. label_studio_sdk/types/export_format.py +25 -0
  132. label_studio_sdk/types/export_snapshot.py +45 -0
  133. label_studio_sdk/types/export_snapshot_status.py +5 -0
  134. label_studio_sdk/types/file_upload.py +11 -21
  135. label_studio_sdk/types/filter.py +16 -26
  136. label_studio_sdk/types/filter_group.py +12 -22
  137. label_studio_sdk/types/gcs_export_storage.py +28 -37
  138. label_studio_sdk/types/gcs_import_storage.py +28 -37
  139. label_studio_sdk/types/inference_run.py +14 -23
  140. label_studio_sdk/types/inference_run_cost_estimate.py +17 -27
  141. label_studio_sdk/types/inference_run_created_by.py +1 -1
  142. label_studio_sdk/types/inference_run_organization.py +1 -1
  143. label_studio_sdk/types/jwt_settings_response.py +32 -0
  144. label_studio_sdk/types/key_indicator_value.py +12 -22
  145. label_studio_sdk/types/key_indicators.py +0 -1
  146. label_studio_sdk/types/key_indicators_item.py +15 -25
  147. label_studio_sdk/types/key_indicators_item_additional_kpis_item.py +13 -23
  148. label_studio_sdk/types/key_indicators_item_extra_kpis_item.py +13 -23
  149. label_studio_sdk/types/local_files_export_storage.py +25 -34
  150. label_studio_sdk/types/local_files_import_storage.py +24 -33
  151. label_studio_sdk/types/ml_backend.py +23 -32
  152. label_studio_sdk/types/model_provider_connection.py +22 -31
  153. label_studio_sdk/types/model_provider_connection_created_by.py +1 -1
  154. label_studio_sdk/types/model_provider_connection_organization.py +1 -1
  155. label_studio_sdk/types/model_provider_connection_provider.py +3 -1
  156. label_studio_sdk/types/pause.py +34 -0
  157. label_studio_sdk/types/pause_paused_by.py +5 -0
  158. label_studio_sdk/types/prediction.py +21 -30
  159. label_studio_sdk/types/project.py +58 -55
  160. label_studio_sdk/types/project_import.py +21 -30
  161. label_studio_sdk/types/project_label_config.py +12 -22
  162. label_studio_sdk/types/prompt.py +24 -32
  163. label_studio_sdk/types/prompt_associated_projects_item.py +6 -0
  164. label_studio_sdk/types/prompt_associated_projects_item_id.py +20 -0
  165. label_studio_sdk/types/prompt_created_by.py +1 -1
  166. label_studio_sdk/types/prompt_organization.py +1 -1
  167. label_studio_sdk/types/prompt_version.py +13 -22
  168. label_studio_sdk/types/prompt_version_created_by.py +1 -1
  169. label_studio_sdk/types/prompt_version_organization.py +1 -1
  170. label_studio_sdk/types/prompt_version_provider.py +3 -1
  171. label_studio_sdk/types/redis_export_storage.py +29 -38
  172. label_studio_sdk/types/redis_import_storage.py +28 -37
  173. label_studio_sdk/types/refined_prompt_response.py +19 -29
  174. label_studio_sdk/types/s3export_storage.py +36 -43
  175. label_studio_sdk/types/s3import_storage.py +37 -44
  176. label_studio_sdk/types/s3s_export_storage.py +26 -33
  177. label_studio_sdk/types/s3s_import_storage.py +35 -42
  178. label_studio_sdk/types/serialization_option.py +12 -22
  179. label_studio_sdk/types/serialization_options.py +18 -28
  180. label_studio_sdk/types/task.py +44 -47
  181. label_studio_sdk/types/task_annotators_item.py +1 -1
  182. label_studio_sdk/types/task_comment_authors_item.py +1 -1
  183. label_studio_sdk/types/task_filter_options.py +15 -25
  184. label_studio_sdk/types/user_simple.py +11 -21
  185. label_studio_sdk/types/view.py +16 -26
  186. label_studio_sdk/types/webhook.py +19 -28
  187. label_studio_sdk/types/webhook_serializer_for_update.py +19 -28
  188. label_studio_sdk/types/workspace.py +22 -31
  189. label_studio_sdk/users/client.py +257 -63
  190. label_studio_sdk/users/types/users_get_token_response.py +12 -22
  191. label_studio_sdk/users/types/users_reset_token_response.py +12 -22
  192. label_studio_sdk/version.py +0 -1
  193. label_studio_sdk/versions/__init__.py +5 -0
  194. label_studio_sdk/versions/client.py +112 -0
  195. label_studio_sdk/versions/types/__init__.py +6 -0
  196. label_studio_sdk/versions/types/versions_get_response.py +73 -0
  197. label_studio_sdk/versions/types/versions_get_response_edition.py +5 -0
  198. label_studio_sdk/views/client.py +219 -52
  199. label_studio_sdk/views/types/views_create_request_data.py +13 -23
  200. label_studio_sdk/views/types/views_create_request_data_filters.py +14 -24
  201. label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +16 -26
  202. label_studio_sdk/views/types/views_create_request_data_filters_items_item_value.py +3 -1
  203. label_studio_sdk/views/types/views_update_request_data.py +13 -23
  204. label_studio_sdk/views/types/views_update_request_data_filters.py +14 -24
  205. label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +16 -26
  206. label_studio_sdk/views/types/views_update_request_data_filters_items_item_value.py +3 -1
  207. label_studio_sdk/webhooks/client.py +191 -61
  208. label_studio_sdk/workspaces/client.py +164 -41
  209. label_studio_sdk/workspaces/members/client.py +109 -31
  210. label_studio_sdk/workspaces/members/types/members_create_response.py +12 -22
  211. label_studio_sdk/workspaces/members/types/members_list_response_item.py +12 -22
  212. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.11.dist-info}/METADATA +8 -5
  213. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.11.dist-info}/RECORD +215 -188
  214. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.11.dist-info}/WHEEL +1 -1
  215. label_studio_sdk/types/export_convert.py +0 -32
  216. label_studio_sdk/types/export_create.py +0 -54
  217. label_studio_sdk/types/export_create_status.py +0 -5
  218. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.11.dist-info}/LICENSE +0 -0
@@ -1,15 +1,17 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
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
4
+ from ..core.client_wrapper import SyncClientWrapper
10
5
  from ..core.request_options import RequestOptions
11
6
  from ..types.annotation import Annotation
7
+ from ..core.jsonable_encoder import jsonable_encoder
8
+ from ..core.pydantic_utilities import parse_obj_as
9
+ from json.decoder import JSONDecodeError
10
+ from ..core.api_error import ApiError
11
+ from .types.annotations_create_bulk_request_selected_items import AnnotationsCreateBulkRequestSelectedItems
12
12
  from .types.annotations_create_bulk_response_item import AnnotationsCreateBulkResponseItem
13
+ from ..core.serialization import convert_and_respect_annotation_metadata
14
+ from ..core.client_wrapper import AsyncClientWrapper
13
15
 
14
16
  # this is used as the default value for optional parameters
15
17
  OMIT = typing.cast(typing.Any, ...)
@@ -21,6 +23,7 @@ class AnnotationsClient:
21
23
 
22
24
  def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Annotation:
23
25
  """
26
+
24
27
  Tasks can have multiple annotations. Use this call to retrieve a specific annotation using its ID.
25
28
 
26
29
  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.
@@ -40,7 +43,7 @@ class AnnotationsClient:
40
43
 
41
44
  Examples
42
45
  --------
43
- from label_studio_sdk.client import LabelStudio
46
+ from label_studio_sdk import LabelStudio
44
47
 
45
48
  client = LabelStudio(
46
49
  api_key="YOUR_API_KEY",
@@ -50,11 +53,19 @@ class AnnotationsClient:
50
53
  )
51
54
  """
52
55
  _response = self._client_wrapper.httpx_client.request(
53
- f"api/annotations/{jsonable_encoder(id)}/", method="GET", request_options=request_options
56
+ f"api/annotations/{jsonable_encoder(id)}/",
57
+ method="GET",
58
+ request_options=request_options,
54
59
  )
55
60
  try:
56
61
  if 200 <= _response.status_code < 300:
57
- return pydantic_v1.parse_obj_as(Annotation, _response.json()) # type: ignore
62
+ return typing.cast(
63
+ Annotation,
64
+ parse_obj_as(
65
+ type_=Annotation, # type: ignore
66
+ object_=_response.json(),
67
+ ),
68
+ )
58
69
  _response_json = _response.json()
59
70
  except JSONDecodeError:
60
71
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -62,6 +73,7 @@ class AnnotationsClient:
62
73
 
63
74
  def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
64
75
  """
76
+
65
77
  Delete an annotation.
66
78
 
67
79
  <Warning>This action can't be undone!</Warning>
@@ -82,7 +94,7 @@ class AnnotationsClient:
82
94
 
83
95
  Examples
84
96
  --------
85
- from label_studio_sdk.client import LabelStudio
97
+ from label_studio_sdk import LabelStudio
86
98
 
87
99
  client = LabelStudio(
88
100
  api_key="YOUR_API_KEY",
@@ -92,7 +104,9 @@ class AnnotationsClient:
92
104
  )
93
105
  """
94
106
  _response = self._client_wrapper.httpx_client.request(
95
- f"api/annotations/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
107
+ f"api/annotations/{jsonable_encoder(id)}/",
108
+ method="DELETE",
109
+ request_options=request_options,
96
110
  )
97
111
  try:
98
112
  if 200 <= _response.status_code < 300:
@@ -106,7 +120,7 @@ class AnnotationsClient:
106
120
  self,
107
121
  id: int,
108
122
  *,
109
- result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
123
+ result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
110
124
  task: typing.Optional[int] = OMIT,
111
125
  project: typing.Optional[int] = OMIT,
112
126
  completed_by: typing.Optional[int] = OMIT,
@@ -117,6 +131,7 @@ class AnnotationsClient:
117
131
  request_options: typing.Optional[RequestOptions] = None,
118
132
  ) -> Annotation:
119
133
  """
134
+
120
135
  Update attributes for an existing annotation.
121
136
 
122
137
  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.
@@ -128,7 +143,7 @@ class AnnotationsClient:
128
143
  id : int
129
144
  A unique integer value identifying this annotation.
130
145
 
131
- result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
146
+ result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
132
147
  Labeling result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/task_format)
133
148
 
134
149
  task : typing.Optional[int]
@@ -162,7 +177,7 @@ class AnnotationsClient:
162
177
 
163
178
  Examples
164
179
  --------
165
- from label_studio_sdk.client import LabelStudio
180
+ from label_studio_sdk import LabelStudio
166
181
 
167
182
  client = LabelStudio(
168
183
  api_key="YOUR_API_KEY",
@@ -204,12 +219,21 @@ class AnnotationsClient:
204
219
  "ground_truth": ground_truth,
205
220
  "lead_time": lead_time,
206
221
  },
222
+ headers={
223
+ "content-type": "application/json",
224
+ },
207
225
  request_options=request_options,
208
226
  omit=OMIT,
209
227
  )
210
228
  try:
211
229
  if 200 <= _response.status_code < 300:
212
- return pydantic_v1.parse_obj_as(Annotation, _response.json()) # type: ignore
230
+ return typing.cast(
231
+ Annotation,
232
+ parse_obj_as(
233
+ type_=Annotation, # type: ignore
234
+ object_=_response.json(),
235
+ ),
236
+ )
213
237
  _response_json = _response.json()
214
238
  except JSONDecodeError:
215
239
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -217,6 +241,7 @@ class AnnotationsClient:
217
241
 
218
242
  def list(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Annotation]:
219
243
  """
244
+
220
245
  List all annotations for a task.
221
246
 
222
247
  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).
@@ -236,7 +261,7 @@ class AnnotationsClient:
236
261
 
237
262
  Examples
238
263
  --------
239
- from label_studio_sdk.client import LabelStudio
264
+ from label_studio_sdk import LabelStudio
240
265
 
241
266
  client = LabelStudio(
242
267
  api_key="YOUR_API_KEY",
@@ -246,11 +271,19 @@ class AnnotationsClient:
246
271
  )
247
272
  """
248
273
  _response = self._client_wrapper.httpx_client.request(
249
- f"api/tasks/{jsonable_encoder(id)}/annotations/", method="GET", request_options=request_options
274
+ f"api/tasks/{jsonable_encoder(id)}/annotations/",
275
+ method="GET",
276
+ request_options=request_options,
250
277
  )
251
278
  try:
252
279
  if 200 <= _response.status_code < 300:
253
- return pydantic_v1.parse_obj_as(typing.List[Annotation], _response.json()) # type: ignore
280
+ return typing.cast(
281
+ typing.List[Annotation],
282
+ parse_obj_as(
283
+ type_=typing.List[Annotation], # type: ignore
284
+ object_=_response.json(),
285
+ ),
286
+ )
254
287
  _response_json = _response.json()
255
288
  except JSONDecodeError:
256
289
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -260,7 +293,7 @@ class AnnotationsClient:
260
293
  self,
261
294
  id: int,
262
295
  *,
263
- result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
296
+ result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
264
297
  task: typing.Optional[int] = OMIT,
265
298
  project: typing.Optional[int] = OMIT,
266
299
  completed_by: typing.Optional[int] = OMIT,
@@ -271,10 +304,12 @@ class AnnotationsClient:
271
304
  request_options: typing.Optional[RequestOptions] = None,
272
305
  ) -> Annotation:
273
306
  """
307
+
274
308
  Add annotations to a task like an annotator does.
275
309
 
276
310
  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).
277
311
 
312
+
278
313
  The content of the result field depends on your labeling configuration. For example, send the following data as part of your POST
279
314
  request to send an empty annotation with the ID of the user who completed the task:
280
315
 
@@ -294,7 +329,7 @@ class AnnotationsClient:
294
329
  id : int
295
330
  Task ID
296
331
 
297
- result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
332
+ result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
298
333
  Labeling result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/task_format)
299
334
 
300
335
  task : typing.Optional[int]
@@ -328,7 +363,7 @@ class AnnotationsClient:
328
363
 
329
364
  Examples
330
365
  --------
331
- from label_studio_sdk.client import LabelStudio
366
+ from label_studio_sdk import LabelStudio
332
367
 
333
368
  client = LabelStudio(
334
369
  api_key="YOUR_API_KEY",
@@ -370,12 +405,21 @@ class AnnotationsClient:
370
405
  "ground_truth": ground_truth,
371
406
  "lead_time": lead_time,
372
407
  },
408
+ headers={
409
+ "content-type": "application/json",
410
+ },
373
411
  request_options=request_options,
374
412
  omit=OMIT,
375
413
  )
376
414
  try:
377
415
  if 200 <= _response.status_code < 300:
378
- return pydantic_v1.parse_obj_as(Annotation, _response.json()) # type: ignore
416
+ return typing.cast(
417
+ Annotation,
418
+ parse_obj_as(
419
+ type_=Annotation, # type: ignore
420
+ object_=_response.json(),
421
+ ),
422
+ )
379
423
  _response_json = _response.json()
380
424
  except JSONDecodeError:
381
425
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -385,9 +429,10 @@ class AnnotationsClient:
385
429
  self,
386
430
  *,
387
431
  tasks: typing.Optional[typing.Sequence[int]] = OMIT,
432
+ selected_items: typing.Optional[AnnotationsCreateBulkRequestSelectedItems] = OMIT,
388
433
  lead_time: typing.Optional[float] = OMIT,
389
434
  project: typing.Optional[int] = OMIT,
390
- result: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
435
+ result: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
391
436
  request_options: typing.Optional[RequestOptions] = None,
392
437
  ) -> typing.List[AnnotationsCreateBulkResponseItem]:
393
438
  """
@@ -397,11 +442,13 @@ class AnnotationsClient:
397
442
  ----------
398
443
  tasks : typing.Optional[typing.Sequence[int]]
399
444
 
445
+ selected_items : typing.Optional[AnnotationsCreateBulkRequestSelectedItems]
446
+
400
447
  lead_time : typing.Optional[float]
401
448
 
402
449
  project : typing.Optional[int]
403
450
 
404
- result : typing.Optional[typing.Dict[str, typing.Any]]
451
+ result : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
405
452
 
406
453
  request_options : typing.Optional[RequestOptions]
407
454
  Request-specific configuration.
@@ -413,7 +460,7 @@ class AnnotationsClient:
413
460
 
414
461
  Examples
415
462
  --------
416
- from label_studio_sdk.client import LabelStudio
463
+ from label_studio_sdk import LabelStudio
417
464
 
418
465
  client = LabelStudio(
419
466
  api_key="YOUR_API_KEY",
@@ -423,13 +470,30 @@ class AnnotationsClient:
423
470
  _response = self._client_wrapper.httpx_client.request(
424
471
  "api/annotations/bulk",
425
472
  method="POST",
426
- json={"tasks": tasks, "lead_time": lead_time, "project": project, "result": result},
473
+ json={
474
+ "tasks": tasks,
475
+ "selectedItems": convert_and_respect_annotation_metadata(
476
+ object_=selected_items, annotation=AnnotationsCreateBulkRequestSelectedItems, direction="write"
477
+ ),
478
+ "lead_time": lead_time,
479
+ "project": project,
480
+ "result": result,
481
+ },
482
+ headers={
483
+ "content-type": "application/json",
484
+ },
427
485
  request_options=request_options,
428
486
  omit=OMIT,
429
487
  )
430
488
  try:
431
489
  if 200 <= _response.status_code < 300:
432
- return pydantic_v1.parse_obj_as(typing.List[AnnotationsCreateBulkResponseItem], _response.json()) # type: ignore
490
+ return typing.cast(
491
+ typing.List[AnnotationsCreateBulkResponseItem],
492
+ parse_obj_as(
493
+ type_=typing.List[AnnotationsCreateBulkResponseItem], # type: ignore
494
+ object_=_response.json(),
495
+ ),
496
+ )
433
497
  _response_json = _response.json()
434
498
  except JSONDecodeError:
435
499
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -442,6 +506,7 @@ class AsyncAnnotationsClient:
442
506
 
443
507
  async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Annotation:
444
508
  """
509
+
445
510
  Tasks can have multiple annotations. Use this call to retrieve a specific annotation using its ID.
446
511
 
447
512
  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.
@@ -461,21 +526,37 @@ class AsyncAnnotationsClient:
461
526
 
462
527
  Examples
463
528
  --------
464
- from label_studio_sdk.client import AsyncLabelStudio
529
+ import asyncio
530
+
531
+ from label_studio_sdk import AsyncLabelStudio
465
532
 
466
533
  client = AsyncLabelStudio(
467
534
  api_key="YOUR_API_KEY",
468
535
  )
469
- await client.annotations.get(
470
- id=1,
471
- )
536
+
537
+
538
+ async def main() -> None:
539
+ await client.annotations.get(
540
+ id=1,
541
+ )
542
+
543
+
544
+ asyncio.run(main())
472
545
  """
473
546
  _response = await self._client_wrapper.httpx_client.request(
474
- f"api/annotations/{jsonable_encoder(id)}/", method="GET", request_options=request_options
547
+ f"api/annotations/{jsonable_encoder(id)}/",
548
+ method="GET",
549
+ request_options=request_options,
475
550
  )
476
551
  try:
477
552
  if 200 <= _response.status_code < 300:
478
- return pydantic_v1.parse_obj_as(Annotation, _response.json()) # type: ignore
553
+ return typing.cast(
554
+ Annotation,
555
+ parse_obj_as(
556
+ type_=Annotation, # type: ignore
557
+ object_=_response.json(),
558
+ ),
559
+ )
479
560
  _response_json = _response.json()
480
561
  except JSONDecodeError:
481
562
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -483,6 +564,7 @@ class AsyncAnnotationsClient:
483
564
 
484
565
  async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
485
566
  """
567
+
486
568
  Delete an annotation.
487
569
 
488
570
  <Warning>This action can't be undone!</Warning>
@@ -503,17 +585,27 @@ class AsyncAnnotationsClient:
503
585
 
504
586
  Examples
505
587
  --------
506
- from label_studio_sdk.client import AsyncLabelStudio
588
+ import asyncio
589
+
590
+ from label_studio_sdk import AsyncLabelStudio
507
591
 
508
592
  client = AsyncLabelStudio(
509
593
  api_key="YOUR_API_KEY",
510
594
  )
511
- await client.annotations.delete(
512
- id=1,
513
- )
595
+
596
+
597
+ async def main() -> None:
598
+ await client.annotations.delete(
599
+ id=1,
600
+ )
601
+
602
+
603
+ asyncio.run(main())
514
604
  """
515
605
  _response = await self._client_wrapper.httpx_client.request(
516
- f"api/annotations/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
606
+ f"api/annotations/{jsonable_encoder(id)}/",
607
+ method="DELETE",
608
+ request_options=request_options,
517
609
  )
518
610
  try:
519
611
  if 200 <= _response.status_code < 300:
@@ -527,7 +619,7 @@ class AsyncAnnotationsClient:
527
619
  self,
528
620
  id: int,
529
621
  *,
530
- result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
622
+ result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
531
623
  task: typing.Optional[int] = OMIT,
532
624
  project: typing.Optional[int] = OMIT,
533
625
  completed_by: typing.Optional[int] = OMIT,
@@ -538,6 +630,7 @@ class AsyncAnnotationsClient:
538
630
  request_options: typing.Optional[RequestOptions] = None,
539
631
  ) -> Annotation:
540
632
  """
633
+
541
634
  Update attributes for an existing annotation.
542
635
 
543
636
  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.
@@ -549,7 +642,7 @@ class AsyncAnnotationsClient:
549
642
  id : int
550
643
  A unique integer value identifying this annotation.
551
644
 
552
- result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
645
+ result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
553
646
  Labeling result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/task_format)
554
647
 
555
648
  task : typing.Optional[int]
@@ -583,34 +676,42 @@ class AsyncAnnotationsClient:
583
676
 
584
677
  Examples
585
678
  --------
586
- from label_studio_sdk.client import AsyncLabelStudio
679
+ import asyncio
680
+
681
+ from label_studio_sdk import AsyncLabelStudio
587
682
 
588
683
  client = AsyncLabelStudio(
589
684
  api_key="YOUR_API_KEY",
590
685
  )
591
- await client.annotations.update(
592
- id=1,
593
- result=[
594
- {
595
- "original_width": 1920,
596
- "original_height": 1080,
597
- "image_rotation": 0,
598
- "from_name": "bboxes",
599
- "to_name": "image",
600
- "type": "rectanglelabels",
601
- "value": {
602
- "x": 20,
603
- "y": 30,
604
- "width": 50,
605
- "height": 60,
606
- "rotation": 0,
607
- "values": {"rectanglelabels": ["Person"]},
608
- },
609
- }
610
- ],
611
- was_cancelled=False,
612
- ground_truth=True,
613
- )
686
+
687
+
688
+ async def main() -> None:
689
+ await client.annotations.update(
690
+ id=1,
691
+ result=[
692
+ {
693
+ "original_width": 1920,
694
+ "original_height": 1080,
695
+ "image_rotation": 0,
696
+ "from_name": "bboxes",
697
+ "to_name": "image",
698
+ "type": "rectanglelabels",
699
+ "value": {
700
+ "x": 20,
701
+ "y": 30,
702
+ "width": 50,
703
+ "height": 60,
704
+ "rotation": 0,
705
+ "values": {"rectanglelabels": ["Person"]},
706
+ },
707
+ }
708
+ ],
709
+ was_cancelled=False,
710
+ ground_truth=True,
711
+ )
712
+
713
+
714
+ asyncio.run(main())
614
715
  """
615
716
  _response = await self._client_wrapper.httpx_client.request(
616
717
  f"api/annotations/{jsonable_encoder(id)}/",
@@ -625,12 +726,21 @@ class AsyncAnnotationsClient:
625
726
  "ground_truth": ground_truth,
626
727
  "lead_time": lead_time,
627
728
  },
729
+ headers={
730
+ "content-type": "application/json",
731
+ },
628
732
  request_options=request_options,
629
733
  omit=OMIT,
630
734
  )
631
735
  try:
632
736
  if 200 <= _response.status_code < 300:
633
- return pydantic_v1.parse_obj_as(Annotation, _response.json()) # type: ignore
737
+ return typing.cast(
738
+ Annotation,
739
+ parse_obj_as(
740
+ type_=Annotation, # type: ignore
741
+ object_=_response.json(),
742
+ ),
743
+ )
634
744
  _response_json = _response.json()
635
745
  except JSONDecodeError:
636
746
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -640,6 +750,7 @@ class AsyncAnnotationsClient:
640
750
  self, id: int, *, request_options: typing.Optional[RequestOptions] = None
641
751
  ) -> typing.List[Annotation]:
642
752
  """
753
+
643
754
  List all annotations for a task.
644
755
 
645
756
  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).
@@ -659,21 +770,37 @@ class AsyncAnnotationsClient:
659
770
 
660
771
  Examples
661
772
  --------
662
- from label_studio_sdk.client import AsyncLabelStudio
773
+ import asyncio
774
+
775
+ from label_studio_sdk import AsyncLabelStudio
663
776
 
664
777
  client = AsyncLabelStudio(
665
778
  api_key="YOUR_API_KEY",
666
779
  )
667
- await client.annotations.list(
668
- id=1,
669
- )
780
+
781
+
782
+ async def main() -> None:
783
+ await client.annotations.list(
784
+ id=1,
785
+ )
786
+
787
+
788
+ asyncio.run(main())
670
789
  """
671
790
  _response = await self._client_wrapper.httpx_client.request(
672
- f"api/tasks/{jsonable_encoder(id)}/annotations/", method="GET", request_options=request_options
791
+ f"api/tasks/{jsonable_encoder(id)}/annotations/",
792
+ method="GET",
793
+ request_options=request_options,
673
794
  )
674
795
  try:
675
796
  if 200 <= _response.status_code < 300:
676
- return pydantic_v1.parse_obj_as(typing.List[Annotation], _response.json()) # type: ignore
797
+ return typing.cast(
798
+ typing.List[Annotation],
799
+ parse_obj_as(
800
+ type_=typing.List[Annotation], # type: ignore
801
+ object_=_response.json(),
802
+ ),
803
+ )
677
804
  _response_json = _response.json()
678
805
  except JSONDecodeError:
679
806
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -683,7 +810,7 @@ class AsyncAnnotationsClient:
683
810
  self,
684
811
  id: int,
685
812
  *,
686
- result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]] = OMIT,
813
+ result: typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]] = OMIT,
687
814
  task: typing.Optional[int] = OMIT,
688
815
  project: typing.Optional[int] = OMIT,
689
816
  completed_by: typing.Optional[int] = OMIT,
@@ -694,10 +821,12 @@ class AsyncAnnotationsClient:
694
821
  request_options: typing.Optional[RequestOptions] = None,
695
822
  ) -> Annotation:
696
823
  """
824
+
697
825
  Add annotations to a task like an annotator does.
698
826
 
699
827
  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).
700
828
 
829
+
701
830
  The content of the result field depends on your labeling configuration. For example, send the following data as part of your POST
702
831
  request to send an empty annotation with the ID of the user who completed the task:
703
832
 
@@ -717,7 +846,7 @@ class AsyncAnnotationsClient:
717
846
  id : int
718
847
  Task ID
719
848
 
720
- result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Any]]]
849
+ result : typing.Optional[typing.Sequence[typing.Dict[str, typing.Optional[typing.Any]]]]
721
850
  Labeling result in JSON format. Read more about the format in [the Label Studio documentation.](https://labelstud.io/guide/task_format)
722
851
 
723
852
  task : typing.Optional[int]
@@ -751,34 +880,42 @@ class AsyncAnnotationsClient:
751
880
 
752
881
  Examples
753
882
  --------
754
- from label_studio_sdk.client import AsyncLabelStudio
883
+ import asyncio
884
+
885
+ from label_studio_sdk import AsyncLabelStudio
755
886
 
756
887
  client = AsyncLabelStudio(
757
888
  api_key="YOUR_API_KEY",
758
889
  )
759
- await client.annotations.create(
760
- id=1,
761
- result=[
762
- {
763
- "original_width": 1920,
764
- "original_height": 1080,
765
- "image_rotation": 0,
766
- "from_name": "bboxes",
767
- "to_name": "image",
768
- "type": "rectanglelabels",
769
- "value": {
770
- "x": 20,
771
- "y": 30,
772
- "width": 50,
773
- "height": 60,
774
- "rotation": 0,
775
- "values": {"rectanglelabels": ["Person"]},
776
- },
777
- }
778
- ],
779
- was_cancelled=False,
780
- ground_truth=True,
781
- )
890
+
891
+
892
+ async def main() -> None:
893
+ await client.annotations.create(
894
+ id=1,
895
+ result=[
896
+ {
897
+ "original_width": 1920,
898
+ "original_height": 1080,
899
+ "image_rotation": 0,
900
+ "from_name": "bboxes",
901
+ "to_name": "image",
902
+ "type": "rectanglelabels",
903
+ "value": {
904
+ "x": 20,
905
+ "y": 30,
906
+ "width": 50,
907
+ "height": 60,
908
+ "rotation": 0,
909
+ "values": {"rectanglelabels": ["Person"]},
910
+ },
911
+ }
912
+ ],
913
+ was_cancelled=False,
914
+ ground_truth=True,
915
+ )
916
+
917
+
918
+ asyncio.run(main())
782
919
  """
783
920
  _response = await self._client_wrapper.httpx_client.request(
784
921
  f"api/tasks/{jsonable_encoder(id)}/annotations/",
@@ -793,12 +930,21 @@ class AsyncAnnotationsClient:
793
930
  "ground_truth": ground_truth,
794
931
  "lead_time": lead_time,
795
932
  },
933
+ headers={
934
+ "content-type": "application/json",
935
+ },
796
936
  request_options=request_options,
797
937
  omit=OMIT,
798
938
  )
799
939
  try:
800
940
  if 200 <= _response.status_code < 300:
801
- return pydantic_v1.parse_obj_as(Annotation, _response.json()) # type: ignore
941
+ return typing.cast(
942
+ Annotation,
943
+ parse_obj_as(
944
+ type_=Annotation, # type: ignore
945
+ object_=_response.json(),
946
+ ),
947
+ )
802
948
  _response_json = _response.json()
803
949
  except JSONDecodeError:
804
950
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -808,9 +954,10 @@ class AsyncAnnotationsClient:
808
954
  self,
809
955
  *,
810
956
  tasks: typing.Optional[typing.Sequence[int]] = OMIT,
957
+ selected_items: typing.Optional[AnnotationsCreateBulkRequestSelectedItems] = OMIT,
811
958
  lead_time: typing.Optional[float] = OMIT,
812
959
  project: typing.Optional[int] = OMIT,
813
- result: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
960
+ result: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
814
961
  request_options: typing.Optional[RequestOptions] = None,
815
962
  ) -> typing.List[AnnotationsCreateBulkResponseItem]:
816
963
  """
@@ -820,11 +967,13 @@ class AsyncAnnotationsClient:
820
967
  ----------
821
968
  tasks : typing.Optional[typing.Sequence[int]]
822
969
 
970
+ selected_items : typing.Optional[AnnotationsCreateBulkRequestSelectedItems]
971
+
823
972
  lead_time : typing.Optional[float]
824
973
 
825
974
  project : typing.Optional[int]
826
975
 
827
- result : typing.Optional[typing.Dict[str, typing.Any]]
976
+ result : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
828
977
 
829
978
  request_options : typing.Optional[RequestOptions]
830
979
  Request-specific configuration.
@@ -836,23 +985,48 @@ class AsyncAnnotationsClient:
836
985
 
837
986
  Examples
838
987
  --------
839
- from label_studio_sdk.client import AsyncLabelStudio
988
+ import asyncio
989
+
990
+ from label_studio_sdk import AsyncLabelStudio
840
991
 
841
992
  client = AsyncLabelStudio(
842
993
  api_key="YOUR_API_KEY",
843
994
  )
844
- await client.annotations.create_bulk()
995
+
996
+
997
+ async def main() -> None:
998
+ await client.annotations.create_bulk()
999
+
1000
+
1001
+ asyncio.run(main())
845
1002
  """
846
1003
  _response = await self._client_wrapper.httpx_client.request(
847
1004
  "api/annotations/bulk",
848
1005
  method="POST",
849
- json={"tasks": tasks, "lead_time": lead_time, "project": project, "result": result},
1006
+ json={
1007
+ "tasks": tasks,
1008
+ "selectedItems": convert_and_respect_annotation_metadata(
1009
+ object_=selected_items, annotation=AnnotationsCreateBulkRequestSelectedItems, direction="write"
1010
+ ),
1011
+ "lead_time": lead_time,
1012
+ "project": project,
1013
+ "result": result,
1014
+ },
1015
+ headers={
1016
+ "content-type": "application/json",
1017
+ },
850
1018
  request_options=request_options,
851
1019
  omit=OMIT,
852
1020
  )
853
1021
  try:
854
1022
  if 200 <= _response.status_code < 300:
855
- return pydantic_v1.parse_obj_as(typing.List[AnnotationsCreateBulkResponseItem], _response.json()) # type: ignore
1023
+ return typing.cast(
1024
+ typing.List[AnnotationsCreateBulkResponseItem],
1025
+ parse_obj_as(
1026
+ type_=typing.List[AnnotationsCreateBulkResponseItem], # type: ignore
1027
+ object_=_response.json(),
1028
+ ),
1029
+ )
856
1030
  _response_json = _response.json()
857
1031
  except JSONDecodeError:
858
1032
  raise ApiError(status_code=_response.status_code, body=_response.text)