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.

Files changed (200) hide show
  1. label_studio_sdk/__init__.py +20 -7
  2. label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +16 -4
  3. label_studio_sdk/_extensions/pager_ext.py +8 -0
  4. label_studio_sdk/actions/client.py +91 -40
  5. label_studio_sdk/actions/types/actions_create_request_filters.py +14 -24
  6. label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +16 -26
  7. label_studio_sdk/actions/types/actions_create_request_filters_items_item_value.py +3 -1
  8. label_studio_sdk/actions/types/actions_create_request_selected_items.py +1 -2
  9. label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +15 -25
  10. label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +15 -25
  11. label_studio_sdk/annotations/__init__.py +2 -2
  12. label_studio_sdk/annotations/client.py +278 -104
  13. label_studio_sdk/annotations/types/__init__.py +2 -1
  14. label_studio_sdk/annotations/types/annotations_create_bulk_request_selected_items.py +34 -0
  15. label_studio_sdk/annotations/types/annotations_create_bulk_response_item.py +11 -21
  16. label_studio_sdk/base_client.py +46 -27
  17. label_studio_sdk/client.py +1 -0
  18. label_studio_sdk/comments/client.py +190 -44
  19. label_studio_sdk/converter/converter.py +56 -13
  20. label_studio_sdk/converter/imports/yolo.py +1 -1
  21. label_studio_sdk/converter/utils.py +3 -2
  22. label_studio_sdk/core/__init__.py +21 -4
  23. label_studio_sdk/core/client_wrapper.py +9 -10
  24. label_studio_sdk/core/file.py +37 -8
  25. label_studio_sdk/core/http_client.py +52 -28
  26. label_studio_sdk/core/jsonable_encoder.py +33 -31
  27. label_studio_sdk/core/pagination.py +5 -4
  28. label_studio_sdk/core/pydantic_utilities.py +272 -4
  29. label_studio_sdk/core/query_encoder.py +38 -13
  30. label_studio_sdk/core/request_options.py +3 -0
  31. label_studio_sdk/core/serialization.py +272 -0
  32. label_studio_sdk/errors/bad_request_error.py +2 -3
  33. label_studio_sdk/export_storage/azure/client.py +228 -58
  34. label_studio_sdk/export_storage/azure/types/azure_create_response.py +19 -29
  35. label_studio_sdk/export_storage/azure/types/azure_update_response.py +19 -29
  36. label_studio_sdk/export_storage/client.py +48 -18
  37. label_studio_sdk/export_storage/gcs/client.py +228 -58
  38. label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +19 -29
  39. label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +19 -29
  40. label_studio_sdk/export_storage/local/client.py +222 -56
  41. label_studio_sdk/export_storage/local/types/local_create_response.py +17 -27
  42. label_studio_sdk/export_storage/local/types/local_update_response.py +17 -27
  43. label_studio_sdk/export_storage/redis/client.py +228 -58
  44. label_studio_sdk/export_storage/redis/types/redis_create_response.py +20 -30
  45. label_studio_sdk/export_storage/redis/types/redis_update_response.py +20 -30
  46. label_studio_sdk/export_storage/s3/client.py +228 -58
  47. label_studio_sdk/export_storage/s3/types/s3create_response.py +27 -35
  48. label_studio_sdk/export_storage/s3/types/s3update_response.py +27 -35
  49. label_studio_sdk/export_storage/s3s/client.py +187 -43
  50. label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +11 -21
  51. label_studio_sdk/files/client.py +172 -56
  52. label_studio_sdk/import_storage/azure/client.py +223 -53
  53. label_studio_sdk/import_storage/azure/types/azure_create_response.py +22 -32
  54. label_studio_sdk/import_storage/azure/types/azure_update_response.py +22 -32
  55. label_studio_sdk/import_storage/client.py +48 -18
  56. label_studio_sdk/import_storage/gcs/client.py +223 -53
  57. label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +22 -32
  58. label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +22 -32
  59. label_studio_sdk/import_storage/local/client.py +223 -53
  60. label_studio_sdk/import_storage/local/types/local_create_response.py +17 -27
  61. label_studio_sdk/import_storage/local/types/local_update_response.py +17 -27
  62. label_studio_sdk/import_storage/redis/client.py +223 -53
  63. label_studio_sdk/import_storage/redis/types/redis_create_response.py +20 -30
  64. label_studio_sdk/import_storage/redis/types/redis_update_response.py +20 -30
  65. label_studio_sdk/import_storage/s3/client.py +223 -53
  66. label_studio_sdk/import_storage/s3/types/s3create_response.py +31 -39
  67. label_studio_sdk/import_storage/s3/types/s3update_response.py +31 -39
  68. label_studio_sdk/import_storage/s3s/client.py +222 -52
  69. label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +11 -21
  70. label_studio_sdk/label_interface/control_tags.py +1 -1
  71. label_studio_sdk/ml/client.py +280 -78
  72. label_studio_sdk/ml/types/ml_create_response.py +21 -31
  73. label_studio_sdk/ml/types/ml_update_response.py +21 -31
  74. label_studio_sdk/model_providers/client.py +173 -56
  75. label_studio_sdk/predictions/client.py +247 -101
  76. label_studio_sdk/projects/__init__.py +3 -0
  77. label_studio_sdk/projects/client.py +309 -115
  78. label_studio_sdk/projects/client_ext.py +16 -0
  79. label_studio_sdk/projects/exports/__init__.py +3 -0
  80. label_studio_sdk/projects/exports/client.py +447 -296
  81. label_studio_sdk/projects/exports/client_ext.py +134 -0
  82. label_studio_sdk/projects/exports/types/__init__.py +6 -0
  83. label_studio_sdk/projects/exports/types/exports_convert_response.py +24 -0
  84. label_studio_sdk/projects/exports/types/exports_list_formats_response_item.py +44 -0
  85. label_studio_sdk/projects/types/projects_create_response.py +29 -34
  86. label_studio_sdk/projects/types/projects_import_tasks_response.py +19 -29
  87. label_studio_sdk/projects/types/projects_list_response.py +11 -21
  88. label_studio_sdk/projects/types/projects_update_response.py +24 -34
  89. label_studio_sdk/prompts/client.py +309 -92
  90. label_studio_sdk/prompts/indicators/client.py +67 -23
  91. label_studio_sdk/prompts/runs/client.py +95 -40
  92. label_studio_sdk/prompts/types/prompts_batch_failed_predictions_request_failed_predictions_item.py +14 -24
  93. label_studio_sdk/prompts/types/prompts_batch_failed_predictions_response.py +11 -21
  94. label_studio_sdk/prompts/types/prompts_batch_predictions_request_results_item.py +26 -29
  95. label_studio_sdk/prompts/types/prompts_batch_predictions_response.py +11 -21
  96. label_studio_sdk/prompts/versions/client.py +277 -88
  97. label_studio_sdk/tasks/client.py +263 -90
  98. label_studio_sdk/tasks/types/tasks_list_response.py +15 -25
  99. label_studio_sdk/types/__init__.py +10 -6
  100. label_studio_sdk/types/annotation.py +29 -38
  101. label_studio_sdk/types/annotation_filter_options.py +14 -24
  102. label_studio_sdk/types/annotations_dm_field.py +30 -39
  103. label_studio_sdk/types/azure_blob_export_storage.py +28 -37
  104. label_studio_sdk/types/azure_blob_import_storage.py +28 -37
  105. label_studio_sdk/types/base_task.py +30 -39
  106. label_studio_sdk/types/base_task_updated_by.py +3 -1
  107. label_studio_sdk/types/base_user.py +14 -21
  108. label_studio_sdk/types/comment.py +12 -21
  109. label_studio_sdk/types/comment_created_by.py +1 -1
  110. label_studio_sdk/types/converted_format.py +12 -22
  111. label_studio_sdk/types/data_manager_task_serializer.py +31 -40
  112. label_studio_sdk/types/data_manager_task_serializer_annotators_item.py +1 -1
  113. label_studio_sdk/types/data_manager_task_serializer_drafts_item.py +13 -22
  114. label_studio_sdk/types/data_manager_task_serializer_predictions_item.py +15 -24
  115. label_studio_sdk/types/export.py +17 -26
  116. label_studio_sdk/types/export_format.py +25 -0
  117. label_studio_sdk/types/export_snapshot.py +45 -0
  118. label_studio_sdk/types/export_snapshot_status.py +5 -0
  119. label_studio_sdk/types/file_upload.py +11 -21
  120. label_studio_sdk/types/filter.py +16 -26
  121. label_studio_sdk/types/filter_group.py +12 -22
  122. label_studio_sdk/types/gcs_export_storage.py +28 -37
  123. label_studio_sdk/types/gcs_import_storage.py +28 -37
  124. label_studio_sdk/types/inference_run.py +14 -23
  125. label_studio_sdk/types/inference_run_cost_estimate.py +17 -27
  126. label_studio_sdk/types/inference_run_created_by.py +1 -1
  127. label_studio_sdk/types/inference_run_organization.py +1 -1
  128. label_studio_sdk/types/key_indicator_value.py +12 -22
  129. label_studio_sdk/types/key_indicators.py +0 -1
  130. label_studio_sdk/types/key_indicators_item.py +15 -25
  131. label_studio_sdk/types/key_indicators_item_additional_kpis_item.py +13 -23
  132. label_studio_sdk/types/key_indicators_item_extra_kpis_item.py +13 -23
  133. label_studio_sdk/types/local_files_export_storage.py +25 -34
  134. label_studio_sdk/types/local_files_import_storage.py +24 -33
  135. label_studio_sdk/types/ml_backend.py +23 -32
  136. label_studio_sdk/types/model_provider_connection.py +22 -31
  137. label_studio_sdk/types/model_provider_connection_created_by.py +1 -1
  138. label_studio_sdk/types/model_provider_connection_organization.py +1 -1
  139. label_studio_sdk/types/model_provider_connection_provider.py +3 -1
  140. label_studio_sdk/types/prediction.py +21 -30
  141. label_studio_sdk/types/project.py +48 -55
  142. label_studio_sdk/types/project_import.py +21 -30
  143. label_studio_sdk/types/project_label_config.py +12 -22
  144. label_studio_sdk/types/prompt.py +24 -32
  145. label_studio_sdk/types/prompt_associated_projects_item.py +6 -0
  146. label_studio_sdk/types/prompt_associated_projects_item_id.py +20 -0
  147. label_studio_sdk/types/prompt_created_by.py +1 -1
  148. label_studio_sdk/types/prompt_organization.py +1 -1
  149. label_studio_sdk/types/prompt_version.py +13 -22
  150. label_studio_sdk/types/prompt_version_created_by.py +1 -1
  151. label_studio_sdk/types/prompt_version_organization.py +1 -1
  152. label_studio_sdk/types/prompt_version_provider.py +3 -1
  153. label_studio_sdk/types/redis_export_storage.py +29 -38
  154. label_studio_sdk/types/redis_import_storage.py +28 -37
  155. label_studio_sdk/types/refined_prompt_response.py +19 -29
  156. label_studio_sdk/types/s3export_storage.py +36 -43
  157. label_studio_sdk/types/s3import_storage.py +37 -44
  158. label_studio_sdk/types/s3s_export_storage.py +26 -33
  159. label_studio_sdk/types/s3s_import_storage.py +35 -42
  160. label_studio_sdk/types/serialization_option.py +12 -22
  161. label_studio_sdk/types/serialization_options.py +18 -28
  162. label_studio_sdk/types/task.py +44 -47
  163. label_studio_sdk/types/task_annotators_item.py +1 -1
  164. label_studio_sdk/types/task_comment_authors_item.py +1 -1
  165. label_studio_sdk/types/task_filter_options.py +15 -25
  166. label_studio_sdk/types/user_simple.py +11 -21
  167. label_studio_sdk/types/view.py +16 -26
  168. label_studio_sdk/types/webhook.py +19 -28
  169. label_studio_sdk/types/webhook_serializer_for_update.py +19 -28
  170. label_studio_sdk/types/workspace.py +22 -31
  171. label_studio_sdk/users/client.py +257 -63
  172. label_studio_sdk/users/types/users_get_token_response.py +12 -22
  173. label_studio_sdk/users/types/users_reset_token_response.py +12 -22
  174. label_studio_sdk/version.py +0 -1
  175. label_studio_sdk/versions/__init__.py +5 -0
  176. label_studio_sdk/versions/client.py +112 -0
  177. label_studio_sdk/versions/types/__init__.py +6 -0
  178. label_studio_sdk/versions/types/versions_get_response.py +73 -0
  179. label_studio_sdk/versions/types/versions_get_response_edition.py +5 -0
  180. label_studio_sdk/views/client.py +219 -52
  181. label_studio_sdk/views/types/views_create_request_data.py +13 -23
  182. label_studio_sdk/views/types/views_create_request_data_filters.py +14 -24
  183. label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +16 -26
  184. label_studio_sdk/views/types/views_create_request_data_filters_items_item_value.py +3 -1
  185. label_studio_sdk/views/types/views_update_request_data.py +13 -23
  186. label_studio_sdk/views/types/views_update_request_data_filters.py +14 -24
  187. label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +16 -26
  188. label_studio_sdk/views/types/views_update_request_data_filters_items_item_value.py +3 -1
  189. label_studio_sdk/webhooks/client.py +191 -61
  190. label_studio_sdk/workspaces/client.py +164 -41
  191. label_studio_sdk/workspaces/members/client.py +109 -31
  192. label_studio_sdk/workspaces/members/types/members_create_response.py +12 -22
  193. label_studio_sdk/workspaces/members/types/members_list_response_item.py +12 -22
  194. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/METADATA +7 -5
  195. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/RECORD +197 -184
  196. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/WHEEL +1 -1
  197. label_studio_sdk/types/export_convert.py +0 -32
  198. label_studio_sdk/types/export_create.py +0 -54
  199. label_studio_sdk/types/export_create_status.py +0 -5
  200. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.10.dist-info}/LICENSE +0 -0
