label-studio-sdk 0.0.32__py3-none-any.whl → 1.0.0__py3-none-any.whl

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