label-studio-sdk 0.0.34__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of label-studio-sdk might be problematic. Click here for more details.

Files changed (272) hide show
  1. label_studio_sdk/__init__.py +232 -9
  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/_extensions/pager_ext.py +49 -0
  16. label_studio_sdk/_legacy/__init__.py +11 -0
  17. label_studio_sdk/_legacy/client.py +471 -0
  18. label_studio_sdk/_legacy/objects.py +74 -0
  19. label_studio_sdk/{project.py → _legacy/project.py} +2 -2
  20. label_studio_sdk/{schema → _legacy/schema}/label_config_schema.json +14 -14
  21. label_studio_sdk/actions/__init__.py +27 -0
  22. label_studio_sdk/actions/client.py +223 -0
  23. label_studio_sdk/actions/types/__init__.py +25 -0
  24. label_studio_sdk/actions/types/actions_create_request_filters.py +43 -0
  25. label_studio_sdk/actions/types/actions_create_request_filters_conjunction.py +5 -0
  26. label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +49 -0
  27. label_studio_sdk/actions/types/actions_create_request_filters_items_item_filter.py +31 -0
  28. label_studio_sdk/actions/types/actions_create_request_filters_items_item_operator.py +23 -0
  29. label_studio_sdk/actions/types/actions_create_request_id.py +19 -0
  30. label_studio_sdk/actions/types/actions_create_request_ordering_item.py +31 -0
  31. label_studio_sdk/actions/types/actions_create_request_selected_items.py +10 -0
  32. label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +39 -0
  33. label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +39 -0
  34. label_studio_sdk/annotations/__init__.py +2 -0
  35. label_studio_sdk/annotations/client.py +750 -0
  36. label_studio_sdk/base_client.py +183 -0
  37. label_studio_sdk/client.py +17 -463
  38. label_studio_sdk/converter/__init__.py +7 -0
  39. label_studio_sdk/converter/audio.py +56 -0
  40. label_studio_sdk/converter/brush.py +452 -0
  41. label_studio_sdk/converter/converter.py +1175 -0
  42. label_studio_sdk/converter/exports/__init__.py +0 -0
  43. label_studio_sdk/converter/exports/csv.py +82 -0
  44. label_studio_sdk/converter/exports/csv2.py +103 -0
  45. label_studio_sdk/converter/funsd.py +85 -0
  46. label_studio_sdk/converter/imports/__init__.py +0 -0
  47. label_studio_sdk/converter/imports/coco.py +314 -0
  48. label_studio_sdk/converter/imports/colors.py +198 -0
  49. label_studio_sdk/converter/imports/label_config.py +45 -0
  50. label_studio_sdk/converter/imports/pathtrack.py +269 -0
  51. label_studio_sdk/converter/imports/yolo.py +236 -0
  52. label_studio_sdk/converter/main.py +202 -0
  53. label_studio_sdk/converter/utils.py +473 -0
  54. label_studio_sdk/core/__init__.py +33 -0
  55. label_studio_sdk/core/api_error.py +15 -0
  56. label_studio_sdk/core/client_wrapper.py +55 -0
  57. label_studio_sdk/core/datetime_utils.py +28 -0
  58. label_studio_sdk/core/file.py +38 -0
  59. label_studio_sdk/core/http_client.py +447 -0
  60. label_studio_sdk/core/jsonable_encoder.py +99 -0
  61. label_studio_sdk/core/pagination.py +87 -0
  62. label_studio_sdk/core/pydantic_utilities.py +28 -0
  63. label_studio_sdk/core/query_encoder.py +33 -0
  64. label_studio_sdk/core/remove_none_from_dict.py +11 -0
  65. label_studio_sdk/core/request_options.py +32 -0
  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 +888 -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 +67 -0
  75. label_studio_sdk/export_storage/azure/types/azure_update_response.py +67 -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 +888 -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 +67 -0
  81. label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +67 -0
  82. label_studio_sdk/export_storage/local/__init__.py +5 -0
  83. label_studio_sdk/export_storage/local/client.py +834 -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 +57 -0
  86. label_studio_sdk/export_storage/local/types/local_update_response.py +57 -0
  87. label_studio_sdk/export_storage/redis/__init__.py +5 -0
  88. label_studio_sdk/export_storage/redis/client.py +918 -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 +72 -0
  91. label_studio_sdk/export_storage/redis/types/redis_update_response.py +72 -0
  92. label_studio_sdk/export_storage/s3/__init__.py +5 -0
  93. label_studio_sdk/export_storage/s3/client.py +1008 -0
  94. label_studio_sdk/export_storage/s3/types/__init__.py +6 -0
  95. label_studio_sdk/export_storage/s3/types/s3create_response.py +89 -0
  96. label_studio_sdk/export_storage/s3/types/s3update_response.py +89 -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 +988 -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 +82 -0
  106. label_studio_sdk/import_storage/azure/types/azure_update_response.py +82 -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 +988 -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 +82 -0
  112. label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +82 -0
  113. label_studio_sdk/import_storage/local/__init__.py +5 -0
  114. label_studio_sdk/import_storage/local/client.py +836 -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 +57 -0
  117. label_studio_sdk/import_storage/local/types/local_update_response.py +57 -0
  118. label_studio_sdk/import_storage/redis/__init__.py +5 -0
  119. label_studio_sdk/import_storage/redis/client.py +924 -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 +72 -0
  122. label_studio_sdk/import_storage/redis/types/redis_update_response.py +72 -0
  123. label_studio_sdk/import_storage/s3/__init__.py +5 -0
  124. label_studio_sdk/import_storage/s3/client.py +1138 -0
  125. label_studio_sdk/import_storage/s3/types/__init__.py +6 -0
  126. label_studio_sdk/import_storage/s3/types/s3create_response.py +109 -0
  127. label_studio_sdk/import_storage/s3/types/s3update_response.py +109 -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/label_interface/base.py +10 -0
  131. label_studio_sdk/label_interface/control_tags.py +109 -71
  132. label_studio_sdk/label_interface/data_examples.json +96 -0
  133. label_studio_sdk/label_interface/interface.py +102 -53
  134. label_studio_sdk/label_interface/object_tags.py +8 -13
  135. label_studio_sdk/label_interface/region.py +33 -1
  136. label_studio_sdk/ml/__init__.py +19 -0
  137. label_studio_sdk/ml/client.py +981 -0
  138. label_studio_sdk/ml/types/__init__.py +17 -0
  139. label_studio_sdk/ml/types/ml_create_request_auth_method.py +5 -0
  140. label_studio_sdk/ml/types/ml_create_response.py +78 -0
  141. label_studio_sdk/ml/types/ml_create_response_auth_method.py +5 -0
  142. label_studio_sdk/ml/types/ml_update_request_auth_method.py +5 -0
  143. label_studio_sdk/ml/types/ml_update_response.py +78 -0
  144. label_studio_sdk/ml/types/ml_update_response_auth_method.py +5 -0
  145. label_studio_sdk/predictions/__init__.py +2 -0
  146. label_studio_sdk/predictions/client.py +638 -0
  147. label_studio_sdk/projects/__init__.py +6 -0
  148. label_studio_sdk/projects/client.py +1055 -0
  149. label_studio_sdk/projects/client_ext.py +19 -0
  150. label_studio_sdk/projects/exports/__init__.py +2 -0
  151. label_studio_sdk/projects/exports/client.py +930 -0
  152. label_studio_sdk/projects/types/__init__.py +7 -0
  153. label_studio_sdk/projects/types/projects_create_response.py +96 -0
  154. label_studio_sdk/projects/types/projects_import_tasks_response.py +71 -0
  155. label_studio_sdk/projects/types/projects_list_response.py +33 -0
  156. label_studio_sdk/py.typed +0 -0
  157. label_studio_sdk/tasks/__init__.py +5 -0
  158. label_studio_sdk/tasks/client.py +835 -0
  159. label_studio_sdk/tasks/client_ext.py +18 -0
  160. label_studio_sdk/tasks/types/__init__.py +6 -0
  161. label_studio_sdk/tasks/types/tasks_list_request_fields.py +5 -0
  162. label_studio_sdk/tasks/types/tasks_list_response.py +48 -0
  163. label_studio_sdk/types/__init__.py +115 -0
  164. label_studio_sdk/types/annotation.py +116 -0
  165. label_studio_sdk/types/annotation_filter_options.py +42 -0
  166. label_studio_sdk/types/annotation_last_action.py +19 -0
  167. label_studio_sdk/types/azure_blob_export_storage.py +112 -0
  168. label_studio_sdk/types/azure_blob_export_storage_status.py +7 -0
  169. label_studio_sdk/types/azure_blob_import_storage.py +113 -0
  170. label_studio_sdk/types/azure_blob_import_storage_status.py +7 -0
  171. label_studio_sdk/types/base_task.py +113 -0
  172. label_studio_sdk/types/base_user.py +42 -0
  173. label_studio_sdk/types/converted_format.py +36 -0
  174. label_studio_sdk/types/converted_format_status.py +5 -0
  175. label_studio_sdk/types/export.py +48 -0
  176. label_studio_sdk/types/export_convert.py +32 -0
  177. label_studio_sdk/types/export_create.py +54 -0
  178. label_studio_sdk/types/export_create_status.py +5 -0
  179. label_studio_sdk/types/export_status.py +5 -0
  180. label_studio_sdk/types/file_upload.py +30 -0
  181. label_studio_sdk/types/filter.py +53 -0
  182. label_studio_sdk/types/filter_group.py +35 -0
  183. label_studio_sdk/types/gcs_export_storage.py +112 -0
  184. label_studio_sdk/types/gcs_export_storage_status.py +7 -0
  185. label_studio_sdk/types/gcs_import_storage.py +113 -0
  186. label_studio_sdk/types/gcs_import_storage_status.py +7 -0
  187. label_studio_sdk/types/local_files_export_storage.py +97 -0
  188. label_studio_sdk/types/local_files_export_storage_status.py +7 -0
  189. label_studio_sdk/types/local_files_import_storage.py +92 -0
  190. label_studio_sdk/types/local_files_import_storage_status.py +7 -0
  191. label_studio_sdk/types/ml_backend.py +89 -0
  192. label_studio_sdk/types/ml_backend_auth_method.py +5 -0
  193. label_studio_sdk/types/ml_backend_state.py +5 -0
  194. label_studio_sdk/types/prediction.py +78 -0
  195. label_studio_sdk/types/project.py +198 -0
  196. label_studio_sdk/types/project_import.py +63 -0
  197. label_studio_sdk/types/project_import_status.py +5 -0
  198. label_studio_sdk/types/project_label_config.py +32 -0
  199. label_studio_sdk/types/project_sampling.py +7 -0
  200. label_studio_sdk/types/project_skip_queue.py +5 -0
  201. label_studio_sdk/types/redis_export_storage.py +117 -0
  202. label_studio_sdk/types/redis_export_storage_status.py +7 -0
  203. label_studio_sdk/types/redis_import_storage.py +112 -0
  204. label_studio_sdk/types/redis_import_storage_status.py +7 -0
  205. label_studio_sdk/types/s3export_storage.py +134 -0
  206. label_studio_sdk/types/s3export_storage_status.py +7 -0
  207. label_studio_sdk/types/s3import_storage.py +140 -0
  208. label_studio_sdk/types/s3import_storage_status.py +7 -0
  209. label_studio_sdk/types/serialization_option.py +36 -0
  210. label_studio_sdk/types/serialization_options.py +45 -0
  211. label_studio_sdk/types/task.py +157 -0
  212. label_studio_sdk/types/task_filter_options.py +49 -0
  213. label_studio_sdk/types/user_simple.py +37 -0
  214. label_studio_sdk/types/view.py +55 -0
  215. label_studio_sdk/types/webhook.py +67 -0
  216. label_studio_sdk/types/webhook_actions_item.py +21 -0
  217. label_studio_sdk/types/webhook_serializer_for_update.py +67 -0
  218. label_studio_sdk/types/webhook_serializer_for_update_actions_item.py +21 -0
  219. label_studio_sdk/users/__init__.py +5 -0
  220. label_studio_sdk/users/client.py +830 -0
  221. label_studio_sdk/users/types/__init__.py +6 -0
  222. label_studio_sdk/users/types/users_get_token_response.py +36 -0
  223. label_studio_sdk/users/types/users_reset_token_response.py +36 -0
  224. label_studio_sdk/version.py +4 -0
  225. label_studio_sdk/views/__init__.py +35 -0
  226. label_studio_sdk/views/client.py +564 -0
  227. label_studio_sdk/views/types/__init__.py +33 -0
  228. label_studio_sdk/views/types/views_create_request_data.py +43 -0
  229. label_studio_sdk/views/types/views_create_request_data_filters.py +43 -0
  230. label_studio_sdk/views/types/views_create_request_data_filters_conjunction.py +5 -0
  231. label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +49 -0
  232. label_studio_sdk/views/types/views_create_request_data_filters_items_item_filter.py +31 -0
  233. label_studio_sdk/views/types/views_create_request_data_filters_items_item_operator.py +23 -0
  234. label_studio_sdk/views/types/views_create_request_data_ordering_item.py +31 -0
  235. label_studio_sdk/views/types/views_update_request_data.py +43 -0
  236. label_studio_sdk/views/types/views_update_request_data_filters.py +43 -0
  237. label_studio_sdk/views/types/views_update_request_data_filters_conjunction.py +5 -0
  238. label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +49 -0
  239. label_studio_sdk/views/types/views_update_request_data_filters_items_item_filter.py +31 -0
  240. label_studio_sdk/views/types/views_update_request_data_filters_items_item_operator.py +23 -0
  241. label_studio_sdk/views/types/views_update_request_data_ordering_item.py +31 -0
  242. label_studio_sdk/webhooks/__init__.py +5 -0
  243. label_studio_sdk/webhooks/client.py +636 -0
  244. label_studio_sdk/webhooks/types/__init__.py +5 -0
  245. label_studio_sdk/webhooks/types/webhooks_update_request_actions_item.py +21 -0
  246. label_studio_sdk-1.0.1.dist-info/METADATA +163 -0
  247. label_studio_sdk-1.0.1.dist-info/RECORD +256 -0
  248. {label_studio_sdk-0.0.34.dist-info → label_studio_sdk-1.0.1.dist-info}/WHEEL +1 -2
  249. label_studio_sdk/objects.py +0 -35
  250. label_studio_sdk-0.0.34.dist-info/LICENSE +0 -201
  251. label_studio_sdk-0.0.34.dist-info/METADATA +0 -24
  252. label_studio_sdk-0.0.34.dist-info/RECORD +0 -37
  253. label_studio_sdk-0.0.34.dist-info/top_level.txt +0 -2
  254. tests/test_client.py +0 -37
  255. tests/test_export.py +0 -105
  256. tests/test_interface/__init__.py +0 -1
  257. tests/test_interface/configs.py +0 -137
  258. tests/test_interface/mockups.py +0 -22
  259. tests/test_interface/test_compat.py +0 -64
  260. tests/test_interface/test_control_tags.py +0 -55
  261. tests/test_interface/test_data_generation.py +0 -45
  262. tests/test_interface/test_lpi.py +0 -15
  263. tests/test_interface/test_main.py +0 -196
  264. tests/test_interface/test_object_tags.py +0 -36
  265. tests/test_interface/test_region.py +0 -36
  266. tests/test_interface/test_validate_summary.py +0 -35
  267. tests/test_interface/test_validation.py +0 -59
  268. {tests → label_studio_sdk/_extensions}/__init__.py +0 -0
  269. /label_studio_sdk/{exceptions.py → _legacy/exceptions.py} +0 -0
  270. /label_studio_sdk/{users.py → _legacy/users.py} +0 -0
  271. /label_studio_sdk/{utils.py → _legacy/utils.py} +0 -0
  272. /label_studio_sdk/{workspaces.py → _legacy/workspaces.py} +0 -0