@@ -1,16 +1,16 @@
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.redis_export_storage import RedisExportStorage
7
+ from ...core.pydantic_utilities import parse_obj_as
8
+ from json.decoder import JSONDecodeError
9
+ from ...core.api_error import ApiError
12
10
  from .types.redis_create_response import RedisCreateResponse
11
+ from ...core.jsonable_encoder import jsonable_encoder
13
12
  from .types.redis_update_response import RedisUpdateResponse
13
+ from ...core.client_wrapper import AsyncClientWrapper
14
14
 
15
15
  # this is used as the default value for optional parameters
16
16
  OMIT = typing.cast(typing.Any, ...)
@@ -24,6 +24,7 @@ class RedisClient:
24
24
  self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
25
25
  ) -> typing.List[RedisExportStorage]:
26
26
  """
27
+
27
28
  You can connect your Redis database to Label Studio as a source storage or target storage. Use this API request to get a list of all Redis export (target) storage connections for a specific project.
28
29
 
29
30
  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).
@@ -45,7 +46,7 @@ class RedisClient:
45
46
 
46
47
  Examples
47
48
  --------
48
- from label_studio_sdk.client import LabelStudio
49
+ from label_studio_sdk import LabelStudio
49
50
 
50
51
  client = LabelStudio(
51
52
  api_key="YOUR_API_KEY",
@@ -53,11 +54,22 @@ class RedisClient:
53
54
  client.export_storage.redis.list()
54
55
  """
