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_import_storage import RedisImportStorage
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[RedisImportStorage]:
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 import (source) 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.import_storage.redis.list()
54
55
  """
55
56
  _response = self._client_wrapper.httpx_client.request(
56
- "api/storages/redis/", method="GET", params={"project": project}, request_options=request_options
57
+ "api/storages/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[RedisImportStorage], _response.json()) # type: ignore
66
+ return typing.cast(
67
+ typing.List[RedisImportStorage],
68
+ parse_obj_as(
69
+ type_=typing.List[RedisImportStorage], # 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 source storage connection to a Redis database.
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 import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import 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) -> RedisImportStorage:
251
277
  """
278
+
252
279
  Get a specific Redis import storage connection. You will need to provide the import storage ID. You can find this using [List import 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/redis/{jsonable_encoder(id)}", method="GET", request_options=request_options
308
+ f"api/storages/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(RedisImportStorage, _response.json()) # type: ignore
314
+ return typing.cast(
315
+ RedisImportStorage,
316
+ parse_obj_as(
317
+ type_=RedisImportStorage, # 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 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
294
330
 
295
331
  Deleting a source storage connection does not affect tasks with synced data in Label Studio. The sync process is designed to import new or updated tasks from the connected storage into the project, but it does not track deletions of files from the storage. Therefore, if you remove the external storage connection, the tasks that were created from that storage will remain in the project.
@@ -310,7 +346,7 @@ class RedisClient:
310
346
 
311
347
  Examples
312
348
  --------
313
- from label_studio_sdk.client import LabelStudio
349
+ from label_studio_sdk import LabelStudio
314
350
 
315
351
  client = LabelStudio(
316
352
  api_key="YOUR_API_KEY",
@@ -320,7 +356,9 @@ class RedisClient:
320
356
  )
321
357
  """
322
358
  _response = self._client_wrapper.httpx_client.request(
323
- f"api/storages/redis/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
359
+ f"api/storages/redis/{jsonable_encoder(id)}",
360
+ method="DELETE",
361
+ request_options=request_options,
324
362
  )
325
363
  try:
326
364
  if 200 <= _response.status_code < 300:
@@ -346,6 +384,7 @@ class RedisClient:
346
384
  request_options: typing.Optional[RequestOptions] = None,
347
385
  ) -> RedisUpdateResponse:
348
386
  """
387
+
349
388
  Update a specific Redis import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
350
389
 
351
390
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -392,7 +431,7 @@ class RedisClient:
392
431
 
393
432
  Examples
394
433
  --------
395
- from label_studio_sdk.client import LabelStudio
434
+ from label_studio_sdk import LabelStudio
396
435
 
397
436
  client = LabelStudio(
398
437
  api_key="YOUR_API_KEY",
@@ -415,12 +454,21 @@ class RedisClient:
415
454
  "port": port,
416
455
  "password": password,
417
456
  },
457
+ headers={
458
+ "content-type": "application/json",
459
+ },
418
460
  request_options=request_options,
419
461
  omit=OMIT,
420
462
  )
421
463
  try:
422
464
  if 200 <= _response.status_code < 300:
423
- return pydantic_v1.parse_obj_as(RedisUpdateResponse, _response.json()) # type: ignore
465
+ return typing.cast(
466
+ RedisUpdateResponse,
467
+ parse_obj_as(
468
+ type_=RedisUpdateResponse, # type: ignore
469
+ object_=_response.json(),
470
+ ),
471
+ )
424
472
  _response_json = _response.json()
425
473
  except JSONDecodeError:
426
474
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -428,6 +476,7 @@ class RedisClient:
428
476
 
429
477
  def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisImportStorage:
430
478
  """
479
+
431
480
  Sync tasks from a Redis import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
432
481
 
433
482
  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.
@@ -449,7 +498,7 @@ class RedisClient:
449
498
 
450
499
  Examples
451
500
  --------
452
- from label_studio_sdk.client import LabelStudio
501
+ from label_studio_sdk import LabelStudio
453
502
 
454
503
  client = LabelStudio(
455
504
  api_key="YOUR_API_KEY",
@@ -459,11 +508,19 @@ class RedisClient:
459
508
  )
460
509
  """
461
510
  _response = self._client_wrapper.httpx_client.request(
462
- f"api/storages/redis/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
511
+ f"api/storages/redis/{jsonable_encoder(id)}/sync",
512
+ method="POST",
513
+ request_options=request_options,
463
514
  )
464
515
  try:
465
516
  if 200 <= _response.status_code < 300:
466
- return pydantic_v1.parse_obj_as(RedisImportStorage, _response.json()) # type: ignore
517
+ return typing.cast(
518
+ RedisImportStorage,
519
+ parse_obj_as(
520
+ type_=RedisImportStorage, # type: ignore
521
+ object_=_response.json(),
522
+ ),
523
+ )
467
524
  _response_json = _response.json()
468
525
  except JSONDecodeError:
469
526
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -478,6 +535,7 @@ class AsyncRedisClient:
478
535
  self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
479
536
  ) -> typing.List[RedisImportStorage]:
480
537
  """
538
+
481
539
  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 import (source) storage connections for a specific project.
482
540
 
483
541
  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).
@@ -499,19 +557,38 @@ class AsyncRedisClient:
499
557
 
500
558
  Examples
501
559
  --------
502
- from label_studio_sdk.client import AsyncLabelStudio
560
+ import asyncio
561
+
562
+ from label_studio_sdk import AsyncLabelStudio
503
563
 
504
564
  client = AsyncLabelStudio(
505
565
  api_key="YOUR_API_KEY",
506
566
  )
507
- await client.import_storage.redis.list()
567
+
568
+
569
+ async def main() -> None:
570
+ await client.import_storage.redis.list()
571
+
572
+
573
+ asyncio.run(main())
508
574
  """
509
575
  _response = await self._client_wrapper.httpx_client.request(
510
- "api/storages/redis/", method="GET", params={"project": project}, request_options=request_options
576
+ "api/storages/redis/",
577
+ method="GET",
578
+ params={
579
+ "project": project,
580
+ },
581
+ request_options=request_options,
511
582
  )
512
583
  try:
513
584
  if 200 <= _response.status_code < 300:
514
- return pydantic_v1.parse_obj_as(typing.List[RedisImportStorage], _response.json()) # type: ignore
585
+ return typing.cast(
586
+ typing.List[RedisImportStorage],
587
+ parse_obj_as(
588
+ type_=typing.List[RedisImportStorage], # type: ignore
589
+ object_=_response.json(),
590
+ ),
591
+ )
515
592
  _response_json = _response.json()
516
593
  except JSONDecodeError:
517
594
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -532,6 +609,7 @@ class AsyncRedisClient:
532
609
  request_options: typing.Optional[RequestOptions] = None,
533
610
  ) -> RedisCreateResponse:
534
611
  """
612
+
535
613
  Create a new source storage connection to a Redis database.
536
614
 
537
615
  For information about the required fields and prerequisites, see [Redis database](https://labelstud.io/guide/storage#Redis-database) in the Label Studio documentation.
@@ -577,12 +655,20 @@ class AsyncRedisClient:
577
655
 
578
656
  Examples
579
657
  --------
580
- from label_studio_sdk.client import AsyncLabelStudio
658
+ import asyncio
659
+
660
+ from label_studio_sdk import AsyncLabelStudio
581
661
 
582
662
  client = AsyncLabelStudio(
583
663
  api_key="YOUR_API_KEY",
584
664
  )
585
- await client.import_storage.redis.create()
665
+
666
+
667
+ async def main() -> None:
668
+ await client.import_storage.redis.create()
669
+
670
+
671
+ asyncio.run(main())
586
672
  """
587
673
  _response = await self._client_wrapper.httpx_client.request(
588
674
  "api/storages/redis/",
@@ -598,12 +684,21 @@ class AsyncRedisClient:
598
684
  "port": port,
599
685
  "password": password,
600
686
  },
687
+ headers={
688
+ "content-type": "application/json",
689
+ },
601
690
  request_options=request_options,
602
691
  omit=OMIT,
603
692
  )
604
693
  try:
605
694
  if 200 <= _response.status_code < 300:
606
- return pydantic_v1.parse_obj_as(RedisCreateResponse, _response.json()) # type: ignore
695
+ return typing.cast(
696
+ RedisCreateResponse,
697
+ parse_obj_as(
698
+ type_=RedisCreateResponse, # type: ignore
699
+ object_=_response.json(),
700
+ ),
701
+ )
607
702
  _response_json = _response.json()