@@ -0,0 +1,1055 @@
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.pagination import AsyncPager, SyncPager
10
+ from ..core.pydantic_utilities import pydantic_v1
11
+ from ..core.request_options import RequestOptions
12
+ from ..errors.bad_request_error import BadRequestError
13
+ from ..types.project import Project
14
+ from ..types.project_label_config import ProjectLabelConfig
15
+ from .exports.client import AsyncExportsClient, ExportsClient
16
+ from .types.projects_create_response import ProjectsCreateResponse
17
+ from .types.projects_import_tasks_response import ProjectsImportTasksResponse
18
+ from .types.projects_list_response import ProjectsListResponse
19
+
20
+ # this is used as the default value for optional parameters
21
+ OMIT = typing.cast(typing.Any, ...)
22
+
23
+
24
+ class ProjectsClient:
25
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
26
+ self._client_wrapper = client_wrapper
27
+ self.exports = ExportsClient(client_wrapper=self._client_wrapper)
28
+
29
+ def list(
30
+ self,
31
+ *,
32
+ ordering: typing.Optional[str] = None,
33
+ ids: typing.Optional[str] = None,
34
+ title: typing.Optional[str] = None,
35
+ page: typing.Optional[int] = None,
36
+ page_size: typing.Optional[int] = None,
37
+ request_options: typing.Optional[RequestOptions] = None,
38
+ ) -> SyncPager[Project]:
39
+ """
40
+ Return a list of the projects within your organization.
41
+
42
+ To perform most tasks with the Label Studio API, you must specify the project ID, sometimes referred to as the `pk`. The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using this API call.
43
+
44
+ To retrieve a list of your Label Studio projects, update the following command to match your own environment.
45
+ Replace the domain name, port, and authorization token, then run the following from the command line:
46
+
47
+ ```bash
48
+ curl -X GET https://localhost:8080/api/projects/ -H 'Authorization: Token abc123'
49
+ ```
50
+
51
+ Parameters
52
+ ----------
53
+ ordering : typing.Optional[str]
54
+ Which field to use when ordering the results.
55
+
56
+ ids : typing.Optional[str]
57
+ ids
58
+
59
+ title : typing.Optional[str]
60
+ title
61
+
62
+ page : typing.Optional[int]
63
+ A page number within the paginated result set.
64
+
65
+ page_size : typing.Optional[int]
66
+ Number of results to return per page.
67
+
68
+ request_options : typing.Optional[RequestOptions]
69
+ Request-specific configuration.
70
+
71
+ Returns
72
+ -------
73
+ SyncPager[Project]
74
+
75
+
76
+ Examples
77
+ --------
78
+ from label_studio_sdk.client import LabelStudio
79
+
80
+ client = LabelStudio(
81
+ api_key="YOUR_API_KEY",
82
+ )
83
+ client.projects.list()
84
+ """
85
+ page = page or 1
86
+ _response = self._client_wrapper.httpx_client.request(
87
+ "api/projects/",
88
+ method="GET",
89
+ params={"ordering": ordering, "ids": ids, "title": title, "page": page, "page_size": page_size},
90
+ request_options=request_options,
91
+ )
92
+ if 200 <= _response.status_code < 300:
93
+ _parsed_response = pydantic_v1.parse_obj_as(ProjectsListResponse, _response.json()) # type: ignore
94
+ _has_next = True
95
+ _get_next = lambda: self.list(
96
+ ordering=ordering,
97
+ ids=ids,
98
+ title=title,
99
+ page=page + 1,
100
+ page_size=page_size,
101
+ request_options=request_options,
102
+ )
103
+ _items = _parsed_response.results
104
+ return SyncPager(has_next=_has_next, items=_items, get_next=_get_next)
105
+ try:
106
+ _response_json = _response.json()
107
+ except JSONDecodeError:
108
+ raise ApiError(status_code=_response.status_code, body=_response.text)
109
+ raise ApiError(status_code=_response.status_code, body=_response_json)
110
+
111
+ def create(
112
+ self,
113
+ *,
114
+ title: typing.Optional[str] = OMIT,
115
+ description: typing.Optional[str] = OMIT,
116
+ label_config: typing.Optional[str] = OMIT,
117
+ expert_instruction: typing.Optional[str] = OMIT,
118
+ show_instruction: typing.Optional[bool] = OMIT,
119
+ show_skip_button: typing.Optional[bool] = OMIT,
120
+ enable_empty_annotation: typing.Optional[bool] = OMIT,
121
+ show_annotation_history: typing.Optional[bool] = OMIT,
122
+ reveal_preannotations_interactively: typing.Optional[bool] = OMIT,
123
+ show_collab_predictions: typing.Optional[bool] = OMIT,
124
+ maximum_annotations: typing.Optional[int] = OMIT,
125
+ color: typing.Optional[str] = OMIT,
126
+ control_weights: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
127
+ request_options: typing.Optional[RequestOptions] = None,
128
+ ) -> ProjectsCreateResponse:
129
+ """
130
+ Create a project and set up the labeling interface. For more information about setting up projects, see the following:
131
+
132
+ - [Create and configure projects](https://labelstud.io/guide/setup_project)
133
+ - [Configure labeling interface](https://labelstud.io/guide/setup)
134
+ - [Project settings](https://labelstud.io/guide/project_settings)
135
+
136
+ ```bash
137
+ curl -H Content-Type:application/json -H 'Authorization: Token abc123' -X POST 'https://localhost:8080/api/projects' --data '{"label_config": "<View>[...]</View>"}'
138
+ ```
139
+
140
+ Parameters
141
+ ----------
142
+ title : typing.Optional[str]
143
+ Project title
144
+
145
+ description : typing.Optional[str]
146
+ Project description
147
+
148
+ label_config : typing.Optional[str]
149
+ Label config in XML format
150
+
151
+ expert_instruction : typing.Optional[str]
152
+ Labeling instructions to show to the user
153
+
154
+ show_instruction : typing.Optional[bool]
155
+ Show labeling instructions
156
+
157
+ show_skip_button : typing.Optional[bool]
158
+ Show skip button
159
+
160
+ enable_empty_annotation : typing.Optional[bool]
161
+ Allow empty annotations
162
+
163
+ show_annotation_history : typing.Optional[bool]
164
+ Show annotation history
165
+
166
+ reveal_preannotations_interactively : typing.Optional[bool]
167
+ Reveal preannotations interactively. If set to True, predictions will be shown to the user only after selecting the area of interest
168
+
169
+ show_collab_predictions : typing.Optional[bool]
170
+ Show predictions to annotators
171
+
172
+ maximum_annotations : typing.Optional[int]
173
+ Maximum annotations per task
174
+
175
+ color : typing.Optional[str]
176
+ Project color in HEX format
177
+
178
+ control_weights : typing.Optional[typing.Dict[str, typing.Any]]
179
+ Dict of weights for each control tag in metric calculation. Each control tag (e.g. label or choice) will have its own key in control weight dict with weight for each label and overall weight. For example, if a bounding box annotation with a control tag named my_bbox should be included with 0.33 weight in agreement calculation, and the first label Car should be twice as important as Airplane, then you need to specify: {'my_bbox': {'type': 'RectangleLabels', 'labels': {'Car': 1.0, 'Airplane': 0.5}, 'overall': 0.33}
180
+
181
+ request_options : typing.Optional[RequestOptions]
182
+ Request-specific configuration.
183
+
184
+ Returns
185
+ -------
186
+ ProjectsCreateResponse
187
+
188
+
189
+ Examples
190
+ --------
191
+ from label_studio_sdk.client import LabelStudio
192
+
193
+ client = LabelStudio(
194
+ api_key="YOUR_API_KEY",
195
+ )
196
+ client.projects.create()
197
+ """
198
+ _response = self._client_wrapper.httpx_client.request(
199
+ "api/projects/",
200
+ method="POST",
201
+ json={
202
+ "title": title,
203
+ "description": description,
204
+ "label_config": label_config,
205
+ "expert_instruction": expert_instruction,
206
+ "show_instruction": show_instruction,
207
+ "show_skip_button": show_skip_button,
208
+ "enable_empty_annotation": enable_empty_annotation,
209
+ "show_annotation_history": show_annotation_history,
210
+ "reveal_preannotations_interactively": reveal_preannotations_interactively,
211
+ "show_collab_predictions": show_collab_predictions,
212
+ "maximum_annotations": maximum_annotations,
213
+ "color": color,
214
+ "control_weights": control_weights,
215
+ },
216
+ request_options=request_options,
217
+ omit=OMIT,
218
+ )
219
+ if 200 <= _response.status_code < 300:
220
+ return pydantic_v1.parse_obj_as(ProjectsCreateResponse, _response.json()) # type: ignore
221
+ try:
222
+ _response_json = _response.json()
223
+ except JSONDecodeError:
224
+ raise ApiError(status_code=_response.status_code, body=_response.text)
225
+ raise ApiError(status_code=_response.status_code, body=_response_json)
226
+
227
+ def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Project:
228
+ """
229
+ Retrieve information about a specific project by 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).
230
+
231
+ Parameters
232
+ ----------
233
+ id : int
234
+ A unique integer value identifying this project.
235
+
236
+ request_options : typing.Optional[RequestOptions]
237
+ Request-specific configuration.
238
+
239
+ Returns
240
+ -------
241
+ Project
242
+ Project information
243
+
244
+ Examples
245
+ --------
246
+ from label_studio_sdk.client import LabelStudio
247
+
248
+ client = LabelStudio(
249
+ api_key="YOUR_API_KEY",
250
+ )
251
+ client.projects.get(
252
+ id=1,
253
+ )
254
+ """
255
+ _response = self._client_wrapper.httpx_client.request(
256
+ f"api/projects/{jsonable_encoder(id)}/", method="GET", request_options=request_options
257
+ )
258
+ if 200 <= _response.status_code < 300:
259
+ return pydantic_v1.parse_obj_as(Project, _response.json()) # type: ignore
260
+ try:
261
+ _response_json = _response.json()
262
+ except JSONDecodeError:
263
+ raise ApiError(status_code=_response.status_code, body=_response.text)
264
+ raise ApiError(status_code=_response.status_code, body=_response_json)
265
+
266
+ def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
267
+ """
268
+ Delete a project by specified project ID. Deleting a project permanently removes all tasks, annotations, and project data from Label Studio.
269
+
270
+ 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).
271
+
272
+ Parameters
273
+ ----------
274
+ id : int
275
+ A unique integer value identifying this project.
276
+
277
+ request_options : typing.Optional[RequestOptions]
278
+ Request-specific configuration.
279
+
280
+ Returns
281
+ -------
282
+ None
283
+
284
+ Examples
285
+ --------
286
+ from label_studio_sdk.client import LabelStudio
287
+
288
+ client = LabelStudio(
289
+ api_key="YOUR_API_KEY",
290
+ )
291
+ client.projects.delete(
292
+ id=1,
293
+ )
294
+ """
295
+ _response = self._client_wrapper.httpx_client.request(
296
+ f"api/projects/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
297
+ )
298
+ if 200 <= _response.status_code < 300:
299
+ return
300
+ try:
301
+ _response_json = _response.json()
302
+ except JSONDecodeError:
303
+ raise ApiError(status_code=_response.status_code, body=_response.text)
304
+ raise ApiError(status_code=_response.status_code, body=_response_json)
305
+
306
+ def update(self, id: int, *, request: Project, request_options: typing.Optional[RequestOptions] = None) -> Project:
307
+ """
308
+ Update the project settings for a specific project. For more information, see the following:
309
+
310
+ - [Create and configure projects](https://labelstud.io/guide/setup_project)
311
+ - [Configure labeling interface](https://labelstud.io/guide/setup)
312
+ - [Project settings](https://labelstud.io/guide/project_settings)
313
+
314
+ 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).
315
+
316
+ <Warning>
317
+ If you are modifying the labeling config for project that has in-progress work, note the following:
318
+ * You cannot remove labels or change the type of labeling being performed unless you delete any existing annotations that are using those labels.
319
+ * If you make changes to the labeling configuration, any tabs that you might have created in the Data Manager are removed.
320
+ </Warning>
321
+
322
+ Parameters
323
+ ----------
324
+ id : int
325
+ A unique integer value identifying this project.
326
+
327
+ request : Project
328
+
329
+ request_options : typing.Optional[RequestOptions]
330
+ Request-specific configuration.
331
+
332
+ Returns
333
+ -------
334
+ Project
335
+
336
+
337
+ Examples
338
+ --------
339
+ from label_studio_sdk import Project
340
+ from label_studio_sdk.client import LabelStudio
341
+
342
+ client = LabelStudio(
343
+ api_key="YOUR_API_KEY",
344
+ )
345
+ client.projects.update(
346
+ id=1,
347
+ request=Project(),
348
+ )
349
+ """
350
+ _response = self._client_wrapper.httpx_client.request(
351
+ f"api/projects/{jsonable_encoder(id)}/",
352
+ method="PATCH",
353
+ json=request,
354
+ request_options=request_options,
355
+ omit=OMIT,
356
+ )
357
+ if 200 <= _response.status_code < 300:
358
+ return pydantic_v1.parse_obj_as(Project, _response.json()) # type: ignore
359
+ try:
360
+ _response_json = _response.json()
361
+ except JSONDecodeError:
362
+ raise ApiError(status_code=_response.status_code, body=_response.text)
363
+ raise ApiError(status_code=_response.status_code, body=_response_json)
364
+
365
+ def import_tasks(
366
+ self,
367
+ id: int,
368
+ *,
369
+ request: typing.Sequence[typing.Dict[str, typing.Any]],
370
+ commit_to_project: typing.Optional[bool] = None,
371
+ return_task_ids: typing.Optional[bool] = None,
372
+ preannotated_from_fields: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
373
+ request_options: typing.Optional[RequestOptions] = None,
374
+ ) -> ProjectsImportTasksResponse:
375
+ """
376
+ Use this API endpoint to import labeling tasks in bulk. Note that each POST request is limited at 250K tasks and 200 MB.
377
+ 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).
378
+
379
+ <Note>
380
+ Imported data is verified against a project *label_config* and must include all variables that were used in the *label_config*.
381
+
382
+ For example, if the label configuration has a _$text_ variable, then each item in a data object must include a `text` field.
383
+ </Note>
384
+
385
+ There are three possible ways to import tasks with this endpoint:
386
+
387
+ #### 1\. **POST with data**
388
+
389
+ Send JSON tasks as POST data. Only JSON is supported for POSTing files directly.
390
+
391
+ Update this example to specify your authorization token and Label Studio instance host, then run the following from
392
+ the command line:
393
+
394
+ ```bash
395
+ curl -H 'Content-Type: application/json' -H 'Authorization: Token abc123' \
396
+ -X POST 'https://localhost:8080/api/projects/1/import' --data '[{"text": "Some text 1"}, {"text": "Some text 2"}]'
397
+ ```
398
+
399
+ #### 2\. **POST with files**
400
+
401
+ Send tasks as files. You can attach multiple files with different names.
402
+
403
+ - **JSON**: text files in JavaScript object notation format
404
+ - **CSV**: text files with tables in Comma Separated Values format
405
+ - **TSV**: text files with tables in Tab Separated Value format
406
+ - **TXT**: simple text files are similar to CSV with one column and no header, supported for projects with one source only
407
+
408
+ Update this example to specify your authorization token, Label Studio instance host, and file name and path,
409
+ then run the following from the command line:
410
+
411
+ ```bash
412
+ curl -H 'Authorization: Token abc123' \
413
+ -X POST 'https://localhost:8080/api/projects/1/import' -F ‘file=@path/to/my_file.csv’
414
+ ```
415
+
416
+ #### 3\. **POST with URL**
417
+
418
+ You can also provide a URL to a file with labeling tasks. Supported file formats are the same as in option 2.
419
+
420
+ ```bash
421
+ curl -H 'Content-Type: application/json' -H 'Authorization: Token abc123' \
422
+ -X POST 'https://localhost:8080/api/projects/1/import' \
423
+ --data '[{"url": "http://example.com/test1.csv"}, {"url": "http://example.com/test2.csv"}]'
424
+ ```
425
+
426
+ <br>
427
+
428
+ Parameters
429
+ ----------
430
+ id : int
431
+ A unique integer value identifying this project.
432
+
433
+ request : typing.Sequence[typing.Dict[str, typing.Any]]
434
+
435
+ commit_to_project : typing.Optional[bool]
436
+ Set to "true" to immediately commit tasks to the project.
437
+
438
+ return_task_ids : typing.Optional[bool]
439
+ Set to "true" to return task IDs in the response.
440
+
441
+ preannotated_from_fields : typing.Optional[typing.Union[str, typing.Sequence[str]]]
442
+ List of fields to preannotate from the task data. For example, if you provide a list of `{"text": "text", "prediction": "label"}` items in the request, the system will create a task with the `text` field and a prediction with the `label` field when `preannoted_from_fields=["prediction"]`.
443
+
444
+ request_options : typing.Optional[RequestOptions]
445
+ Request-specific configuration.
446
+
447
+ Returns
448
+ -------
449
+ ProjectsImportTasksResponse
450
+ Tasks successfully imported
451
+
452
+ Examples
453
+ --------
454
+ from label_studio_sdk.client import LabelStudio
455
+
456
+ client = LabelStudio(
457
+ api_key="YOUR_API_KEY",
458
+ )
459
+ client.projects.import_tasks(
460
+ id=1,
461
+ request=[{}],
462
+ )
463
+ """
464
+ _response = self._client_wrapper.httpx_client.request(
465
+ f"api/projects/{jsonable_encoder(id)}/import",
466
+ method="POST",
467
+ params={
468
+ "commit_to_project": commit_to_project,
469
+ "return_task_ids": return_task_ids,
470
+ "preannotated_from_fields": preannotated_from_fields,
471
+ },
472
+ json=request,
473
+ request_options=request_options,
474
+ omit=OMIT,
475
+ )
476
+ if 200 <= _response.status_code < 300:
477
+ return pydantic_v1.parse_obj_as(ProjectsImportTasksResponse, _response.json()) # type: ignore
478
+ if _response.status_code == 400:
479
+ raise BadRequestError(pydantic_v1.parse_obj_as(str, _response.json())) # type: ignore
480
+ try:
481
+ _response_json = _response.json()
482
+ except JSONDecodeError:
483
+ raise ApiError(status_code=_response.status_code, body=_response.text)
484
+ raise ApiError(status_code=_response.status_code, body=_response_json)
485
+
486
+ def validate_config(
487
+ self, id: int, *, request: ProjectLabelConfig, request_options: typing.Optional[RequestOptions] = None
488
+ ) -> ProjectLabelConfig:
489
+ """
490
+ Determine whether the label configuration for a specific project is valid. For more information about setting up labeling configs, see [Configure labeling interface](https://labelstud.io/guide/setup) and our [Tags reference](https://labelstud.io/tags/).
491
+
492
+ 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).
493
+
494
+ Parameters
495
+ ----------
496
+ id : int
497
+ A unique integer value identifying this project.
498
+
499
+ request : ProjectLabelConfig
500
+
501
+ request_options : typing.Optional[RequestOptions]
502
+ Request-specific configuration.
503
+
504
+ Returns
505
+ -------
506
+ ProjectLabelConfig
507
+
508
+
509
+ Examples
510
+ --------
511
+ from label_studio_sdk import ProjectLabelConfig
512
+ from label_studio_sdk.client import LabelStudio
513
+
514
+ client = LabelStudio(
515
+ api_key="YOUR_API_KEY",
516
+ )
517
+ client.projects.validate_config(
518
+ id=1,
519
+ request=ProjectLabelConfig(
520
+ label_config="label_config",
521
+ ),
522
+ )
523
+ """
524
+ _response = self._client_wrapper.httpx_client.request(
525
+ f"api/projects/{jsonable_encoder(id)}/validate/",
526
+ method="POST",
527
+ json=request,
528
+ request_options=request_options,
529
+ omit=OMIT,
530
+ )
531
+ if 200 <= _response.status_code < 300:
532
+ return pydantic_v1.parse_obj_as(ProjectLabelConfig, _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
+
540
+ class AsyncProjectsClient:
541
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
542
+ self._client_wrapper = client_wrapper
543
+ self.exports = AsyncExportsClient(client_wrapper=self._client_wrapper)
544
+
545
+ async def list(
546
+ self,
547
+ *,
548
+ ordering: typing.Optional[str] = None,
549
+ ids: typing.Optional[str] = None,
550
+ title: typing.Optional[str] = None,
551
+ page: typing.Optional[int] = None,
552
+ page_size: typing.Optional[int] = None,
553
+ request_options: typing.Optional[RequestOptions] = None,
554
+ ) -> AsyncPager[Project]:
555
+ """
556
+ Return a list of the projects within your organization.
557
+
558
+ To perform most tasks with the Label Studio API, you must specify the project ID, sometimes referred to as the `pk`. The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using this API call.
559
+
560
+ To retrieve a list of your Label Studio projects, update the following command to match your own environment.
561
+ Replace the domain name, port, and authorization token, then run the following from the command line:
562
+
563
+ ```bash
564
+ curl -X GET https://localhost:8080/api/projects/ -H 'Authorization: Token abc123'
565
+ ```
566
+
567
+ Parameters
568
+ ----------
569
+ ordering : typing.Optional[str]
570
+ Which field to use when ordering the results.
571
+
572
+ ids : typing.Optional[str]
573
+ ids
574
+
575
+ title : typing.Optional[str]
576
+ title
577
+
578
+ page : typing.Optional[int]
579
+ A page number within the paginated result set.
580
+
581
+ page_size : typing.Optional[int]
582
+ Number of results to return per page.
583
+
584
+ request_options : typing.Optional[RequestOptions]
585
+ Request-specific configuration.
586
+
587
+ Returns
588
+ -------
589
+ AsyncPager[Project]
590
+
591
+
592
+ Examples
593
+ --------
594
+ from label_studio_sdk.client import AsyncLabelStudio
595
+
596
+ client = AsyncLabelStudio(
597
+ api_key="YOUR_API_KEY",
598
+ )
599
+ await client.projects.list()
600
+ """
601
+ page = page or 1
602
+ _response = await self._client_wrapper.httpx_client.request(
603
+ "api/projects/",
604
+ method="GET",
605
+ params={"ordering": ordering, "ids": ids, "title": title, "page": page, "page_size": page_size},
606
+ request_options=request_options,
607
+ )
608
+ if 200 <= _response.status_code < 300:
609
+ _parsed_response = pydantic_v1.parse_obj_as(ProjectsListResponse, _response.json()) # type: ignore
610
+ _has_next = True
611
+ _get_next = lambda: self.list(
612
+ ordering=ordering,
613
+ ids=ids,
614
+ title=title,
615
+ page=page + 1,
616
+ page_size=page_size,
617
+ request_options=request_options,
618
+ )
619
+ _items = _parsed_response.results
620
+ return AsyncPager(has_next=_has_next, items=_items, get_next=_get_next)
621
+ try:
622
+ _response_json = _response.json()
623
+ except JSONDecodeError:
624
+ raise ApiError(status_code=_response.status_code, body=_response.text)
625
+ raise ApiError(status_code=_response.status_code, body=_response_json)
626
+
627
+ async def create(
628
+ self,
629
+ *,
630
+ title: typing.Optional[str] = OMIT,
631
+ description: typing.Optional[str] = OMIT,
632
+ label_config: typing.Optional[str] = OMIT,
633
+ expert_instruction: typing.Optional[str] = OMIT,
634
+ show_instruction: typing.Optional[bool] = OMIT,
635
+ show_skip_button: typing.Optional[bool] = OMIT,
636
+ enable_empty_annotation: typing.Optional[bool] = OMIT,
637
+ show_annotation_history: typing.Optional[bool] = OMIT,
638
+ reveal_preannotations_interactively: typing.Optional[bool] = OMIT,
639
+ show_collab_predictions: typing.Optional[bool] = OMIT,
640
+ maximum_annotations: typing.Optional[int] = OMIT,
641
+ color: typing.Optional[str] = OMIT,
642
+ control_weights: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
643
+ request_options: typing.Optional[RequestOptions] = None,
644
+ ) -> ProjectsCreateResponse:
645
+ """
646
+ Create a project and set up the labeling interface. For more information about setting up projects, see the following:
647
+
648
+ - [Create and configure projects](https://labelstud.io/guide/setup_project)
649
+ - [Configure labeling interface](https://labelstud.io/guide/setup)
650
+ - [Project settings](https://labelstud.io/guide/project_settings)
651
+
652
+ ```bash
653
+ curl -H Content-Type:application/json -H 'Authorization: Token abc123' -X POST 'https://localhost:8080/api/projects' --data '{"label_config": "<View>[...]</View>"}'
654
+ ```
655
+
656
+ Parameters
657
+ ----------
658
+ title : typing.Optional[str]
659
+ Project title
660
+
661
+ description : typing.Optional[str]
662
+ Project description
663
+
664
+ label_config : typing.Optional[str]
665
+ Label config in XML format
666
+
667
+ expert_instruction : typing.Optional[str]
668
+ Labeling instructions to show to the user
669
+
670
+ show_instruction : typing.Optional[bool]
671
+ Show labeling instructions
672
+
673
+ show_skip_button : typing.Optional[bool]
674
+ Show skip button
675
+
676
+ enable_empty_annotation : typing.Optional[bool]
677
+ Allow empty annotations
678
+
679
+ show_annotation_history : typing.Optional[bool]
680
+ Show annotation history
681
+
682
+ reveal_preannotations_interactively : typing.Optional[bool]
683
+ Reveal preannotations interactively. If set to True, predictions will be shown to the user only after selecting the area of interest
684
+
685
+ show_collab_predictions : typing.Optional[bool]
686
+ Show predictions to annotators
687
+
688
+ maximum_annotations : typing.Optional[int]
689
+ Maximum annotations per task
690
+
691
+ color : typing.Optional[str]
692
+ Project color in HEX format
693
+
694
+ control_weights : typing.Optional[typing.Dict[str, typing.Any]]
695
+ Dict of weights for each control tag in metric calculation. Each control tag (e.g. label or choice) will have its own key in control weight dict with weight for each label and overall weight. For example, if a bounding box annotation with a control tag named my_bbox should be included with 0.33 weight in agreement calculation, and the first label Car should be twice as important as Airplane, then you need to specify: {'my_bbox': {'type': 'RectangleLabels', 'labels': {'Car': 1.0, 'Airplane': 0.5}, 'overall': 0.33}
696
+
697
+ request_options : typing.Optional[RequestOptions]
698
+ Request-specific configuration.
699
+
700
+ Returns
701
+ -------
702
+ ProjectsCreateResponse
703
+
704
+
705
+ Examples
706
+ --------
707
+ from label_studio_sdk.client import AsyncLabelStudio
708
+
709
+ client = AsyncLabelStudio(
710
+ api_key="YOUR_API_KEY",
711
+ )
712
+ await client.projects.create()
713
+ """
714
+ _response = await self._client_wrapper.httpx_client.request(
715
+ "api/projects/",
716
+ method="POST",
717
+ json={
718
+ "title": title,
719
+ "description": description,
720
+ "label_config": label_config,
721
+ "expert_instruction": expert_instruction,
722
+ "show_instruction": show_instruction,
723
+ "show_skip_button": show_skip_button,
724
+ "enable_empty_annotation": enable_empty_annotation,
725
+ "show_annotation_history": show_annotation_history,
726
+ "reveal_preannotations_interactively": reveal_preannotations_interactively,
727
+ "show_collab_predictions": show_collab_predictions,
728
+ "maximum_annotations": maximum_annotations,
729
+ "color": color,
730
+ "control_weights": control_weights,
731
+ },
732
+ request_options=request_options,
733
+ omit=OMIT,
734
+ )
735
+ if 200 <= _response.status_code < 300:
736
+ return pydantic_v1.parse_obj_as(ProjectsCreateResponse, _response.json()) # type: ignore
737
+ try:
738
+ _response_json = _response.json()
739
+ except JSONDecodeError:
740
+ raise ApiError(status_code=_response.status_code, body=_response.text)
741
+ raise ApiError(status_code=_response.status_code, body=_response_json)
742
+
743
+ async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Project:
744
+ """
745
+ Retrieve information about a specific project by 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).
746
+
747
+ Parameters
748
+ ----------
749
+ id : int
750
+ A unique integer value identifying this project.
751
+
752
+ request_options : typing.Optional[RequestOptions]
753
+ Request-specific configuration.
754
+
755
+ Returns
756
+ -------
757
+ Project
758
+ Project information
759
+
760
+ Examples
761
+ --------
762
+ from label_studio_sdk.client import AsyncLabelStudio
763
+
764
+ client = AsyncLabelStudio(
765
+ api_key="YOUR_API_KEY",
766
+ )
767
+ await client.projects.get(
768
+ id=1,
769
+ )
770
+ """
771
+ _response = await self._client_wrapper.httpx_client.request(
772
+ f"api/projects/{jsonable_encoder(id)}/", method="GET", request_options=request_options
773
+ )
774
+ if 200 <= _response.status_code < 300:
775
+ return pydantic_v1.parse_obj_as(Project, _response.json()) # type: ignore
776
+ try:
777
+ _response_json = _response.json()
778
+ except JSONDecodeError:
779
+ raise ApiError(status_code=_response.status_code, body=_response.text)
780
+ raise ApiError(status_code=_response.status_code, body=_response_json)
781
+
782
+ async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
783
+ """
784
+ Delete a project by specified project ID. Deleting a project permanently removes all tasks, annotations, and project data from Label Studio.
785
+
786
+ 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).
787
+
788
+ Parameters
789
+ ----------
790
+ id : int
791
+ A unique integer value identifying this project.
792
+
793
+ request_options : typing.Optional[RequestOptions]
794
+ Request-specific configuration.
795
+
796
+ Returns
797
+ -------
798
+ None
799
+
800
+ Examples
801
+ --------
802
+ from label_studio_sdk.client import AsyncLabelStudio
803
+
804
+ client = AsyncLabelStudio(
805
+ api_key="YOUR_API_KEY",
806
+ )
807
+ await client.projects.delete(
808
+ id=1,
809
+ )
810
+ """
811
+ _response = await self._client_wrapper.httpx_client.request(
812
+ f"api/projects/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
813
+ )
814
+ if 200 <= _response.status_code < 300:
815
+ return
816
+ try:
817
+ _response_json = _response.json()
818
+ except JSONDecodeError:
819
+ raise ApiError(status_code=_response.status_code, body=_response.text)
820
+ raise ApiError(status_code=_response.status_code, body=_response_json)
821
+
822
+ async def update(
823
+ self, id: int, *, request: Project, request_options: typing.Optional[RequestOptions] = None
824
+ ) -> Project:
825
+ """
826
+ Update the project settings for a specific project. For more information, see the following:
827
+
828
+ - [Create and configure projects](https://labelstud.io/guide/setup_project)
829
+ - [Configure labeling interface](https://labelstud.io/guide/setup)
830
+ - [Project settings](https://labelstud.io/guide/project_settings)
831
+
832
+ 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).
833
+
834
+ <Warning>
835
+ If you are modifying the labeling config for project that has in-progress work, note the following:
836
+ * You cannot remove labels or change the type of labeling being performed unless you delete any existing annotations that are using those labels.
837
+ * If you make changes to the labeling configuration, any tabs that you might have created in the Data Manager are removed.
838
+ </Warning>
839
+
840
+ Parameters
841
+ ----------
842
+ id : int
843
+ A unique integer value identifying this project.
844
+
845
+ request : Project
846
+
847
+ request_options : typing.Optional[RequestOptions]
848
+ Request-specific configuration.
849
+
850
+ Returns
851
+ -------
852
+ Project
853
+
854
+
855
+ Examples
856
+ --------
857
+ from label_studio_sdk import Project
858
+ from label_studio_sdk.client import AsyncLabelStudio
859
+
860
+ client = AsyncLabelStudio(
861
+ api_key="YOUR_API_KEY",
862
+ )
863
+ await client.projects.update(
864
+ id=1,
865
+ request=Project(),
866
+ )
867
+ """
868
+ _response = await self._client_wrapper.httpx_client.request(
869
+ f"api/projects/{jsonable_encoder(id)}/",
870
+ method="PATCH",
871
+ json=request,
872
+ request_options=request_options,
873
+ omit=OMIT,
874
+ )
875
+ if 200 <= _response.status_code < 300:
876
+ return pydantic_v1.parse_obj_as(Project, _response.json()) # type: ignore
877
+ try:
878
+ _response_json = _response.json()
879
+ except JSONDecodeError:
880
+ raise ApiError(status_code=_response.status_code, body=_response.text)
881
+ raise ApiError(status_code=_response.status_code, body=_response_json)
882
+
883
+ async def import_tasks(
884
+ self,
885
+ id: int,
886
+ *,
887
+ request: typing.Sequence[typing.Dict[str, typing.Any]],
888
+ commit_to_project: typing.Optional[bool] = None,
889
+ return_task_ids: typing.Optional[bool] = None,
890
+ preannotated_from_fields: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
891
+ request_options: typing.Optional[RequestOptions] = None,
892
+ ) -> ProjectsImportTasksResponse:
893
+ """
894
+ Use this API endpoint to import labeling tasks in bulk. Note that each POST request is limited at 250K tasks and 200 MB.
895
+ 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).
896
+
897
+ <Note>
898
+ Imported data is verified against a project *label_config* and must include all variables that were used in the *label_config*.
899
+
900
+ For example, if the label configuration has a _$text_ variable, then each item in a data object must include a `text` field.
901
+ </Note>
902
+
903
+ There are three possible ways to import tasks with this endpoint:
904
+
905
+ #### 1\. **POST with data**
906
+
907
+ Send JSON tasks as POST data. Only JSON is supported for POSTing files directly.
908
+
909
+ Update this example to specify your authorization token and Label Studio instance host, then run the following from
910
+ the command line:
911
+
912
+ ```bash
913
+ curl -H 'Content-Type: application/json' -H 'Authorization: Token abc123' \
914
+ -X POST 'https://localhost:8080/api/projects/1/import' --data '[{"text": "Some text 1"}, {"text": "Some text 2"}]'
915
+ ```
916
+
917
+ #### 2\. **POST with files**
918
+
919
+ Send tasks as files. You can attach multiple files with different names.
920
+
921
+ - **JSON**: text files in JavaScript object notation format
922
+ - **CSV**: text files with tables in Comma Separated Values format
923
+ - **TSV**: text files with tables in Tab Separated Value format
924
+ - **TXT**: simple text files are similar to CSV with one column and no header, supported for projects with one source only
925
+
926
+ Update this example to specify your authorization token, Label Studio instance host, and file name and path,
927
+ then run the following from the command line:
928
+
929
+ ```bash
930
+ curl -H 'Authorization: Token abc123' \
931
+ -X POST 'https://localhost:8080/api/projects/1/import' -F ‘file=@path/to/my_file.csv’
932
+ ```
933
+
934
+ #### 3\. **POST with URL**
935
+
936
+ You can also provide a URL to a file with labeling tasks. Supported file formats are the same as in option 2.
937
+
938
+ ```bash
939
+ curl -H 'Content-Type: application/json' -H 'Authorization: Token abc123' \
940
+ -X POST 'https://localhost:8080/api/projects/1/import' \
941
+ --data '[{"url": "http://example.com/test1.csv"}, {"url": "http://example.com/test2.csv"}]'
942
+ ```
943
+
944
+ <br>
945
+
946
+ Parameters
947
+ ----------
948
+ id : int
949
+ A unique integer value identifying this project.
950
+
951
+ request : typing.Sequence[typing.Dict[str, typing.Any]]
952
+
953
+ commit_to_project : typing.Optional[bool]
954
+ Set to "true" to immediately commit tasks to the project.
955
+
956
+ return_task_ids : typing.Optional[bool]
957
+ Set to "true" to return task IDs in the response.
958
+
959
+ preannotated_from_fields : typing.Optional[typing.Union[str, typing.Sequence[str]]]
960
+ List of fields to preannotate from the task data. For example, if you provide a list of `{"text": "text", "prediction": "label"}` items in the request, the system will create a task with the `text` field and a prediction with the `label` field when `preannoted_from_fields=["prediction"]`.
961
+
962
+ request_options : typing.Optional[RequestOptions]
963
+ Request-specific configuration.
964
+
965
+ Returns
966
+ -------
967
+ ProjectsImportTasksResponse
968
+ Tasks successfully imported
969
+
970
+ Examples
971
+ --------
972
+ from label_studio_sdk.client import AsyncLabelStudio
973
+
974
+ client = AsyncLabelStudio(
975
+ api_key="YOUR_API_KEY",
976
+ )
977
+ await client.projects.import_tasks(
978
+ id=1,
979
+ request=[{}],
980
+ )
981
+ """
982
+ _response = await self._client_wrapper.httpx_client.request(
983
+ f"api/projects/{jsonable_encoder(id)}/import",
984
+ method="POST",
985
+ params={
986
+ "commit_to_project": commit_to_project,
987
+ "return_task_ids": return_task_ids,
988
+ "preannotated_from_fields": preannotated_from_fields,
989
+ },
990
+ json=request,
991
+ request_options=request_options,
992
+ omit=OMIT,
993
+ )
994
+ if 200 <= _response.status_code < 300:
995
+ return pydantic_v1.parse_obj_as(ProjectsImportTasksResponse, _response.json()) # type: ignore
996
+ if _response.status_code == 400:
997
+ raise BadRequestError(pydantic_v1.parse_obj_as(str, _response.json())) # type: ignore
998
+ try:
999
+ _response_json = _response.json()
1000
+ except JSONDecodeError:
1001
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1002
+ raise ApiError(status_code=_response.status_code, body=_response_json)
1003
+
1004
+ async def validate_config(
1005
+ self, id: int, *, request: ProjectLabelConfig, request_options: typing.Optional[RequestOptions] = None
1006
+ ) -> ProjectLabelConfig:
1007
+ """
1008
+ Determine whether the label configuration for a specific project is valid. For more information about setting up labeling configs, see [Configure labeling interface](https://labelstud.io/guide/setup) and our [Tags reference](https://labelstud.io/tags/).
1009
+
1010
+ 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).
1011
+
1012
+ Parameters
1013
+ ----------
1014
+ id : int
1015
+ A unique integer value identifying this project.
1016
+
1017
+ request : ProjectLabelConfig
1018
+
1019
+ request_options : typing.Optional[RequestOptions]
1020
+ Request-specific configuration.
1021
+
1022
+ Returns
1023
+ -------
1024
+ ProjectLabelConfig
1025
+
1026
+
1027
+ Examples
1028
+ --------
1029
+ from label_studio_sdk import ProjectLabelConfig
1030
+ from label_studio_sdk.client import AsyncLabelStudio
1031
+
1032
+ client = AsyncLabelStudio(
1033
+ api_key="YOUR_API_KEY",
1034
+ )
1035
+ await client.projects.validate_config(
1036
+ id=1,
1037
+ request=ProjectLabelConfig(
1038
+ label_config="label_config",
1039
+ ),
1040
+ )
1041
+ """
1042
+ _response = await self._client_wrapper.httpx_client.request(
1043
+ f"api/projects/{jsonable_encoder(id)}/validate/",
1044
+ method="POST",
1045
+ json=request,
1046
+ request_options=request_options,
1047
+ omit=OMIT,
1048
+ )
1049
+ if 200 <= _response.status_code < 300:
1050
+ return pydantic_v1.parse_obj_as(ProjectLabelConfig, _response.json()) # type: ignore
1051
+ try:
1052
+ _response_json = _response.json()
1053
+ except JSONDecodeError:
1054
+ raise ApiError(status_code=_response.status_code, body=_response.text)
1055
+ raise ApiError(status_code=_response.status_code, body=_response_json)