55
56
  _response = self._client_wrapper.httpx_client.request(
56
- "api/storages/export/redis", method="GET", params={"project": project}, request_options=request_options
57
+ "api/storages/export/redis",
58
+ method="GET",
59
+ params={
60
+ "project": project,
61
+ },
62
+ request_options=request_options,
57
63
  )
58
64
  try:
59
65
  if 200 <= _response.status_code < 300:
60
- return pydantic_v1.parse_obj_as(typing.List[RedisExportStorage], _response.json()) # type: ignore
66
+ return typing.cast(
67
+ typing.List[RedisExportStorage],
68
+ parse_obj_as(
69
+ type_=typing.List[RedisExportStorage], # type: ignore
70
+ object_=_response.json(),
71
+ ),
72
+ )
61
73
  _response_json = _response.json()
62
74
  except JSONDecodeError:
63
75
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -78,6 +90,7 @@ class RedisClient:
78
90
  request_options: typing.Optional[RequestOptions] = None,
79
91
  ) -> RedisCreateResponse:
80
92
  """
93
+
81
94
  Create a new target storage connection to Redis.
82
95
 
83
96
  For information about the required fields and prerequisites, see [Redis database](https://labelstud.io/guide/storage#Redis-database) in the Label Studio documentation.
@@ -123,7 +136,7 @@ class RedisClient:
123
136
 
124
137
  Examples
125
138
  --------
126
- from label_studio_sdk.client import LabelStudio
139
+ from label_studio_sdk import LabelStudio
127
140
 
128
141
  client = LabelStudio(
129
142
  api_key="YOUR_API_KEY",
@@ -144,12 +157,21 @@ class RedisClient:
144
157
  "port": port,
145
158
  "password": password,
146
159
  },
160
+ headers={
161
+ "content-type": "application/json",
162
+ },
147
163
  request_options=request_options,
148
164
  omit=OMIT,
149
165
  )
150
166
  try:
151
167
  if 200 <= _response.status_code < 300:
152
- return pydantic_v1.parse_obj_as(RedisCreateResponse, _response.json()) # type: ignore
168
+ return typing.cast(
169
+ RedisCreateResponse,
170
+ parse_obj_as(
171
+ type_=RedisCreateResponse, # type: ignore
172
+ object_=_response.json(),
173
+ ),
174
+ )
153
175
  _response_json = _response.json()
154
176
  except JSONDecodeError:
155
177
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -171,6 +193,7 @@ class RedisClient:
171
193
  request_options: typing.Optional[RequestOptions] = None,
172
194
  ) -> None:
173
195
  """