608
703
  except JSONDecodeError:
609
704
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -625,6 +720,7 @@ class AsyncRedisClient:
625
720
  request_options: typing.Optional[RequestOptions] = None,
626
721
  ) -> None:
627
722
  """
723
+
628
724
  Validate a specific Redis import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import data.
629
725
 
630
726
  Parameters
@@ -668,12 +764,20 @@ class AsyncRedisClient:
668
764
 
669
765
  Examples
670
766
  --------
671
- from label_studio_sdk.client import AsyncLabelStudio
767
+ import asyncio
768
+
769
+ from label_studio_sdk import AsyncLabelStudio
672
770
 
673
771
  client = AsyncLabelStudio(
674
772
  api_key="YOUR_API_KEY",
675
773
  )
676
- await client.import_storage.redis.validate()
774
+
775
+
776
+ async def main() -> None:
777
+ await client.import_storage.redis.validate()
778
+
779
+
780
+ asyncio.run(main())
677
781
  """
678
782
  _response = await self._client_wrapper.httpx_client.request(
679
783
  "api/storages/redis/validate",
@@ -690,6 +794,9 @@ class AsyncRedisClient:
690
794
  "port": port,
691
795
  "password": password,
692
796
  },
797
+ headers={
798
+ "content-type": "application/json",
799
+ },
693
800
  request_options=request_options,
694
801
  omit=OMIT,
695
802
  )
@@ -703,6 +810,7 @@ class AsyncRedisClient:
703
810
 
704
811
  async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisImportStorage:
705
812
  """
813
+
706
814
  Get a specific Redis import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
707
815
 
708
816
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -722,21 +830,37 @@ class AsyncRedisClient:
722
830
 
723
831
  Examples
724
832
  --------
725
- from label_studio_sdk.client import AsyncLabelStudio
833
+ import asyncio
834
+
835
+ from label_studio_sdk import AsyncLabelStudio
726
836
 
727
837
  client = AsyncLabelStudio(
728
838
  api_key="YOUR_API_KEY",
729
839
  )
730
- await client.import_storage.redis.get(
731
- id=1,
732
- )
840
+
841
+
842
+ async def main() -> None:
843
+ await client.import_storage.redis.get(
844
+ id=1,
845
+ )
846
+
847
+
848
+ asyncio.run(main())
733
849
  """
734
850
  _response = await self._client_wrapper.httpx_client.request(
735
- f"api/storages/redis/{jsonable_encoder(id)}", method="GET", request_options=request_options
851
+ f"api/storages/redis/{jsonable_encoder(id)}",
852
+ method="GET",
853
+ request_options=request_options,
736
854
  )
737
855
  try:
738
856
  if 200 <= _response.status_code < 300:
739
- return pydantic_v1.parse_obj_as(RedisImportStorage, _response.json()) # type: ignore
857
+ return typing.cast(
858
+ RedisImportStorage,
859
+ parse_obj_as(
860
+ type_=RedisImportStorage, # type: ignore
861
+ object_=_response.json(),
862
+ ),
863
+ )
740
864
  _response_json = _response.json()
741
865
  except JSONDecodeError:
742
866
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -744,6 +868,7 @@ class AsyncRedisClient:
744
868
 
745
869
  async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
746
870
  """
871
+
747
872
  Delete a specific Redis import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
748
873
 
749
874
  Deleting a source storage connection does not affect tasks with synced data in Label Studio. The sync process is designed to import new or updated tasks from the connected storage into the project, but it does not track deletions of files from the storage. Therefore, if you remove the external storage connection, the tasks that were created from that storage will remain in the project.
@@ -764,17 +889,27 @@ class AsyncRedisClient:
764
889
 
765
890
  Examples
766
891
  --------
767
- from label_studio_sdk.client import AsyncLabelStudio
892
+ import asyncio
893
+
894
+ from label_studio_sdk import AsyncLabelStudio
768
895
 
769
896
  client = AsyncLabelStudio(
770
897
  api_key="YOUR_API_KEY",
771
898
  )
772
- await client.import_storage.redis.delete(
773
- id=1,
774
- )
899
+
900
+
901
+ async def main() -> None:
902
+ await client.import_storage.redis.delete(
903
+ id=1,
904
+ )
905
+
906
+
907
+ asyncio.run(main())
775
908
  """
