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,930 @@
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.export import Export
12
+ from ...types.export_convert import ExportConvert
13
+ from ...types.export_create import ExportCreate
14
+
15
+ # this is used as the default value for optional parameters
16
+ OMIT = typing.cast(typing.Any, ...)
17
+
18
+
19
+ class ExportsClient:
20
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
21
+ self._client_wrapper = client_wrapper
22
+
23
+ def create_export(
24
+ self,
25
+ id: int,
26
+ *,
27
+ export_type: typing.Optional[str] = None,
28
+ download_all_tasks: typing.Optional[str] = None,
29
+ download_resources: typing.Optional[bool] = None,
30
+ ids: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None,
31
+ request_options: typing.Optional[RequestOptions] = None,
32
+ ) -> typing.Iterator[bytes]:
33
+ """
34
+ <Note>If you have a large project it's recommended to use export snapshots, this easy export endpoint might have timeouts.</Note>
35
+ Export annotated tasks as a file in a specific format.
36
+ For example, to export JSON annotations for a project to a file called `annotations.json`,
37
+ run the following from the command line:
38
+
39
+ ```bash
40
+ curl -X GET https://localhost:8080/api/projects/{id}/export?exportType=JSON -H 'Authorization: Token abc123' --output 'annotations.json'
41
+ ```
42
+
43
+ To export all tasks, including skipped tasks and others without annotations, run the following from the command line:
44
+
45
+ ```bash
46
+ curl -X GET https://localhost:8080/api/projects/{id}/export?exportType=JSON&download_all_tasks=true -H 'Authorization: Token abc123' --output 'annotations.json'
47
+ ```
48
+
49
+ To export specific tasks with IDs of 123 and 345, run the following from the command line:
50
+
51
+ ```bash
52
+ curl -X GET https://localhost:8080/api/projects/{id}/export?ids[]=123\&ids[]=345 -H 'Authorization: Token abc123' --output 'annotations.json'
53
+ ```
54
+
55
+ You must provide a project ID. 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](../list).
56
+
57
+ Parameters
58
+ ----------
59
+ id : int
60
+ A unique integer value identifying this project.
61
+
62
+ export_type : typing.Optional[str]
63
+ Selected export format (JSON by default)
64
+
65
+ download_all_tasks : typing.Optional[str]
66
+ If true, download all tasks regardless of status. If false, download only annotated tasks.
67
+
68
+ download_resources : typing.Optional[bool]
69
+ If true, download all resource files such as images, audio, and others relevant to the tasks.
70
+
71
+ ids : typing.Optional[typing.Union[int, typing.Sequence[int]]]
72
+ Specify a list of task IDs to retrieve only the details for those tasks.
73
+
74
+ request_options : typing.Optional[RequestOptions]
75
+ Request-specific configuration.
76
+
77
+ Yields
78
+ ------
79
+ typing.Iterator[bytes]
80
+ Exported data
81
+
82
+ Examples
83
+ --------
84
+ from label_studio_sdk.client import LabelStudio
85
+
86
+ client = LabelStudio(
87
+ api_key="YOUR_API_KEY",
88
+ )
89
+ client.projects.exports.create_export(
90
+ id=1,
91
+ export_type="string",
92
+ download_all_tasks="string",
93
+ download_resources=True,
94
+ ids=1,
95
+ )
96
+ """
97
+ with self._client_wrapper.httpx_client.stream(
98
+ f"api/projects/{jsonable_encoder(id)}/export",
99
+ method="GET",
100
+ params={
101
+ "export_type": export_type,
102
+ "download_all_tasks": download_all_tasks,
103
+ "download_resources": download_resources,
104
+ "ids": ids,
105
+ },
106
+ request_options=request_options,
107
+ ) as _response:
108
+ if 200 <= _response.status_code < 300:
109
+ for _chunk in _response.iter_bytes():
110
+ yield _chunk
111
+ return
112
+ _response.read()
113
+ try:
114
+ _response_json = _response.json()
115
+ except JSONDecodeError:
116
+ raise ApiError(status_code=_response.status_code, body=_response.text)
117
+ raise ApiError(status_code=_response.status_code, body=_response_json)
118
+
119
+ def list_formats(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[str]:
120
+ """
121
+ Before exporting annotations, you can check with formats are supported by the specified project. For more information about export formats, see [Export formats supported by Label Studio](https://labelstud.io/guide/export#Export-formats-supported-by-Label-Studio).
122
+
123
+ You must provide a project ID. 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](../list).
124
+
125
+ Parameters
126
+ ----------
127
+ id : int
128
+ A unique integer value identifying this project.
129
+
130
+ request_options : typing.Optional[RequestOptions]
131
+ Request-specific configuration.
132
+
133
+ Returns
134
+ -------
135
+ typing.List[str]
136
+ Export formats
137
+
138
+ Examples
139
+ --------
140
+ from label_studio_sdk.client import LabelStudio
141
+
142
+ client = LabelStudio(
143
+ api_key="YOUR_API_KEY",
144
+ )
145
+ client.projects.exports.list_formats(
146
+ id=1,
147
+ )
148
+ """
149
+ _response = self._client_wrapper.httpx_client.request(
150
+ f"api/projects/{jsonable_encoder(id)}/export/formats", method="GET", request_options=request_options
151
+ )
152
+ if 200 <= _response.status_code < 300:
153
+ return pydantic_v1.parse_obj_as(typing.List[str], _response.json()) # type: ignore
154
+ try:
155
+ _response_json = _response.json()
156
+ except JSONDecodeError:
157
+ raise ApiError(status_code=_response.status_code, body=_response.text)
158
+ raise ApiError(status_code=_response.status_code, body=_response_json)
159
+
160
+ def list(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Export]:
161
+ """
162
+ Returns a list of export file (snapshots) for a specific project by ID. 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](../list).
163
+
164
+ Included in the response is information about each snapshot, such as who created it and what format it is in.
165
+
166
+ Parameters
167
+ ----------
168
+ id : int
169
+ A unique integer value identifying this project.
170
+
171
+ request_options : typing.Optional[RequestOptions]
172
+ Request-specific configuration.
173
+
174
+ Returns
175
+ -------
176
+ typing.List[Export]
177
+
178
+
179
+ Examples
180
+ --------
181
+ from label_studio_sdk.client import LabelStudio
182
+
183
+ client = LabelStudio(
184
+ api_key="YOUR_API_KEY",
185
+ )
186
+ client.projects.exports.list(
187
+ id=1,
188
+ )
189
+ """
190
+ _response = self._client_wrapper.httpx_client.request(
191
+ f"api/projects/{jsonable_encoder(id)}/exports/", method="GET", request_options=request_options
192
+ )
193
+ if 200 <= _response.status_code < 300:
194
+ return pydantic_v1.parse_obj_as(typing.List[Export], _response.json()) # type: ignore
195
+ try:
196
+ _response_json = _response.json()
197
+ except JSONDecodeError:
198
+ raise ApiError(status_code=_response.status_code, body=_response.text)
199
+ raise ApiError(status_code=_response.status_code, body=_response_json)
200
+
201
+ def create(
202
+ self, id: int, *, request: ExportCreate, request_options: typing.Optional[RequestOptions] = None
203
+ ) -> ExportCreate:
204
+ """
205
+ Create a new export request to start a background task and generate an export file (snapshot) for a specific project by ID. 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](../list).
206
+
207
+ A snapshot is a static export of your project's data and annotations at a specific point in time. It captures the current state of your tasks, annotations, and other relevant data, allowing you to download and review them later. Snapshots are particularly useful for large projects as they help avoid timeouts during export operations by processing the data asynchronously.
208
+
209
+ For more information, see the [Label Studio documentation on exporting annotations](https://labelstud.io/guide/export.html).
210
+
211
+ Parameters
212
+ ----------
213
+ id : int
214
+ A unique integer value identifying this project.
215
+
216
+ request : ExportCreate
217
+
218
+ request_options : typing.Optional[RequestOptions]
219
+ Request-specific configuration.
220
+
221
+ Returns
222
+ -------
223
+ ExportCreate
224
+
225
+
226
+ Examples
227
+ --------
228
+ from label_studio_sdk import ExportCreate
229
+ from label_studio_sdk.client import LabelStudio
230
+
231
+ client = LabelStudio(
232
+ api_key="YOUR_API_KEY",
233
+ )
234
+ client.projects.exports.create(
235
+ id=1,
236
+ request=ExportCreate(),
237
+ )
238
+ """
239
+ _response = self._client_wrapper.httpx_client.request(
240
+ f"api/projects/{jsonable_encoder(id)}/exports/",
241
+ method="POST",
242
+ json=request,
243
+ request_options=request_options,
244
+ omit=OMIT,
245
+ )
246
+ if 200 <= _response.status_code < 300:
247
+ return pydantic_v1.parse_obj_as(ExportCreate, _response.json()) # type: ignore
248
+ try:
249
+ _response_json = _response.json()
250
+ except JSONDecodeError:
251
+ raise ApiError(status_code=_response.status_code, body=_response.text)
252
+ raise ApiError(status_code=_response.status_code, body=_response_json)
253
+
254
+ def get(self, id: int, export_pk: str, *, request_options: typing.Optional[RequestOptions] = None) -> Export:
255
+ """
256
+ Retrieve information about a specific export file (snapshot).
257
+
258
+ You will need the export ID. You can find this in the response when you [create the snapshot via the API](create) or using [List all export snapshots](list).
259
+
260
+ You will also need the project ID. This can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../list).
261
+
262
+ Parameters
263
+ ----------
264
+ id : int
265
+ A unique integer value identifying this project.
266
+
267
+ export_pk : str
268
+ Primary key identifying the export file.
269
+
270
+ request_options : typing.Optional[RequestOptions]
271
+ Request-specific configuration.
272
+
273
+ Returns
274
+ -------
275
+ Export
276
+
277
+
278
+ Examples
279
+ --------
280
+ from label_studio_sdk.client import LabelStudio
281
+
282
+ client = LabelStudio(
283
+ api_key="YOUR_API_KEY",
284
+ )
285
+ client.projects.exports.get(
286
+ id=1,
287
+ export_pk="export_pk",
288
+ )
289
+ """
290
+ _response = self._client_wrapper.httpx_client.request(
291
+ f"api/projects/{jsonable_encoder(id)}/exports/{jsonable_encoder(export_pk)}",
292
+ method="GET",
293
+ request_options=request_options,
294
+ )
295
+ if 200 <= _response.status_code < 300:
296
+ return pydantic_v1.parse_obj_as(Export, _response.json()) # type: ignore
297
+ try:
298
+ _response_json = _response.json()
299
+ except JSONDecodeError:
300
+ raise ApiError(status_code=_response.status_code, body=_response.text)
301
+ raise ApiError(status_code=_response.status_code, body=_response_json)
302
+
303
+ def delete(self, id: int, export_pk: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
304
+ """
305
+ Delete an export file by specified export ID.
306
+
307
+ You will need the export ID. You can find this in the response when you [create the snapshot via the API](create) or using [List all export snapshots](list).
308
+
309
+ Parameters
310
+ ----------
311
+ id : int
312
+ A unique integer value identifying this project.
313
+
314
+ export_pk : str
315
+ Primary key identifying the export file.
316
+
317
+ request_options : typing.Optional[RequestOptions]
318
+ Request-specific configuration.
319
+
320
+ Returns
321
+ -------
322
+ None
323
+
324
+ Examples
325
+ --------
326
+ from label_studio_sdk.client import LabelStudio
327
+
328
+ client = LabelStudio(
329
+ api_key="YOUR_API_KEY",
330
+ )
331
+ client.projects.exports.delete(
332
+ id=1,
333
+ export_pk="export_pk",
334
+ )
335
+ """
336
+ _response = self._client_wrapper.httpx_client.request(
337
+ f"api/projects/{jsonable_encoder(id)}/exports/{jsonable_encoder(export_pk)}",
338
+ method="DELETE",
339
+ request_options=request_options,
340
+ )
341
+ if 200 <= _response.status_code < 300:
342
+ return
343
+ try:
344
+ _response_json = _response.json()
345
+ except JSONDecodeError:
346
+ raise ApiError(status_code=_response.status_code, body=_response.text)
347
+ raise ApiError(status_code=_response.status_code, body=_response_json)
348
+
349
+ def convert(
350
+ self,
351
+ id: int,
352
+ export_pk: str,
353
+ *,
354
+ request: ExportConvert,
355
+ request_options: typing.Optional[RequestOptions] = None,
356
+ ) -> ExportConvert:
357
+ """
358
+ You can use this to convert an export snapshot into the selected format.
359
+
360
+ To see what formats are supported, you can use [Get export formats](list-formats) or see [Export formats supported by Label Studio](https://labelstud.io/guide/export#Export-formats-supported-by-Label-Studio).
361
+
362
+ You will need to provide the project ID and export ID (`export_pk`). The export ID is returned when you create the export or you can use [List all export snapshots](list).
363
+
364
+ 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](../list).
365
+
366
+ Parameters
367
+ ----------
368
+ id : int
369
+ A unique integer value identifying this project.
370
+
371
+ export_pk : str
372
+ Primary key identifying the export file.
373
+
374
+ request : ExportConvert
375
+
376
+ request_options : typing.Optional[RequestOptions]
377
+ Request-specific configuration.
378
+
379
+ Returns
380
+ -------
381
+ ExportConvert
382
+
383
+
384
+ Examples
385
+ --------
386
+ from label_studio_sdk import ExportConvert
387
+ from label_studio_sdk.client import LabelStudio
388
+
389
+ client = LabelStudio(
390
+ api_key="YOUR_API_KEY",
391
+ )
392
+ client.projects.exports.convert(
393
+ id=1,
394
+ export_pk="export_pk",
395
+ request=ExportConvert(
396
+ export_type="export_type",
397
+ ),
398
+ )
399
+ """
400
+ _response = self._client_wrapper.httpx_client.request(
401
+ f"api/projects/{jsonable_encoder(id)}/exports/{jsonable_encoder(export_pk)}/convert",
402
+ method="POST",
403
+ json=request,
404
+ request_options=request_options,
405
+ omit=OMIT,
406
+ )
407
+ if 200 <= _response.status_code < 300:
408
+ return pydantic_v1.parse_obj_as(ExportConvert, _response.json()) # type: ignore
409
+ try:
410
+ _response_json = _response.json()
411
+ except JSONDecodeError:
412
+ raise ApiError(status_code=_response.status_code, body=_response.text)
413
+ raise ApiError(status_code=_response.status_code, body=_response_json)
414
+
415
+ def download(
416
+ self,
417
+ id: int,
418
+ export_pk: str,
419
+ *,
420
+ export_type: typing.Optional[str] = None,
421
+ request_options: typing.Optional[RequestOptions] = None,
422
+ ) -> None:
423
+ """
424
+ Download an export snapshot as a file in a specified format. To see what formats are supported, you can use [Get export formats](list-formats) or see [Export formats supported by Label Studio](https://labelstud.io/guide/export#Export-formats-supported-by-Label-Studio).
425
+
426
+ You will need to provide the project ID and export ID (`export_pk`). The export ID is returned when you create the export or you can use [List all export snapshots](list).
427
+
428
+ 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](../list).
429
+
430
+ Parameters
431
+ ----------
432
+ id : int
433
+ A unique integer value identifying this project.
434
+
435
+ export_pk : str
436
+ Primary key identifying the export file.
437
+
438
+ export_type : typing.Optional[str]
439
+ Selected export format
440
+
441
+ request_options : typing.Optional[RequestOptions]
442
+ Request-specific configuration.
443
+
444
+ Returns
445
+ -------
446
+ None
447
+
448
+ Examples
449
+ --------
450
+ from label_studio_sdk.client import LabelStudio
451
+
452
+ client = LabelStudio(
453
+ api_key="YOUR_API_KEY",
454
+ )
455
+ client.projects.exports.download(
456
+ id=1,
457
+ export_pk="export_pk",
458
+ )
459
+ """
460
+ _response = self._client_wrapper.httpx_client.request(
461
+ f"api/projects/{jsonable_encoder(id)}/exports/{jsonable_encoder(export_pk)}/download",
462
+ method="GET",
463
+ params={"exportType": export_type},
464
+ request_options=request_options,
465
+ )
466
+ if 200 <= _response.status_code < 300:
467
+ return
468
+ try:
469
+ _response_json = _response.json()
470
+ except JSONDecodeError:
471
+ raise ApiError(status_code=_response.status_code, body=_response.text)
472
+ raise ApiError(status_code=_response.status_code, body=_response_json)
473
+
474
+
475
+ class AsyncExportsClient:
476
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
477
+ self._client_wrapper = client_wrapper
478
+
479
+ async def create_export(
480
+ self,
481
+ id: int,
482
+ *,
483
+ export_type: typing.Optional[str] = None,
484
+ download_all_tasks: typing.Optional[str] = None,
485
+ download_resources: typing.Optional[bool] = None,
486
+ ids: typing.Optional[typing.Union[int, typing.Sequence[int]]] = None,
487
+ request_options: typing.Optional[RequestOptions] = None,
488
+ ) -> typing.AsyncIterator[bytes]:
489
+ """
490
+ <Note>If you have a large project it's recommended to use export snapshots, this easy export endpoint might have timeouts.</Note>
491
+ Export annotated tasks as a file in a specific format.
492
+ For example, to export JSON annotations for a project to a file called `annotations.json`,
493
+ run the following from the command line:
494
+
495
+ ```bash
496
+ curl -X GET https://localhost:8080/api/projects/{id}/export?exportType=JSON -H 'Authorization: Token abc123' --output 'annotations.json'
497
+ ```
498
+
499
+ To export all tasks, including skipped tasks and others without annotations, run the following from the command line:
500
+
501
+ ```bash
502
+ curl -X GET https://localhost:8080/api/projects/{id}/export?exportType=JSON&download_all_tasks=true -H 'Authorization: Token abc123' --output 'annotations.json'
503
+ ```
504
+
505
+ To export specific tasks with IDs of 123 and 345, run the following from the command line:
506
+
507
+ ```bash
508
+ curl -X GET https://localhost:8080/api/projects/{id}/export?ids[]=123\&ids[]=345 -H 'Authorization: Token abc123' --output 'annotations.json'
509
+ ```
510
+
511
+ You must provide a project ID. 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](../list).
512
+
513
+ Parameters
514
+ ----------
515
+ id : int
516
+ A unique integer value identifying this project.
517
+
518
+ export_type : typing.Optional[str]
519
+ Selected export format (JSON by default)
520
+
521
+ download_all_tasks : typing.Optional[str]
522
+ If true, download all tasks regardless of status. If false, download only annotated tasks.
523
+
524
+ download_resources : typing.Optional[bool]
525
+ If true, download all resource files such as images, audio, and others relevant to the tasks.
526
+
527
+ ids : typing.Optional[typing.Union[int, typing.Sequence[int]]]
528
+ Specify a list of task IDs to retrieve only the details for those tasks.
529
+
530
+ request_options : typing.Optional[RequestOptions]
531
+ Request-specific configuration.
532
+
533
+ Yields
534
+ ------
535
+ typing.AsyncIterator[bytes]
536
+ Exported data
537
+
538
+ Examples
539
+ --------
540
+ from label_studio_sdk.client import AsyncLabelStudio
541
+
542
+ client = AsyncLabelStudio(
543
+ api_key="YOUR_API_KEY",
544
+ )
545
+ await client.projects.exports.create_export(
546
+ id=1,
547
+ export_type="string",
548
+ download_all_tasks="string",
549
+ download_resources=True,
550
+ ids=1,
551
+ )
552
+ """
553
+ async with self._client_wrapper.httpx_client.stream(
554
+ f"api/projects/{jsonable_encoder(id)}/export",
555
+ method="GET",
556
+ params={
557
+ "export_type": export_type,
558
+ "download_all_tasks": download_all_tasks,
559
+ "download_resources": download_resources,
560
+ "ids": ids,
561
+ },
562
+ request_options=request_options,
563
+ ) as _response:
564
+ if 200 <= _response.status_code < 300:
565
+ async for _chunk in _response.aiter_bytes():
566
+ yield _chunk
567
+ return
568
+ await _response.aread()
569
+ try:
570
+ _response_json = _response.json()
571
+ except JSONDecodeError:
572
+ raise ApiError(status_code=_response.status_code, body=_response.text)
573
+ raise ApiError(status_code=_response.status_code, body=_response_json)
574
+
575
+ async def list_formats(
576
+ self, id: int, *, request_options: typing.Optional[RequestOptions] = None
577
+ ) -> typing.List[str]:
578
+ """
579
+ Before exporting annotations, you can check with formats are supported by the specified project. For more information about export formats, see [Export formats supported by Label Studio](https://labelstud.io/guide/export#Export-formats-supported-by-Label-Studio).
580
+
581
+ You must provide a project ID. 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](../list).
582
+
583
+ Parameters
584
+ ----------
585
+ id : int
586
+ A unique integer value identifying this project.
587
+
588
+ request_options : typing.Optional[RequestOptions]
589
+ Request-specific configuration.
590
+
591
+ Returns
592
+ -------
593
+ typing.List[str]
594
+ Export formats
595
+
596
+ Examples
597
+ --------
598
+ from label_studio_sdk.client import AsyncLabelStudio
599
+
600
+ client = AsyncLabelStudio(
601
+ api_key="YOUR_API_KEY",
602
+ )
603
+ await client.projects.exports.list_formats(
604
+ id=1,
605
+ )
606
+ """
607
+ _response = await self._client_wrapper.httpx_client.request(
608
+ f"api/projects/{jsonable_encoder(id)}/export/formats", method="GET", request_options=request_options
609
+ )
610
+ if 200 <= _response.status_code < 300:
611
+ return pydantic_v1.parse_obj_as(typing.List[str], _response.json()) # type: ignore
612
+ try:
613
+ _response_json = _response.json()
614
+ except JSONDecodeError:
615
+ raise ApiError(status_code=_response.status_code, body=_response.text)
616
+ raise ApiError(status_code=_response.status_code, body=_response_json)
617
+
618
+ async def list(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> typing.List[Export]:
619
+ """
620
+ Returns a list of export file (snapshots) for a specific project by ID. 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](../list).
621
+
622
+ Included in the response is information about each snapshot, such as who created it and what format it is in.
623
+
624
+ Parameters
625
+ ----------
626
+ id : int
627
+ A unique integer value identifying this project.
628
+
629
+ request_options : typing.Optional[RequestOptions]
630
+ Request-specific configuration.
631
+
632
+ Returns
633
+ -------
634
+ typing.List[Export]
635
+
636
+
637
+ Examples
638
+ --------
639
+ from label_studio_sdk.client import AsyncLabelStudio
640
+
641
+ client = AsyncLabelStudio(
642
+ api_key="YOUR_API_KEY",
643
+ )
644
+ await client.projects.exports.list(
645
+ id=1,
646
+ )
647
+ """
648
+ _response = await self._client_wrapper.httpx_client.request(
649
+ f"api/projects/{jsonable_encoder(id)}/exports/", method="GET", request_options=request_options
650
+ )
651
+ if 200 <= _response.status_code < 300:
652
+ return pydantic_v1.parse_obj_as(typing.List[Export], _response.json()) # type: ignore
653
+ try:
654
+ _response_json = _response.json()
655
+ except JSONDecodeError:
656
+ raise ApiError(status_code=_response.status_code, body=_response.text)
657
+ raise ApiError(status_code=_response.status_code, body=_response_json)
658
+
659
+ async def create(
660
+ self, id: int, *, request: ExportCreate, request_options: typing.Optional[RequestOptions] = None
661
+ ) -> ExportCreate:
662
+ """
663
+ Create a new export request to start a background task and generate an export file (snapshot) for a specific project by ID. 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](../list).
664
+
665
+ A snapshot is a static export of your project's data and annotations at a specific point in time. It captures the current state of your tasks, annotations, and other relevant data, allowing you to download and review them later. Snapshots are particularly useful for large projects as they help avoid timeouts during export operations by processing the data asynchronously.
666
+
667
+ For more information, see the [Label Studio documentation on exporting annotations](https://labelstud.io/guide/export.html).
668
+
669
+ Parameters
670
+ ----------
671
+ id : int
672
+ A unique integer value identifying this project.
673
+
674
+ request : ExportCreate
675
+
676
+ request_options : typing.Optional[RequestOptions]
677
+ Request-specific configuration.
678
+
679
+ Returns
680
+ -------
681
+ ExportCreate
682
+
683
+
684
+ Examples
685
+ --------
686
+ from label_studio_sdk import ExportCreate
687
+ from label_studio_sdk.client import AsyncLabelStudio
688
+
689
+ client = AsyncLabelStudio(
690
+ api_key="YOUR_API_KEY",
691
+ )
692
+ await client.projects.exports.create(
693
+ id=1,
694
+ request=ExportCreate(),
695
+ )
696
+ """
697
+ _response = await self._client_wrapper.httpx_client.request(
698
+ f"api/projects/{jsonable_encoder(id)}/exports/",
699
+ method="POST",
700
+ json=request,
701
+ request_options=request_options,
702
+ omit=OMIT,
703
+ )
704
+ if 200 <= _response.status_code < 300:
705
+ return pydantic_v1.parse_obj_as(ExportCreate, _response.json()) # type: ignore
706
+ try:
707
+ _response_json = _response.json()
708
+ except JSONDecodeError:
709
+ raise ApiError(status_code=_response.status_code, body=_response.text)
710
+ raise ApiError(status_code=_response.status_code, body=_response_json)
711
+
712
+ async def get(self, id: int, export_pk: str, *, request_options: typing.Optional[RequestOptions] = None) -> Export:
713
+ """
714
+ Retrieve information about a specific export file (snapshot).
715
+
716
+ You will need the export ID. You can find this in the response when you [create the snapshot via the API](create) or using [List all export snapshots](list).
717
+
718
+ You will also need the project ID. This can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../list).
719
+
720
+ Parameters
721
+ ----------
722
+ id : int
723
+ A unique integer value identifying this project.
724
+
725
+ export_pk : str
726
+ Primary key identifying the export file.
727
+
728
+ request_options : typing.Optional[RequestOptions]
729
+ Request-specific configuration.
730
+
731
+ Returns
732
+ -------
733
+ Export
734
+
735
+
736
+ Examples
737
+ --------
738
+ from label_studio_sdk.client import AsyncLabelStudio
739
+
740
+ client = AsyncLabelStudio(
741
+ api_key="YOUR_API_KEY",
742
+ )
743
+ await client.projects.exports.get(
744
+ id=1,
745
+ export_pk="export_pk",
746
+ )
747
+ """
748
+ _response = await self._client_wrapper.httpx_client.request(
749
+ f"api/projects/{jsonable_encoder(id)}/exports/{jsonable_encoder(export_pk)}",
750
+ method="GET",
751
+ request_options=request_options,
752
+ )
753
+ if 200 <= _response.status_code < 300:
754
+ return pydantic_v1.parse_obj_as(Export, _response.json()) # type: ignore
755
+ try:
756
+ _response_json = _response.json()
757
+ except JSONDecodeError:
758
+ raise ApiError(status_code=_response.status_code, body=_response.text)
759
+ raise ApiError(status_code=_response.status_code, body=_response_json)
760
+
761
+ async def delete(self, id: int, export_pk: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
762
+ """
763
+ Delete an export file by specified export ID.
764
+
765
+ You will need the export ID. You can find this in the response when you [create the snapshot via the API](create) or using [List all export snapshots](list).
766
+
767
+ Parameters
768
+ ----------
769
+ id : int
770
+ A unique integer value identifying this project.
771
+
772
+ export_pk : str
773
+ Primary key identifying the export file.
774
+
775
+ request_options : typing.Optional[RequestOptions]
776
+ Request-specific configuration.
777
+
778
+ Returns
779
+ -------
780
+ None
781
+
782
+ Examples
783
+ --------
784
+ from label_studio_sdk.client import AsyncLabelStudio
785
+
786
+ client = AsyncLabelStudio(
787
+ api_key="YOUR_API_KEY",
788
+ )
789
+ await client.projects.exports.delete(
790
+ id=1,
791
+ export_pk="export_pk",
792
+ )
793
+ """
794
+ _response = await self._client_wrapper.httpx_client.request(
795
+ f"api/projects/{jsonable_encoder(id)}/exports/{jsonable_encoder(export_pk)}",
796
+ method="DELETE",
797
+ request_options=request_options,
798
+ )
799
+ if 200 <= _response.status_code < 300:
800
+ return
801
+ try:
802
+ _response_json = _response.json()
803
+ except JSONDecodeError:
804
+ raise ApiError(status_code=_response.status_code, body=_response.text)
805
+ raise ApiError(status_code=_response.status_code, body=_response_json)
806
+
807
+ async def convert(
808
+ self,
809
+ id: int,
810
+ export_pk: str,
811
+ *,
812
+ request: ExportConvert,
813
+ request_options: typing.Optional[RequestOptions] = None,
814
+ ) -> ExportConvert:
815
+ """
816
+ You can use this to convert an export snapshot into the selected format.
817
+
818
+ To see what formats are supported, you can use [Get export formats](list-formats) or see [Export formats supported by Label Studio](https://labelstud.io/guide/export#Export-formats-supported-by-Label-Studio).
819
+
820
+ You will need to provide the project ID and export ID (`export_pk`). The export ID is returned when you create the export or you can use [List all export snapshots](list).
821
+
822
+ 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](../list).
823
+
824
+ Parameters
825
+ ----------
826
+ id : int
827
+ A unique integer value identifying this project.
828
+
829
+ export_pk : str
830
+ Primary key identifying the export file.
831
+
832
+ request : ExportConvert
833
+
834
+ request_options : typing.Optional[RequestOptions]
835
+ Request-specific configuration.
836
+
837
+ Returns
838
+ -------
839
+ ExportConvert
840
+
841
+
842
+ Examples
843
+ --------
844
+ from label_studio_sdk import ExportConvert
845
+ from label_studio_sdk.client import AsyncLabelStudio
846
+
847
+ client = AsyncLabelStudio(
848
+ api_key="YOUR_API_KEY",
849
+ )
850
+ await client.projects.exports.convert(
851
+ id=1,
852
+ export_pk="export_pk",
853
+ request=ExportConvert(
854
+ export_type="export_type",
855
+ ),
856
+ )
857
+ """
858
+ _response = await self._client_wrapper.httpx_client.request(
859
+ f"api/projects/{jsonable_encoder(id)}/exports/{jsonable_encoder(export_pk)}/convert",
860
+ method="POST",
861
+ json=request,
862
+ request_options=request_options,
863
+ omit=OMIT,
864
+ )
865
+ if 200 <= _response.status_code < 300:
866
+ return pydantic_v1.parse_obj_as(ExportConvert, _response.json()) # type: ignore
867
+ try:
868
+ _response_json = _response.json()
869
+ except JSONDecodeError:
870
+ raise ApiError(status_code=_response.status_code, body=_response.text)
871
+ raise ApiError(status_code=_response.status_code, body=_response_json)
872
+
873
+ async def download(
874
+ self,
875
+ id: int,
876
+ export_pk: str,
877
+ *,
878
+ export_type: typing.Optional[str] = None,
879
+ request_options: typing.Optional[RequestOptions] = None,
880
+ ) -> None:
881
+ """
882
+ Download an export snapshot as a file in a specified format. To see what formats are supported, you can use [Get export formats](list-formats) or see [Export formats supported by Label Studio](https://labelstud.io/guide/export#Export-formats-supported-by-Label-Studio).
883
+
884
+ You will need to provide the project ID and export ID (`export_pk`). The export ID is returned when you create the export or you can use [List all export snapshots](list).
885
+
886
+ 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](../list).
887
+
888
+ Parameters
889
+ ----------
890
+ id : int
891
+ A unique integer value identifying this project.
892
+
893
+ export_pk : str
894
+ Primary key identifying the export file.
895
+
896
+ export_type : typing.Optional[str]
897
+ Selected export format
898
+
899
+ request_options : typing.Optional[RequestOptions]
900
+ Request-specific configuration.
901
+
902
+ Returns
903
+ -------
904
+ None
905
+
906
+ Examples
907
+ --------
908
+ from label_studio_sdk.client import AsyncLabelStudio
909
+
910
+ client = AsyncLabelStudio(
911
+ api_key="YOUR_API_KEY",
912
+ )
913
+ await client.projects.exports.download(
914
+ id=1,
915
+ export_pk="export_pk",
916
+ )
917
+ """
918
+ _response = await self._client_wrapper.httpx_client.request(
919
+ f"api/projects/{jsonable_encoder(id)}/exports/{jsonable_encoder(export_pk)}/download",
920
+ method="GET",
921
+ params={"exportType": export_type},
922
+ request_options=request_options,
923
+ )
924
+ if 200 <= _response.status_code < 300:
925
+ return
926
+ try:
927
+ _response_json = _response.json()
928
+ except JSONDecodeError:
929
+ raise ApiError(status_code=_response.status_code, body=_response.text)
930
+ raise ApiError(status_code=_response.status_code, body=_response_json)