196
+
174
197
  Validate a specific Redis export storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to export data.
175
198
 
176
199
  Parameters
@@ -214,7 +237,7 @@ class RedisClient:
214
237
 
215
238
  Examples
216
239
  --------
217
- from label_studio_sdk.client import LabelStudio
240
+ from label_studio_sdk import LabelStudio
218
241
 
219
242
  client = LabelStudio(
220
243
  api_key="YOUR_API_KEY",
@@ -236,6 +259,9 @@ class RedisClient:
236
259
  "port": port,
237
260
  "password": password,
238
261
  },
262
+ headers={
263
+ "content-type": "application/json",
264
+ },
239
265
  request_options=request_options,
240
266
  omit=OMIT,
241
267
  )
@@ -249,6 +275,7 @@ class RedisClient:
249
275
 
250
276
  def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
251
277
  """
278
+
252
279
  Get a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
253
280
 
254
281
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -268,7 +295,7 @@ class RedisClient:
268
295
 
269
296
  Examples
270
297
  --------
271
- from label_studio_sdk.client import LabelStudio
298
+ from label_studio_sdk import LabelStudio
272
299
 
273
300
  client = LabelStudio(
274
301
  api_key="YOUR_API_KEY",
@@ -278,11 +305,19 @@ class RedisClient:
278
305
  )
279
306
  """
