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.local_files_import_storage import LocalFilesImportStorage
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.local_create_response import LocalCreateResponse
11
+ from ...core.jsonable_encoder import jsonable_encoder
13
12
  from .types.local_update_response import LocalUpdateResponse
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 LocalClient:
24
24
  self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
25
25
  ) -> typing.List[LocalFilesImportStorage]:
26
26
  """
27
+
27
28
  If you have local files that you want to add to Label Studio from a specific directory, you can set up a specific local directory on the machine where LS is running as source or target storage. Use this API request to get a list of all local file 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 LocalClient:
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 LocalClient:
53
54
  client.import_storage.local.list()
54
55
  """
55
56
  _response = self._client_wrapper.httpx_client.request(
56
- "api/storages/localfiles/", method="GET", params={"project": project}, request_options=request_options
57
+ "api/storages/localfiles/",
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[LocalFilesImportStorage], _response.json()) # type: ignore
66
+ return typing.cast(
67
+ typing.List[LocalFilesImportStorage],
68
+ parse_obj_as(
69
+ type_=typing.List[LocalFilesImportStorage], # 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)
@@ -75,6 +87,7 @@ class LocalClient:
75
87
  request_options: typing.Optional[RequestOptions] = None,
76
88
  ) -> LocalCreateResponse:
77
89
  """
90
+
78
91
  Create a new source storage connection to a local file directory.
79
92
 
80
93
  For information about the required fields and prerequisites, see [Local storage](https://labelstud.io/guide/storage#Local-storage) in the Label Studio documentation.
@@ -111,7 +124,7 @@ class LocalClient:
111
124
 
112
125
  Examples
113
126
  --------
114
- from label_studio_sdk.client import LabelStudio
127
+ from label_studio_sdk import LabelStudio
115
128
 
116
129
  client = LabelStudio(
117
130
  api_key="YOUR_API_KEY",
@@ -129,12 +142,21 @@ class LocalClient:
129
142
  "regex_filter": regex_filter,
130
143
  "use_blob_urls": use_blob_urls,
131
144
  },
145
+ headers={
146
+ "content-type": "application/json",
147
+ },
132
148
  request_options=request_options,
133
149
  omit=OMIT,
134
150
  )
135
151
  try:
136
152
  if 200 <= _response.status_code < 300:
137
- return pydantic_v1.parse_obj_as(LocalCreateResponse, _response.json()) # type: ignore
153
+ return typing.cast(
154
+ LocalCreateResponse,
155
+ parse_obj_as(
156
+ type_=LocalCreateResponse, # type: ignore
157
+ object_=_response.json(),
158
+ ),
159
+ )
138
160
  _response_json = _response.json()
139
161
  except JSONDecodeError:
140
162
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -153,6 +175,7 @@ class LocalClient:
153
175
  request_options: typing.Optional[RequestOptions] = None,
154
176
  ) -> None:
155
177
  """
178
+
156
179
  Validate a specific local file import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import data.
157
180
 
158
181
  Parameters
@@ -187,7 +210,7 @@ class LocalClient:
187
210
 
188
211
  Examples
189
212
  --------
190
- from label_studio_sdk.client import LabelStudio
213
+ from label_studio_sdk import LabelStudio
191
214
 
192
215
  client = LabelStudio(
193
216
  api_key="YOUR_API_KEY",
@@ -206,6 +229,9 @@ class LocalClient:
206
229
  "regex_filter": regex_filter,
207
230
  "use_blob_urls": use_blob_urls,
208
231
  },
232
+ headers={
233
+ "content-type": "application/json",
234
+ },
209
235
  request_options=request_options,
210
236
  omit=OMIT,
211
237
  )
@@ -219,6 +245,7 @@ class LocalClient:
219
245
 
220
246
  def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> LocalFilesImportStorage:
221
247
  """
248
+
222
249
  Get a specific local file import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
223
250
 
224
251
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -238,7 +265,7 @@ class LocalClient:
238
265
 
239
266
  Examples
240
267
  --------
241
- from label_studio_sdk.client import LabelStudio
268
+ from label_studio_sdk import LabelStudio
242
269
 
243
270
  client = LabelStudio(
244
271
  api_key="YOUR_API_KEY",
@@ -248,11 +275,19 @@ class LocalClient:
248
275
  )
249
276
  """