776
909
  _response = await self._client_wrapper.httpx_client.request(
777
- f"api/storages/redis/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
910
+ f"api/storages/redis/{jsonable_encoder(id)}",
911
+ method="DELETE",
912
+ request_options=request_options,
778
913
  )
779
914
  try:
780
915
  if 200 <= _response.status_code < 300:
@@ -800,6 +935,7 @@ class AsyncRedisClient:
800
935
  request_options: typing.Optional[RequestOptions] = None,
801
936
  ) -> RedisUpdateResponse:
802
937
  """
938
+
803
939
  Update a specific Redis import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
804
940
 
805
941
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -846,14 +982,22 @@ class AsyncRedisClient:
846
982
 
847
983
  Examples
848
984
  --------
849
- from label_studio_sdk.client import AsyncLabelStudio
985
+ import asyncio
986
+
987
+ from label_studio_sdk import AsyncLabelStudio
850
988
 
851
989
  client = AsyncLabelStudio(
852
990
  api_key="YOUR_API_KEY",
853
991
  )
854
- await client.import_storage.redis.update(
855
- id=1,
856
- )
992
+
993
+
994
+ async def main() -> None:
995
+ await client.import_storage.redis.update(
996
+ id=1,
997
+ )
998
+
999
+
1000
+ asyncio.run(main())
857
1001
  """
858
1002
  _response = await self._client_wrapper.httpx_client.request(
859
1003
  f"api/storages/redis/{jsonable_encoder(id)}",
@@ -869,12 +1013,21 @@ class AsyncRedisClient:
869
1013
  "port": port,
870
1014
  "password": password,
871
1015
  },
1016
+ headers={
1017
+ "content-type": "application/json",
1018
+ },
872
1019
  request_options=request_options,
873
1020
  omit=OMIT,
874
1021
  )
875
1022
  try:
876
1023
  if 200 <= _response.status_code < 300:
877
- return pydantic_v1.parse_obj_as(RedisUpdateResponse, _response.json()) # type: ignore
1024
+ return typing.cast(
1025
+ RedisUpdateResponse,
1026
+ parse_obj_as(
1027
+ type_=RedisUpdateResponse, # type: ignore
1028
+ object_=_response.json(),
1029
+ ),
1030
+ )
878
1031
  _response_json = _response.json()
879
1032
  except JSONDecodeError:
880
1033
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -882,6 +1035,7 @@ class AsyncRedisClient:
882
1035
 
883
1036
  async def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisImportStorage:
884
1037
  """
1038
+
885
1039
  Sync tasks from a Redis import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
886
1040
 
887
1041
  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.
@@ -903,21 +1057,37 @@ class AsyncRedisClient:
903
1057
 
904
1058
  Examples
905
1059
  --------
906
- from label_studio_sdk.client import AsyncLabelStudio
1060
+ import asyncio
1061
+
1062
+ from label_studio_sdk import AsyncLabelStudio
907
1063
 
908
1064
  client = AsyncLabelStudio(
909
1065
  api_key="YOUR_API_KEY",
910
1066
  )
911
- await client.import_storage.redis.sync(
912
- id=1,
913
- )
1067
+
1068
+
1069
+ async def main() -> None:
1070
+ await client.import_storage.redis.sync(
1071
+ id=1,
1072
+ )
1073
+
1074
+
1075
+ asyncio.run(main())
914
1076
  """
915
1077
  _response = await self._client_wrapper.httpx_client.request(
916
- f"api/storages/redis/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
1078
+ f"api/storages/redis/{jsonable_encoder(id)}/sync",
1079
+ method="POST",
1080
+ request_options=request_options,
917
1081
  )
918
1082
  try:
919
1083
  if 200 <= _response.status_code < 300:
920
- return pydantic_v1.parse_obj_as(RedisImportStorage, _response.json()) # type: ignore
1084
+ return typing.cast(
1085
+ RedisImportStorage,
1086
+ parse_obj_as(
1087
+ type_=RedisImportStorage, # type: ignore
1088
+ object_=_response.json(),
1089
+ ),
1090
+ )
921
1091
  _response_json = _response.json()
922
1092
  except JSONDecodeError:
923
1093
  raise ApiError(status_code=_response.status_code, body=_response.text)