280
307
  _response = self._client_wrapper.httpx_client.request(
281
- f"api/storages/export/redis/{jsonable_encoder(id)}", method="GET", request_options=request_options
308
+ f"api/storages/export/redis/{jsonable_encoder(id)}",
309
+ method="GET",
310
+ request_options=request_options,
282
311
  )
283
312
  try:
284
313
  if 200 <= _response.status_code < 300:
285
- return pydantic_v1.parse_obj_as(RedisExportStorage, _response.json()) # type: ignore
314
+ return typing.cast(
315
+ RedisExportStorage,
316
+ parse_obj_as(
317
+ type_=RedisExportStorage, # type: ignore
318
+ object_=_response.json(),
319
+ ),
320
+ )
286
321
  _response_json = _response.json()
287
322
  except JSONDecodeError:
288
323
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -290,6 +325,7 @@ class RedisClient:
290
325
 
291
326
  def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
292
327
  """
328
+
293
329
  Delete a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
294
330
 
295
331
  Deleting an export/target storage connection does not affect tasks with synced data in Label Studio. If you want to remove the tasks that were synced from the external storage, you will need to delete them manually from within the Label Studio UI or use the [Delete tasks](../../tasks/delete-all-tasks) API.
@@ -308,7 +344,7 @@ class RedisClient:
308
344
 
309
345
  Examples
310
346
  --------
311
- from label_studio_sdk.client import LabelStudio
347
+ from label_studio_sdk import LabelStudio
312
348
 
313
349
  client = LabelStudio(
314
350
  api_key="YOUR_API_KEY",
@@ -318,7 +354,9 @@ class RedisClient:
318
354
  )
319
355
  """
320
356
  _response = self._client_wrapper.httpx_client.request(
321
- f"api/storages/export/redis/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
357
+ f"api/storages/export/redis/{jsonable_encoder(id)}",
358
+ method="DELETE",
359
+ request_options=request_options,
322
360
  )
323
361
  try:
324
362
  if 200 <= _response.status_code < 300:
@@ -344,6 +382,7 @@ class RedisClient:
344
382
  request_options: typing.Optional[RequestOptions] = None,
345
383
  ) -> RedisUpdateResponse:
346
384
  """
385
+
347
386
  Update a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
348
387
 
349
388
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -390,7 +429,7 @@ class RedisClient:
390
429
 
391
430
  Examples
392
431
  --------
393
- from label_studio_sdk.client import LabelStudio
432
+ from label_studio_sdk import LabelStudio
394
433
 
395
434
  client = LabelStudio(
396
435
  api_key="YOUR_API_KEY",
@@ -413,19 +452,29 @@ class RedisClient:
413
452
  "port": port,
414
453
  "password": password,
415
454
  },
455
+ headers={
456
+ "content-type": "application/json",
457
+ },
416
458
  request_options=request_options,
417
459
  omit=OMIT,
418
460
  )
419
461
  try:
420
462
  if 200 <= _response.status_code < 300:
421
- return pydantic_v1.parse_obj_as(RedisUpdateResponse, _response.json()) # type: ignore
463
+ return typing.cast(
464
+ RedisUpdateResponse,
465
+ parse_obj_as(
466
+ type_=RedisUpdateResponse, # type: ignore
467
+ object_=_response.json(),
468
+ ),
469
+ )
422
470
  _response_json = _response.json()
423
471
  except JSONDecodeError:
424
472
  raise ApiError(status_code=_response.status_code, body=_response.text)
425
473
  raise ApiError(status_code=_response.status_code, body=_response_json)
426
474
 
427
- def sync(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
475
+ def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
428
476
  """
477
+
429
478
  Sync tasks to an Redis export/target storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
430
479
 
431
480
  Sync operations with external databases only go one way. They either create tasks from objects in the database (source/import storage) or push annotations to the output database (export/target storage). Changing something on the database side doesn’t guarantee consistency in results.
@@ -434,7 +483,7 @@ class RedisClient:
434
483
 
435
484
  Parameters
436
485
  ----------