250
277
  _response = self._client_wrapper.httpx_client.request(
251
- f"api/storages/localfiles/{jsonable_encoder(id)}", method="GET", request_options=request_options
278
+ f"api/storages/localfiles/{jsonable_encoder(id)}",
279
+ method="GET",
280
+ request_options=request_options,
252
281
  )
253
282
  try:
254
283
  if 200 <= _response.status_code < 300:
255
- return pydantic_v1.parse_obj_as(LocalFilesImportStorage, _response.json()) # type: ignore
284
+ return typing.cast(
285
+ LocalFilesImportStorage,
286
+ parse_obj_as(
287
+ type_=LocalFilesImportStorage, # type: ignore
288
+ object_=_response.json(),
289
+ ),
290
+ )
256
291
  _response_json = _response.json()
257
292
  except JSONDecodeError:
258
293
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -260,6 +295,7 @@ class LocalClient:
260
295
 
261
296
  def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
262
297
  """
298
+
263
299
  Delete a specific local import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
264
300
 
265
301
  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.
@@ -280,7 +316,7 @@ class LocalClient:
280
316
 
281
317
  Examples
282
318
  --------
283
- from label_studio_sdk.client import LabelStudio
319
+ from label_studio_sdk import LabelStudio
284
320
 
285
321
  client = LabelStudio(
286
322
  api_key="YOUR_API_KEY",
@@ -290,7 +326,9 @@ class LocalClient:
290
326
  )
291
327
  """
292
328
  _response = self._client_wrapper.httpx_client.request(
293
- f"api/storages/localfiles/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
329
+ f"api/storages/localfiles/{jsonable_encoder(id)}",
330
+ method="DELETE",
331
+ request_options=request_options,
294
332
  )
295
333
  try:
296
334
  if 200 <= _response.status_code < 300:
@@ -313,6 +351,7 @@ class LocalClient:
313
351
  request_options: typing.Optional[RequestOptions] = None,
314
352
  ) -> LocalUpdateResponse:
315
353
  """
354
+
316
355
  Update a specific local import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
317
356
 
318
357
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -350,7 +389,7 @@ class LocalClient:
350
389
 
351
390
  Examples
352
391
  --------
353
- from label_studio_sdk.client import LabelStudio
392
+ from label_studio_sdk import LabelStudio
354
393
 
355
394
  client = LabelStudio(
356
395
  api_key="YOUR_API_KEY",
@@ -370,12 +409,21 @@ class LocalClient:
370
409
  "regex_filter": regex_filter,
371
410
  "use_blob_urls": use_blob_urls,
372
411
  },
412
+ headers={
413
+ "content-type": "application/json",
414
+ },
373
415
  request_options=request_options,
374
416
  omit=OMIT,
375
417
  )
376
418
  try:
377
419
  if 200 <= _response.status_code < 300:
378
- return pydantic_v1.parse_obj_as(LocalUpdateResponse, _response.json()) # type: ignore
420
+ return typing.cast(
421
+ LocalUpdateResponse,
422
+ parse_obj_as(
423
+ type_=LocalUpdateResponse, # type: ignore
424
+ object_=_response.json(),
425
+ ),
426
+ )
379
427
  _response_json = _response.json()
380
428
  except JSONDecodeError:
381
429
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -383,6 +431,7 @@ class LocalClient:
383
431
 
384
432
  def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> LocalFilesImportStorage:
385
433
  """
434
+
386
435
  Sync tasks from a local import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
387
436
 
388
437
  Sync operations with external sources only go one way. They either create tasks from objects in the source directory (source/import storage) or push annotations to the output directory (export/target storage). Changing something on the local file side doesn’t guarantee consistency in results.
@@ -404,7 +453,7 @@ class LocalClient:
404
453
 
405
454
  Examples
406
455
  --------
407
- from label_studio_sdk.client import LabelStudio
456
+ from label_studio_sdk import LabelStudio
408
457
 
409
458
  client = LabelStudio(
410
459
  api_key="YOUR_API_KEY",
@@ -414,11 +463,19 @@ class LocalClient:
414
463
  )
415
464
  """
416
465
  _response = self._client_wrapper.httpx_client.request(
417
- f"api/storages/localfiles/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
466
+ f"api/storages/localfiles/{jsonable_encoder(id)}/sync",
467
+ method="POST",
468
+ request_options=request_options,
418
469
  )
419
470
  try:
420
471
  if 200 <= _response.status_code < 300:
421
- return pydantic_v1.parse_obj_as(LocalFilesImportStorage, _response.json()) # type: ignore
472
+ return typing.cast(
473
+ LocalFilesImportStorage,
474
+ parse_obj_as(
475
+ type_=LocalFilesImportStorage, # type: ignore
476
+ object_=_response.json(),
477
+ ),
478
+ )
422
479
  _response_json = _response.json()
423
480
  except JSONDecodeError:
424
481
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -433,6 +490,7 @@ class AsyncLocalClient:
433
490
  self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
434
491
  ) -> typing.List[LocalFilesImportStorage]:
435
492
  """
493
+
436
494
  If you have local files that you want to add to Label Studio from a specific directory, you can set up a specific local directory on the machine where LS is running as source or target storage. Use this API request to get a list of all local file import (source) storage connections for a specific project.
437
495
 
438
496
  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).
@@ -454,19 +512,38 @@ class AsyncLocalClient:
454
512
 
455
513
  Examples
456
514
  --------
457
- from label_studio_sdk.client import AsyncLabelStudio
515
+ import asyncio
516
+
517
+ from label_studio_sdk import AsyncLabelStudio
458
518
 
459
519
  client = AsyncLabelStudio(
460
520
  api_key="YOUR_API_KEY",
461
521
  )
462
- await client.import_storage.local.list()
522
+
523
+
524
+ async def main() -> None:
525
+ await client.import_storage.local.list()
526
+
527
+
528
+ asyncio.run(main())
463
529
  """
464
530
  _response = await self._client_wrapper.httpx_client.request(
465
- "api/storages/localfiles/", method="GET", params={"project": project}, request_options=request_options
531
+ "api/storages/localfiles/",
532
+ method="GET",
533
+ params={
534
+ "project": project,
535
+ },
536
+ request_options=request_options,
466
537
  )
467
538
  try:
468
539
  if 200 <= _response.status_code < 300:
469
- return pydantic_v1.parse_obj_as(typing.List[LocalFilesImportStorage], _response.json()) # type: ignore
540
+ return typing.cast(
541
+ typing.List[LocalFilesImportStorage],
542
+ parse_obj_as(
543
+ type_=typing.List[LocalFilesImportStorage], # type: ignore
544
+ object_=_response.json(),
545
+ ),
546
+ )
470
547
  _response_json = _response.json()
471
548
  except JSONDecodeError:
472
549
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -484,6 +561,7 @@ class AsyncLocalClient:
484
561
  request_options: typing.Optional[RequestOptions] = None,
485
562
  ) -> LocalCreateResponse:
486
563
  """
564
+
487
565
  Create a new source storage connection to a local file directory.
488
566
 