437
- id : str
486
+ id : int
438
487
 
439
488
  request_options : typing.Optional[RequestOptions]
440
489
  Request-specific configuration.
@@ -446,21 +495,29 @@ class RedisClient:
446
495
 
447
496
  Examples
448
497
  --------
449
- from label_studio_sdk.client import LabelStudio
498
+ from label_studio_sdk import LabelStudio
450
499
 
451
500
  client = LabelStudio(
452
501
  api_key="YOUR_API_KEY",
453
502
  )
454
503
  client.export_storage.redis.sync(
455
- id="id",
504
+ id=1,
456
505
  )
457
506
  """
458
507
  _response = self._client_wrapper.httpx_client.request(
459
- f"api/storages/export/redis/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
508
+ f"api/storages/export/redis/{jsonable_encoder(id)}/sync",
509
+ method="POST",
510
+ request_options=request_options,
460
511
  )
461
512
  try:
462
513
  if 200 <= _response.status_code < 300:
463
- return pydantic_v1.parse_obj_as(RedisExportStorage, _response.json()) # type: ignore
514
+ return typing.cast(
515
+ RedisExportStorage,
516
+ parse_obj_as(
517
+ type_=RedisExportStorage, # type: ignore
518
+ object_=_response.json(),
519
+ ),
520
+ )
464
521
  _response_json = _response.json()
465
522
  except JSONDecodeError:
466
523
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -475,6 +532,7 @@ class AsyncRedisClient:
475
532
  self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
476
533
  ) -> typing.List[RedisExportStorage]:
477
534
  """
535
+
478
536
  You can connect your Redis database to Label Studio as a source storage or target storage. Use this API request to get a list of all Redis export (target) storage connections for a specific project.
479
537
 
480
538
  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).
@@ -496,19 +554,38 @@ class AsyncRedisClient:
496
554
 
497
555
  Examples
498
556
  --------
499
- from label_studio_sdk.client import AsyncLabelStudio
557
+ import asyncio
558
+
559
+ from label_studio_sdk import AsyncLabelStudio
500
560
 
501
561
  client = AsyncLabelStudio(
502
562
  api_key="YOUR_API_KEY",
503
563
  )
504
- await client.export_storage.redis.list()
564
+
565
+
566
+ async def main() -> None:
567
+ await client.export_storage.redis.list()
568
+
569
+
570
+ asyncio.run(main())
505
571
  """
506
572
  _response = await self._client_wrapper.httpx_client.request(
507
- "api/storages/export/redis", method="GET", params={"project": project}, request_options=request_options
573
+ "api/storages/export/redis",
574
+ method="GET",
575
+ params={
576
+ "project": project,
577
+ },
578
+ request_options=request_options,
508
579
  )
509
580
  try:
510
581
  if 200 <= _response.status_code < 300:
511
- return pydantic_v1.parse_obj_as(typing.List[RedisExportStorage], _response.json()) # type: ignore
582
+ return typing.cast(
583
+ typing.List[RedisExportStorage],
584
+ parse_obj_as(
585
+ type_=typing.List[RedisExportStorage], # type: ignore
586
+ object_=_response.json(),
587
+ ),
588
+ )
512
589
  _response_json = _response.json()
513
590
  except JSONDecodeError:
514
591
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -529,6 +606,7 @@ class AsyncRedisClient:
529
606
  request_options: typing.Optional[RequestOptions] = None,
530
607
  ) -> RedisCreateResponse:
531
608
  """
609
+
532
610
  Create a new target storage connection to Redis.
533
611
 