489
567
  For information about the required fields and prerequisites, see [Local storage](https://labelstud.io/guide/storage#Local-storage) in the Label Studio documentation.
@@ -520,12 +598,20 @@ class AsyncLocalClient:
520
598
 
521
599
  Examples
522
600
  --------
523
- from label_studio_sdk.client import AsyncLabelStudio
601
+ import asyncio
602
+
603
+ from label_studio_sdk import AsyncLabelStudio
524
604
 
525
605
  client = AsyncLabelStudio(
526
606
  api_key="YOUR_API_KEY",
527
607
  )
528
- await client.import_storage.local.create()
608
+
609
+
610
+ async def main() -> None:
611
+ await client.import_storage.local.create()
612
+
613
+
614
+ asyncio.run(main())
529
615
  """
530
616
  _response = await self._client_wrapper.httpx_client.request(
531
617
  "api/storages/localfiles/",
@@ -538,12 +624,21 @@ class AsyncLocalClient:
538
624
  "regex_filter": regex_filter,
539
625
  "use_blob_urls": use_blob_urls,
540
626
  },
627
+ headers={
628
+ "content-type": "application/json",
629
+ },
541
630
  request_options=request_options,
542
631
  omit=OMIT,
543
632
  )
544
633
  try:
545
634
  if 200 <= _response.status_code < 300:
546
- return pydantic_v1.parse_obj_as(LocalCreateResponse, _response.json()) # type: ignore
635
+ return typing.cast(
636
+ LocalCreateResponse,
637
+ parse_obj_as(
638
+ type_=LocalCreateResponse, # type: ignore
639
+ object_=_response.json(),
640
+ ),
641
+ )
547
642
  _response_json = _response.json()
548
643
  except JSONDecodeError:
549
644
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -562,6 +657,7 @@ class AsyncLocalClient:
562
657
  request_options: typing.Optional[RequestOptions] = None,
563
658
  ) -> None:
564
659
  """
660
+
565
661
  Validate a specific local file import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import data.
566
662
 
567
663
  Parameters
@@ -596,12 +692,20 @@ class AsyncLocalClient:
596
692
 
597
693
  Examples
598
694
  --------
599
- from label_studio_sdk.client import AsyncLabelStudio
695
+ import asyncio
696
+
697
+ from label_studio_sdk import AsyncLabelStudio
600
698
 
601
699
  client = AsyncLabelStudio(
602
700
  api_key="YOUR_API_KEY",
603
701
  )
604
- await client.import_storage.local.validate()
702
+
703
+
704
+ async def main() -> None:
705
+ await client.import_storage.local.validate()
706
+
707
+
708
+ asyncio.run(main())
605
709
  """
606
710
  _response = await self._client_wrapper.httpx_client.request(
607
711
  "api/storages/localfiles/validate",
@@ -615,6 +719,9 @@ class AsyncLocalClient:
615
719
  "regex_filter": regex_filter,
616
720
  "use_blob_urls": use_blob_urls,
617
721
  },
722
+ headers={
723
+ "content-type": "application/json",
724
+ },
618
725
  request_options=request_options,
619
726
  omit=OMIT,
620
727
  )
@@ -628,6 +735,7 @@ class AsyncLocalClient:
628
735
 
629
736
  async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> LocalFilesImportStorage:
630
737
  """
738
+
631
739
  Get a specific local file import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
632
740
 
633
741
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -647,21 +755,37 @@ class AsyncLocalClient:
647
755
 
648
756
  Examples
649
757
  --------
650
- from label_studio_sdk.client import AsyncLabelStudio
758
+ import asyncio
759
+
760
+ from label_studio_sdk import AsyncLabelStudio
651
761
 
652
762
  client = AsyncLabelStudio(
653
763
  api_key="YOUR_API_KEY",
654
764
  )
655
- await client.import_storage.local.get(
656
- id=1,
657
- )
765
+
766
+
767
+ async def main() -> None:
768
+ await client.import_storage.local.get(
769
+ id=1,
770
+ )
771
+
772
+
773
+ asyncio.run(main())
658
774
  """
659
775
  _response = await self._client_wrapper.httpx_client.request(
660
- f"api/storages/localfiles/{jsonable_encoder(id)}", method="GET", request_options=request_options
776
+ f"api/storages/localfiles/{jsonable_encoder(id)}",
777
+ method="GET",
778
+ request_options=request_options,
661
779
  )
662
780
  try:
663
781
  if 200 <= _response.status_code < 300:
664
- return pydantic_v1.parse_obj_as(LocalFilesImportStorage, _response.json()) # type: ignore
782
+ return typing.cast(
783
+ LocalFilesImportStorage,
784
+ parse_obj_as(
785
+ type_=LocalFilesImportStorage, # type: ignore
786
+ object_=_response.json(),
787
+ ),
788
+ )
665
789
  _response_json = _response.json()
666
790
  except JSONDecodeError:
667
791
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -669,6 +793,7 @@ class AsyncLocalClient:
669
793
 
670
794
  async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
671
795
  """
796
+
672
797
  Delete a specific local import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
673
798
 
674
799
  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.
@@ -689,17 +814,27 @@ class AsyncLocalClient:
689
814
 
690
815
  Examples
691
816
  --------
692
- from label_studio_sdk.client import AsyncLabelStudio
817
+ import asyncio
818
+
819
+ from label_studio_sdk import AsyncLabelStudio
693
820
 
694
821
  client = AsyncLabelStudio(
695
822
  api_key="YOUR_API_KEY",
696
823
  )
697
- await client.import_storage.local.delete(
698
- id=1,
699
- )
824
+
825
+
826
+ async def main() -> None:
827
+ await client.import_storage.local.delete(
828
+ id=1,
829
+ )
830
+
831
+
832
+ asyncio.run(main())
700
833
  """
701
834
  _response = await self._client_wrapper.httpx_client.request(
702
- f"api/storages/localfiles/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
835
+ f"api/storages/localfiles/{jsonable_encoder(id)}",
836
+ method="DELETE",
837
+ request_options=request_options,
703
838
  )
704
839
  try:
705
840
  if 200 <= _response.status_code < 300:
@@ -722,6 +857,7 @@ class AsyncLocalClient:
722
857
  request_options: typing.Optional[RequestOptions] = None,
723
858
  ) -> LocalUpdateResponse:
724
859
  """
860
+
725
861
  Update a specific local import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
726
862
 
727
863
  For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
@@ -759,14 +895,22 @@ class AsyncLocalClient:
759
895
 
760
896
  Examples
761
897
  --------
762
- from label_studio_sdk.client import AsyncLabelStudio
898
+ import asyncio
899
+
900
+ from label_studio_sdk import AsyncLabelStudio
763
901
 
764
902
  client = AsyncLabelStudio(
765
903
  api_key="YOUR_API_KEY",
766
904
  )
767
- await client.import_storage.local.update(
768
- id=1,
769
- )
905
+
906
+
907
+ async def main() -> None:
908
+ await client.import_storage.local.update(
909
+ id=1,
910
+ )
911
+
912
+
913
+ asyncio.run(main())
770
914
  """
771
915
  _response = await self._client_wrapper.httpx_client.request(
772
916
  f"api/storages/localfiles/{jsonable_encoder(id)}",
@@ -779,12 +923,21 @@ class AsyncLocalClient:
779
923
  "regex_filter": regex_filter,
780
924
  "use_blob_urls": use_blob_urls,
781
925
  },
926
+ headers={
927
+ "content-type": "application/json",
928
+ },
782
929
  request_options=request_options,
783
930
  omit=OMIT,
784
931
  )
785
932
  try:
786
933
  if 200 <= _response.status_code < 300:
787
- return pydantic_v1.parse_obj_as(LocalUpdateResponse, _response.json()) # type: ignore
934
+ return typing.cast(
935
+ LocalUpdateResponse,
936
+ parse_obj_as(
937
+ type_=LocalUpdateResponse, # type: ignore
938
+ object_=_response.json(),
939
+ ),
940
+ )
788
941
  _response_json = _response.json()
789
942
  except JSONDecodeError:
790
943
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -794,6 +947,7 @@ class AsyncLocalClient:
794
947
  self, id: int, *, request_options: typing.Optional[RequestOptions] = None
795
948
  ) -> LocalFilesImportStorage:
796
949
  """
950
+
797
951
  Sync tasks from a local import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
798
952
 
799
953
  Sync operations with external sources only go one way. They either create tasks from objects in the source directory (source/import storage) or push annotations to the output directory (export/target storage). Changing something on the local file side doesn’t guarantee consistency in results.
@@ -815,21 +969,37 @@ class AsyncLocalClient:
815
969
 
816
970
  Examples
817
971
  --------
818
- from label_studio_sdk.client import AsyncLabelStudio
972
+ import asyncio
973
+
974
+ from label_studio_sdk import AsyncLabelStudio
819
975
 
820
976
  client = AsyncLabelStudio(
821
977
  api_key="YOUR_API_KEY",
822
978
  )
823
- await client.import_storage.local.sync(
824
- id=1,
825
- )
979
+
980
+
981
+ async def main() -> None:
982
+ await client.import_storage.local.sync(
983
+ id=1,
984
+ )
985
+
986
+
987
+ asyncio.run(main())
826
988
  """
827
989
  _response = await self._client_wrapper.httpx_client.request(
828
- f"api/storages/localfiles/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
990
+ f"api/storages/localfiles/{jsonable_encoder(id)}/sync",
991
+ method="POST",
992
+ request_options=request_options,
829
993
  )
830
994
  try:
831
995
  if 200 <= _response.status_code < 300:
832
- return pydantic_v1.parse_obj_as(LocalFilesImportStorage, _response.json()) # type: ignore
996
+ return typing.cast(
997
+ LocalFilesImportStorage,
998
+ parse_obj_as(
999
+ type_=LocalFilesImportStorage, # type: ignore
1000
+ object_=_response.json(),
1001
+ ),
1002
+ )
833
1003
  _response_json = _response.json()
834
1004
  except JSONDecodeError:
835
1005
  raise ApiError(status_code=_response.status_code, body=_response.text)