534
612
  For information about the required fields and prerequisites, see [Redis database](https://labelstud.io/guide/storage#Redis-database) in the Label Studio documentation.
@@ -574,12 +652,20 @@ class AsyncRedisClient:
574
652
 
575
653
  Examples
576
654
  --------
577
- from label_studio_sdk.client import AsyncLabelStudio
655
+ import asyncio
656
+
657
+ from label_studio_sdk import AsyncLabelStudio
578
658
 
579
659
  client = AsyncLabelStudio(
580
660
  api_key="YOUR_API_KEY",
581
661
  )
582
- await client.export_storage.redis.create()
662
+
663
+
664
+ async def main() -> None:
665
+ await client.export_storage.redis.create()
666
+
667
+
668
+ asyncio.run(main())
583
669
  """
584
670
  _response = await self._client_wrapper.httpx_client.request(
585
671
  "api/storages/export/redis",
@@ -595,12 +681,21 @@ class AsyncRedisClient:
595
681
  "port": port,
596
682
  "password": password,
597
683
  },
684
+ headers={
685
+ "content-type": "application/json",
686
+ },
598
687
  request_options=request_options,
599
688
  omit=OMIT,
600
689
  )
601
690
  try:
602
691
  if 200 <= _response.status_code < 300:
603
- return pydantic_v1.parse_obj_as(RedisCreateResponse, _response.json()) # type: ignore
692
+ return typing.cast(
693
+ RedisCreateResponse,
694
+ parse_obj_as(
695
+ type_=RedisCreateResponse, # type: ignore
696
+ object_=_response.json(),
697
+ ),
698
+ )
604
699
  _response_json = _response.json()
605
700
  except JSONDecodeError:
606
701
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -622,6 +717,7 @@ class AsyncRedisClient:
622
717
  request_options: typing.Optional[RequestOptions] = None,
623
718
  ) -> None:
624
719
  """
720
+
625
721
  Validate a specific Redis export storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to export data.
626
722
 
627
723
  Parameters
@@ -665,12 +761,20 @@ class AsyncRedisClient:
665
761
 
666
762
  Examples
667
763
  --------
668
- from label_studio_sdk.client import AsyncLabelStudio
764
+ import asyncio
765
+
766
+ from label_studio_sdk import AsyncLabelStudio
669
767
 
670
768
  client = AsyncLabelStudio(
671
769
  api_key="YOUR_API_KEY",
672
770
  )
673
- await client.export_storage.redis.validate()
771
+
772
+
773
+ async def main() -> None:
774
+ await client.export_storage.redis.validate()
775
+
776
+
777
+ asyncio.run(main())
674
778
  """
675
779
  _response = await self._client_wrapper.httpx_client.request(
676
780
  "api/storages/export/redis/validate",
@@ -687,6 +791,9 @@ class AsyncRedisClient:
687
791
  "port": port,
688
792
  "password": password,
689
793
  },
794
+ headers={
795
+ "content-type": "application/json",
796
+ },
690
797
  request_options=request_options,
691
798
  omit=OMIT,
692
799
  )
@@ -700,6 +807,7 @@ class AsyncRedisClient:
700
807
 
701
808
  async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
702
809
  """
810
+
703
811
  Get a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
704
812
 
705
813
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -719,21 +827,37 @@ class AsyncRedisClient:
719
827
 
720
828
  Examples
721
829
  --------
722
- from label_studio_sdk.client import AsyncLabelStudio
830
+ import asyncio
831
+
832
+ from label_studio_sdk import AsyncLabelStudio
723
833
 
724
834
  client = AsyncLabelStudio(
725
835
  api_key="YOUR_API_KEY",
726
836
  )
727
- await client.export_storage.redis.get(
728
- id=1,
729
- )
837
+
838
+
839
+ async def main() -> None:
840
+ await client.export_storage.redis.get(
841
+ id=1,
842
+ )
843
+
844
+
845
+ asyncio.run(main())
730
846
  """
731
847
  _response = await self._client_wrapper.httpx_client.request(
732
- f"api/storages/export/redis/{jsonable_encoder(id)}", method="GET", request_options=request_options
848
+ f"api/storages/export/redis/{jsonable_encoder(id)}",
849
+ method="GET",
850
+ request_options=request_options,
733
851
  )
734
852
  try:
735
853
  if 200 <= _response.status_code < 300:
736
- return pydantic_v1.parse_obj_as(RedisExportStorage, _response.json()) # type: ignore
854
+ return typing.cast(
855
+ RedisExportStorage,
856
+ parse_obj_as(
857
+ type_=RedisExportStorage, # type: ignore
858
+ object_=_response.json(),
859
+ ),
860
+ )
737
861
  _response_json = _response.json()
738
862
  except JSONDecodeError:
739
863
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -741,6 +865,7 @@ class AsyncRedisClient:
741
865
 
742
866
  async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
743
867
  """
868
+
744
869
  Delete a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
745
870
 
746
871
  Deleting an export/target storage connection does not affect tasks with synced data in Label Studio. If you want to remove the tasks that were synced from the external storage, you will need to delete them manually from within the Label Studio UI or use the [Delete tasks](../../tasks/delete-all-tasks) API.
@@ -759,17 +884,27 @@ class AsyncRedisClient:
759
884
 
760
885
  Examples
761
886
  --------
762
- from label_studio_sdk.client import AsyncLabelStudio
887
+ import asyncio
888
+
889
+ from label_studio_sdk import AsyncLabelStudio
763
890
 
764
891
  client = AsyncLabelStudio(
765
892
  api_key="YOUR_API_KEY",
766
893
  )
767
- await client.export_storage.redis.delete(
768
- id=1,
769
- )
894
+
895
+
896
+ async def main() -> None:
897
+ await client.export_storage.redis.delete(
898
+ id=1,
899
+ )
900
+
901
+
902
+ asyncio.run(main())
770
903
  """
771
904
  _response = await self._client_wrapper.httpx_client.request(
772
- f"api/storages/export/redis/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
905
+ f"api/storages/export/redis/{jsonable_encoder(id)}",
906
+ method="DELETE",
907
+ request_options=request_options,
773
908
  )
774
909
  try:
775
910
  if 200 <= _response.status_code < 300:
@@ -795,6 +930,7 @@ class AsyncRedisClient:
795
930
  request_options: typing.Optional[RequestOptions] = None,
796
931
  ) -> RedisUpdateResponse:
797
932
  """
933
+
798
934
  Update a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
799
935
 
800
936
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -841,14 +977,22 @@ class AsyncRedisClient:
841
977
 
842
978
  Examples
843
979
  --------
844
- from label_studio_sdk.client import AsyncLabelStudio
980
+ import asyncio
981
+
982
+ from label_studio_sdk import AsyncLabelStudio
845
983
 
846
984
  client = AsyncLabelStudio(
847
985
  api_key="YOUR_API_KEY",
848
986
  )
849
- await client.export_storage.redis.update(
850
- id=1,
851
- )
987
+
988
+
989
+ async def main() -> None:
990
+ await client.export_storage.redis.update(
991
+ id=1,
992
+ )
993
+
994
+
995
+ asyncio.run(main())
852
996
  """
853
997
  _response = await self._client_wrapper.httpx_client.request(
854
998
  f"api/storages/export/redis/{jsonable_encoder(id)}",
@@ -864,19 +1008,29 @@ class AsyncRedisClient:
864
1008
  "port": port,
865
1009
  "password": password,
866
1010
  },
1011
+ headers={
1012
+ "content-type": "application/json",
1013
+ },
867
1014
  request_options=request_options,
868
1015
  omit=OMIT,
869
1016
  )
870
1017
  try:
871
1018
  if 200 <= _response.status_code < 300:
872
- return pydantic_v1.parse_obj_as(RedisUpdateResponse, _response.json()) # type: ignore
1019
+ return typing.cast(
1020
+ RedisUpdateResponse,
1021
+ parse_obj_as(
1022
+ type_=RedisUpdateResponse, # type: ignore
1023
+ object_=_response.json(),
1024
+ ),
1025
+ )
873
1026
  _response_json = _response.json()
874
1027
  except JSONDecodeError:
875
1028
  raise ApiError(status_code=_response.status_code, body=_response.text)
876
1029
  raise ApiError(status_code=_response.status_code, body=_response_json)
877
1030
 
878
- async def sync(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
1031
+ async def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
879
1032
  """
1033
+
880
1034
  Sync tasks to an Redis export/target storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
881
1035
 
882
1036
  Sync operations with external databases only go one way. They either create tasks from objects in the database (source/import storage) or push annotations to the output database (export/target storage). Changing something on the database side doesn’t guarantee consistency in results.
@@ -885,7 +1039,7 @@ class AsyncRedisClient:
885
1039
 
886
1040
  Parameters
887
1041
  ----------
888
- id : str
1042
+ id : int
889
1043
 
890
1044
  request_options : typing.Optional[RequestOptions]
891
1045
  Request-specific configuration.
@@ -897,21 +1051,37 @@ class AsyncRedisClient:
897
1051
 
898
1052
  Examples
899
1053
  --------
900
- from label_studio_sdk.client import AsyncLabelStudio
1054
+ import asyncio
1055
+
1056
+ from label_studio_sdk import AsyncLabelStudio
901
1057
 
902
1058
  client = AsyncLabelStudio(
903
1059
  api_key="YOUR_API_KEY",
904
1060
  )
905
- await client.export_storage.redis.sync(
906
- id="id",
907
- )
1061
+
1062
+
1063
+ async def main() -> None:
1064
+ await client.export_storage.redis.sync(
1065
+ id=1,
1066
+ )
1067
+
1068
+
1069
+ asyncio.run(main())
908
1070
  """
909
1071
  _response = await self._client_wrapper.httpx_client.request(
910
- f"api/storages/export/redis/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
1072
+ f"api/storages/export/redis/{jsonable_encoder(id)}/sync",
1073
+ method="POST",
1074
+ request_options=request_options,
911
1075
  )
912
1076
  try:
913
1077
  if 200 <= _response.status_code < 300:
914
- return pydantic_v1.parse_obj_as(RedisExportStorage, _response.json()) # type: ignore
1078
+ return typing.cast(
1079
+ RedisExportStorage,
1080
+ parse_obj_as(
1081
+ type_=RedisExportStorage, # type: ignore
1082
+ object_=_response.json(),
1083
+ ),
1084
+ )
915
1085
  _response_json = _response.json()
916
1086
  except JSONDecodeError:
917
1087
  raise ApiError(status_code=_response.status_code, body=_response.text)