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,981 @@
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 ..errors.internal_server_error import InternalServerError
12
+ from ..types.ml_backend import MlBackend
13
+ from .types.ml_create_request_auth_method import MlCreateRequestAuthMethod
14
+ from .types.ml_create_response import MlCreateResponse
15
+ from .types.ml_update_request_auth_method import MlUpdateRequestAuthMethod
16
+ from .types.ml_update_response import MlUpdateResponse
17
+
18
+ # this is used as the default value for optional parameters
19
+ OMIT = typing.cast(typing.Any, ...)
20
+
21
+
22
+ class MlClient:
23
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
24
+ self._client_wrapper = client_wrapper
25
+
26
+ def list(
27
+ self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
28
+ ) -> typing.List[MlBackend]:
29
+ """
30
+ List all configured Machine Learning (ML) backends for a specific project by ID. For more information about ML backends, see [Machine learning integration](https://labelstud.io/guide/ml).
31
+
32
+ You will need to provide 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](../projects/list).
33
+
34
+ Parameters
35
+ ----------
36
+ project : typing.Optional[int]
37
+ Project ID
38
+
39
+ request_options : typing.Optional[RequestOptions]
40
+ Request-specific configuration.
41
+
42
+ Returns
43
+ -------
44
+ typing.List[MlBackend]
45
+
46
+
47
+ Examples
48
+ --------
49
+ from label_studio_sdk.client import LabelStudio
50
+
51
+ client = LabelStudio(
52
+ api_key="YOUR_API_KEY",
53
+ )
54
+ client.ml.list()
55
+ """
56
+ _response = self._client_wrapper.httpx_client.request(
57
+ "api/ml/", method="GET", params={"project": project}, request_options=request_options
58
+ )
59
+ if 200 <= _response.status_code < 300:
60
+ return pydantic_v1.parse_obj_as(typing.List[MlBackend], _response.json()) # type: ignore
61
+ try:
62
+ _response_json = _response.json()
63
+ except JSONDecodeError:
64
+ raise ApiError(status_code=_response.status_code, body=_response.text)
65
+ raise ApiError(status_code=_response.status_code, body=_response_json)
66
+
67
+ def create(
68
+ self,
69
+ *,
70
+ url: typing.Optional[str] = OMIT,
71
+ project: typing.Optional[int] = OMIT,
72
+ is_interactive: typing.Optional[bool] = OMIT,
73
+ title: typing.Optional[str] = OMIT,
74
+ description: typing.Optional[str] = OMIT,
75
+ auth_method: typing.Optional[MlCreateRequestAuthMethod] = OMIT,
76
+ basic_auth_user: typing.Optional[str] = OMIT,
77
+ basic_auth_pass: typing.Optional[str] = OMIT,
78
+ extra_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
79
+ timeout: typing.Optional[int] = OMIT,
80
+ request_options: typing.Optional[RequestOptions] = None,
81
+ ) -> MlCreateResponse:
82
+ """
83
+ Add an ML backend to a project. For more information about what you need to configure when adding an ML backend, see [Connect the model to Label studio](https://labelstud.io/guide/ml#Connect-the-model-to-Label-Studio).
84
+
85
+ <Note>If you are using Docker Compose, you may need to adjust your ML backend URL. See [localhost and Docker containers](https://labelstud.io/guide/ml#localhost-and-Docker-containers).</Note>
86
+
87
+ <Note>If you are using files that are located in the cloud, local storage, or uploaded to Label Studio, you must configure your environment variables to allow the ML backend to interact with those files. See [Allow the ML backend to access Label Studio](https://labelstud.io/guide/ml#Allow-the-ML-backend-to-access-Label-Studio-data).</Note>
88
+
89
+ Parameters
90
+ ----------
91
+ url : typing.Optional[str]
92
+ ML backend URL
93
+
94
+ project : typing.Optional[int]
95
+ Project ID
96
+
97
+ is_interactive : typing.Optional[bool]
98
+ Is interactive
99
+
100
+ title : typing.Optional[str]
101
+ Title
102
+
103
+ description : typing.Optional[str]
104
+ Description
105
+
106
+ auth_method : typing.Optional[MlCreateRequestAuthMethod]
107
+ Auth method
108
+
109
+ basic_auth_user : typing.Optional[str]
110
+ Basic auth user
111
+
112
+ basic_auth_pass : typing.Optional[str]
113
+ Basic auth password
114
+
115
+ extra_params : typing.Optional[typing.Dict[str, typing.Any]]
116
+ Extra parameters
117
+
118
+ timeout : typing.Optional[int]
119
+ Response model timeout
120
+
121
+ request_options : typing.Optional[RequestOptions]
122
+ Request-specific configuration.
123
+
124
+ Returns
125
+ -------
126
+ MlCreateResponse
127
+
128
+
129
+ Examples
130
+ --------
131
+ from label_studio_sdk.client import LabelStudio
132
+
133
+ client = LabelStudio(
134
+ api_key="YOUR_API_KEY",
135
+ )
136
+ client.ml.create()
137
+ """
138
+ _response = self._client_wrapper.httpx_client.request(
139
+ "api/ml/",
140
+ method="POST",
141
+ json={
142
+ "url": url,
143
+ "project": project,
144
+ "is_interactive": is_interactive,
145
+ "title": title,
146
+ "description": description,
147
+ "auth_method": auth_method,
148
+ "basic_auth_user": basic_auth_user,
149
+ "basic_auth_pass": basic_auth_pass,
150
+ "extra_params": extra_params,
151
+ "timeout": timeout,
152
+ },
153
+ request_options=request_options,
154
+ omit=OMIT,
155
+ )
156
+ if 200 <= _response.status_code < 300:
157
+ return pydantic_v1.parse_obj_as(MlCreateResponse, _response.json()) # type: ignore
158
+ try:
159
+ _response_json = _response.json()
160
+ except JSONDecodeError:
161
+ raise ApiError(status_code=_response.status_code, body=_response.text)
162
+ raise ApiError(status_code=_response.status_code, body=_response_json)
163
+
164
+ def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> MlBackend:
165
+ """
166
+ Get details about a specific ML backend. You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
167
+
168
+ For more information, see [Machine learning integration](https://labelstud.io/guide/ml).
169
+
170
+ Parameters
171
+ ----------
172
+ id : int
173
+ A unique integer value identifying this ml backend.
174
+
175
+ request_options : typing.Optional[RequestOptions]
176
+ Request-specific configuration.
177
+
178
+ Returns
179
+ -------
180
+ MlBackend
181
+
182
+
183
+ Examples
184
+ --------
185
+ from label_studio_sdk.client import LabelStudio
186
+
187
+ client = LabelStudio(
188
+ api_key="YOUR_API_KEY",
189
+ )
190
+ client.ml.get(
191
+ id=1,
192
+ )
193
+ """
194
+ _response = self._client_wrapper.httpx_client.request(
195
+ f"api/ml/{jsonable_encoder(id)}", method="GET", request_options=request_options
196
+ )
197
+ if 200 <= _response.status_code < 300:
198
+ return pydantic_v1.parse_obj_as(MlBackend, _response.json()) # type: ignore
199
+ try:
200
+ _response_json = _response.json()
201
+ except JSONDecodeError:
202
+ raise ApiError(status_code=_response.status_code, body=_response.text)
203
+ raise ApiError(status_code=_response.status_code, body=_response_json)
204
+
205
+ def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
206
+ """
207
+ Remove an existing ML backend connection. You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
208
+
209
+ For more information, see [Machine learning integration](https://labelstud.io/guide/ml).
210
+
211
+ Parameters
212
+ ----------
213
+ id : int
214
+ A unique integer value identifying this ml backend.
215
+
216
+ request_options : typing.Optional[RequestOptions]
217
+ Request-specific configuration.
218
+
219
+ Returns
220
+ -------
221
+ None
222
+
223
+ Examples
224
+ --------
225
+ from label_studio_sdk.client import LabelStudio
226
+
227
+ client = LabelStudio(
228
+ api_key="YOUR_API_KEY",
229
+ )
230
+ client.ml.delete(
231
+ id=1,
232
+ )
233
+ """
234
+ _response = self._client_wrapper.httpx_client.request(
235
+ f"api/ml/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
236
+ )
237
+ if 200 <= _response.status_code < 300:
238
+ return
239
+ try:
240
+ _response_json = _response.json()
241
+ except JSONDecodeError:
242
+ raise ApiError(status_code=_response.status_code, body=_response.text)
243
+ raise ApiError(status_code=_response.status_code, body=_response_json)
244
+
245
+ def update(
246
+ self,
247
+ id: int,
248
+ *,
249
+ url: typing.Optional[str] = OMIT,
250
+ project: typing.Optional[int] = OMIT,
251
+ is_interactive: typing.Optional[bool] = OMIT,
252
+ title: typing.Optional[str] = OMIT,
253
+ description: typing.Optional[str] = OMIT,
254
+ auth_method: typing.Optional[MlUpdateRequestAuthMethod] = OMIT,
255
+ basic_auth_user: typing.Optional[str] = OMIT,
256
+ basic_auth_pass: typing.Optional[str] = OMIT,
257
+ extra_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
258
+ timeout: typing.Optional[int] = OMIT,
259
+ request_options: typing.Optional[RequestOptions] = None,
260
+ ) -> MlUpdateResponse:
261
+ """
262
+ Update the ML backend parameters. You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
263
+
264
+ For more information, see [Machine learning integration](https://labelstud.io/guide/ml).
265
+
266
+ Parameters
267
+ ----------
268
+ id : int
269
+ A unique integer value identifying this ml backend.
270
+
271
+ url : typing.Optional[str]
272
+ ML backend URL
273
+
274
+ project : typing.Optional[int]
275
+ Project ID
276
+
277
+ is_interactive : typing.Optional[bool]
278
+ Is interactive
279
+
280
+ title : typing.Optional[str]
281
+ Title
282
+
283
+ description : typing.Optional[str]
284
+ Description
285
+
286
+ auth_method : typing.Optional[MlUpdateRequestAuthMethod]
287
+ Auth method
288
+
289
+ basic_auth_user : typing.Optional[str]
290
+ Basic auth user
291
+
292
+ basic_auth_pass : typing.Optional[str]
293
+ Basic auth password
294
+
295
+ extra_params : typing.Optional[typing.Dict[str, typing.Any]]
296
+ Extra parameters
297
+
298
+ timeout : typing.Optional[int]
299
+ Response model timeout
300
+
301
+ request_options : typing.Optional[RequestOptions]
302
+ Request-specific configuration.
303
+
304
+ Returns
305
+ -------
306
+ MlUpdateResponse
307
+
308
+
309
+ Examples
310
+ --------
311
+ from label_studio_sdk.client import LabelStudio
312
+
313
+ client = LabelStudio(
314
+ api_key="YOUR_API_KEY",
315
+ )
316
+ client.ml.update(
317
+ id=1,
318
+ )
319
+ """
320
+ _response = self._client_wrapper.httpx_client.request(
321
+ f"api/ml/{jsonable_encoder(id)}",
322
+ method="PATCH",
323
+ json={
324
+ "url": url,
325
+ "project": project,
326
+ "is_interactive": is_interactive,
327
+ "title": title,
328
+ "description": description,
329
+ "auth_method": auth_method,
330
+ "basic_auth_user": basic_auth_user,
331
+ "basic_auth_pass": basic_auth_pass,
332
+ "extra_params": extra_params,
333
+ "timeout": timeout,
334
+ },
335
+ request_options=request_options,
336
+ omit=OMIT,
337
+ )
338
+ if 200 <= _response.status_code < 300:
339
+ return pydantic_v1.parse_obj_as(MlUpdateResponse, _response.json()) # type: ignore
340
+ try:
341
+ _response_json = _response.json()
342
+ except JSONDecodeError:
343
+ raise ApiError(status_code=_response.status_code, body=_response.text)
344
+ raise ApiError(status_code=_response.status_code, body=_response_json)
345
+
346
+ def predict_interactive(
347
+ self,
348
+ id: int,
349
+ *,
350
+ task: int,
351
+ context: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
352
+ request_options: typing.Optional[RequestOptions] = None,
353
+ ) -> None:
354
+ """
355
+ Enable interactive pre-annotations for a specific task.
356
+
357
+ ML-assisted labeling with interactive pre-annotations works with image segmentation and object detection tasks using rectangles, ellipses, polygons, brush masks, and keypoints, as well as with HTML and text named entity recognition tasks. Your ML backend must support the type of labeling that you’re performing, recognize the input that you create, and be able to respond with the relevant output for a prediction. For more information, see [Interactive pre-annotations](https://labelstud.io/guide/ml.html#Interactive-pre-annotations).
358
+
359
+ Before you can use interactive annotations, it must be enabled for you ML backend connection (`"is_interactive": true`).
360
+
361
+ You will need the task ID and the ML backend connection ID. The task ID is available from the Label Studio URL when viewing the task, or you can retrieve it programmatically with [Get task list](../tasks/list). The ML backend connection ID is available via [List ML backends](list).
362
+
363
+ Parameters
364
+ ----------
365
+ id : int
366
+ A unique integer value identifying this ML backend.
367
+
368
+ task : int
369
+ ID of task to annotate
370
+
371
+ context : typing.Optional[typing.Dict[str, typing.Any]]
372
+ Context for ML model
373
+
374
+ request_options : typing.Optional[RequestOptions]
375
+ Request-specific configuration.
376
+
377
+ Returns
378
+ -------
379
+ None
380
+
381
+ Examples
382
+ --------
383
+ from label_studio_sdk.client import LabelStudio
384
+
385
+ client = LabelStudio(
386
+ api_key="YOUR_API_KEY",
387
+ )
388
+ client.ml.predict_interactive(
389
+ id=1,
390
+ task=1,
391
+ )
392
+ """
393
+ _response = self._client_wrapper.httpx_client.request(
394
+ f"api/ml/{jsonable_encoder(id)}/interactive-annotating",
395
+ method="POST",
396
+ json={"task": task, "context": context},
397
+ request_options=request_options,
398
+ omit=OMIT,
399
+ )
400
+ if 200 <= _response.status_code < 300:
401
+ return
402
+ try:
403
+ _response_json = _response.json()
404
+ except JSONDecodeError:
405
+ raise ApiError(status_code=_response.status_code, body=_response.text)
406
+ raise ApiError(status_code=_response.status_code, body=_response_json)
407
+
408
+ def train(
409
+ self,
410
+ id: int,
411
+ *,
412
+ use_ground_truth: typing.Optional[bool] = OMIT,
413
+ request_options: typing.Optional[RequestOptions] = None,
414
+ ) -> None:
415
+ """
416
+ After you connect a model to Label Studio as a machine learning backend and annotate at least one task, you can start training the model. Training logs appear in stdout and the console.
417
+
418
+ For more information, see [Model training](https://labelstud.io/guide/ml.html#Model-training).
419
+
420
+ You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
421
+
422
+ Parameters
423
+ ----------
424
+ id : int
425
+ A unique integer value identifying this ML backend.
426
+
427
+ use_ground_truth : typing.Optional[bool]
428
+ Whether to include ground truth annotations in training
429
+
430
+ request_options : typing.Optional[RequestOptions]
431
+ Request-specific configuration.
432
+
433
+ Returns
434
+ -------
435
+ None
436
+
437
+ Examples
438
+ --------
439
+ from label_studio_sdk.client import LabelStudio
440
+
441
+ client = LabelStudio(
442
+ api_key="YOUR_API_KEY",
443
+ )
444
+ client.ml.train(
445
+ id=1,
446
+ )
447
+ """
448
+ _response = self._client_wrapper.httpx_client.request(
449
+ f"api/ml/{jsonable_encoder(id)}/train",
450
+ method="POST",
451
+ json={"use_ground_truth": use_ground_truth},
452
+ request_options=request_options,
453
+ omit=OMIT,
454
+ )
455
+ if 200 <= _response.status_code < 300:
456
+ return
457
+ if _response.status_code == 500:
458
+ raise InternalServerError(pydantic_v1.parse_obj_as(str, _response.json())) # type: ignore
459
+ try:
460
+ _response_json = _response.json()
461
+ except JSONDecodeError:
462
+ raise ApiError(status_code=_response.status_code, body=_response.text)
463
+ raise ApiError(status_code=_response.status_code, body=_response_json)
464
+
465
+ def list_model_versions(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
466
+ """
467
+ Get available versions of the model. You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
468
+
469
+ Parameters
470
+ ----------
471
+ id : str
472
+
473
+ request_options : typing.Optional[RequestOptions]
474
+ Request-specific configuration.
475
+
476
+ Returns
477
+ -------
478
+ None
479
+
480
+ Examples
481
+ --------
482
+ from label_studio_sdk.client import LabelStudio
483
+
484
+ client = LabelStudio(
485
+ api_key="YOUR_API_KEY",
486
+ )
487
+ client.ml.list_model_versions(
488
+ id="id",
489
+ )
490
+ """
491
+ _response = self._client_wrapper.httpx_client.request(
492
+ f"api/ml/{jsonable_encoder(id)}/versions", method="GET", request_options=request_options
493
+ )
494
+ if 200 <= _response.status_code < 300:
495
+ return
496
+ try:
497
+ _response_json = _response.json()
498
+ except JSONDecodeError:
499
+ raise ApiError(status_code=_response.status_code, body=_response.text)
500
+ raise ApiError(status_code=_response.status_code, body=_response_json)
501
+
502
+
503
+ class AsyncMlClient:
504
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
505
+ self._client_wrapper = client_wrapper
506
+
507
+ async def list(
508
+ self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
509
+ ) -> typing.List[MlBackend]:
510
+ """
511
+ List all configured Machine Learning (ML) backends for a specific project by ID. For more information about ML backends, see [Machine learning integration](https://labelstud.io/guide/ml).
512
+
513
+ You will need to provide 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](../projects/list).
514
+
515
+ Parameters
516
+ ----------
517
+ project : typing.Optional[int]
518
+ Project ID
519
+
520
+ request_options : typing.Optional[RequestOptions]
521
+ Request-specific configuration.
522
+
523
+ Returns
524
+ -------
525
+ typing.List[MlBackend]
526
+
527
+
528
+ Examples
529
+ --------
530
+ from label_studio_sdk.client import AsyncLabelStudio
531
+
532
+ client = AsyncLabelStudio(
533
+ api_key="YOUR_API_KEY",
534
+ )
535
+ await client.ml.list()
536
+ """
537
+ _response = await self._client_wrapper.httpx_client.request(
538
+ "api/ml/", method="GET", params={"project": project}, request_options=request_options
539
+ )
540
+ if 200 <= _response.status_code < 300:
541
+ return pydantic_v1.parse_obj_as(typing.List[MlBackend], _response.json()) # type: ignore
542
+ try:
543
+ _response_json = _response.json()
544
+ except JSONDecodeError:
545
+ raise ApiError(status_code=_response.status_code, body=_response.text)
546
+ raise ApiError(status_code=_response.status_code, body=_response_json)
547
+
548
+ async def create(
549
+ self,
550
+ *,
551
+ url: typing.Optional[str] = OMIT,
552
+ project: typing.Optional[int] = OMIT,
553
+ is_interactive: typing.Optional[bool] = OMIT,
554
+ title: typing.Optional[str] = OMIT,
555
+ description: typing.Optional[str] = OMIT,
556
+ auth_method: typing.Optional[MlCreateRequestAuthMethod] = OMIT,
557
+ basic_auth_user: typing.Optional[str] = OMIT,
558
+ basic_auth_pass: typing.Optional[str] = OMIT,
559
+ extra_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
560
+ timeout: typing.Optional[int] = OMIT,
561
+ request_options: typing.Optional[RequestOptions] = None,
562
+ ) -> MlCreateResponse:
563
+ """
564
+ Add an ML backend to a project. For more information about what you need to configure when adding an ML backend, see [Connect the model to Label studio](https://labelstud.io/guide/ml#Connect-the-model-to-Label-Studio).
565
+
566
+ <Note>If you are using Docker Compose, you may need to adjust your ML backend URL. See [localhost and Docker containers](https://labelstud.io/guide/ml#localhost-and-Docker-containers).</Note>
567
+
568
+ <Note>If you are using files that are located in the cloud, local storage, or uploaded to Label Studio, you must configure your environment variables to allow the ML backend to interact with those files. See [Allow the ML backend to access Label Studio](https://labelstud.io/guide/ml#Allow-the-ML-backend-to-access-Label-Studio-data).</Note>
569
+
570
+ Parameters
571
+ ----------
572
+ url : typing.Optional[str]
573
+ ML backend URL
574
+
575
+ project : typing.Optional[int]
576
+ Project ID
577
+
578
+ is_interactive : typing.Optional[bool]
579
+ Is interactive
580
+
581
+ title : typing.Optional[str]
582
+ Title
583
+
584
+ description : typing.Optional[str]
585
+ Description
586
+
587
+ auth_method : typing.Optional[MlCreateRequestAuthMethod]
588
+ Auth method
589
+
590
+ basic_auth_user : typing.Optional[str]
591
+ Basic auth user
592
+
593
+ basic_auth_pass : typing.Optional[str]
594
+ Basic auth password
595
+
596
+ extra_params : typing.Optional[typing.Dict[str, typing.Any]]
597
+ Extra parameters
598
+
599
+ timeout : typing.Optional[int]
600
+ Response model timeout
601
+
602
+ request_options : typing.Optional[RequestOptions]
603
+ Request-specific configuration.
604
+
605
+ Returns
606
+ -------
607
+ MlCreateResponse
608
+
609
+
610
+ Examples
611
+ --------
612
+ from label_studio_sdk.client import AsyncLabelStudio
613
+
614
+ client = AsyncLabelStudio(
615
+ api_key="YOUR_API_KEY",
616
+ )
617
+ await client.ml.create()
618
+ """
619
+ _response = await self._client_wrapper.httpx_client.request(
620
+ "api/ml/",
621
+ method="POST",
622
+ json={
623
+ "url": url,
624
+ "project": project,
625
+ "is_interactive": is_interactive,
626
+ "title": title,
627
+ "description": description,
628
+ "auth_method": auth_method,
629
+ "basic_auth_user": basic_auth_user,
630
+ "basic_auth_pass": basic_auth_pass,
631
+ "extra_params": extra_params,
632
+ "timeout": timeout,
633
+ },
634
+ request_options=request_options,
635
+ omit=OMIT,
636
+ )
637
+ if 200 <= _response.status_code < 300:
638
+ return pydantic_v1.parse_obj_as(MlCreateResponse, _response.json()) # type: ignore
639
+ try:
640
+ _response_json = _response.json()
641
+ except JSONDecodeError:
642
+ raise ApiError(status_code=_response.status_code, body=_response.text)
643
+ raise ApiError(status_code=_response.status_code, body=_response_json)
644
+
645
+ async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> MlBackend:
646
+ """
647
+ Get details about a specific ML backend. You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
648
+
649
+ For more information, see [Machine learning integration](https://labelstud.io/guide/ml).
650
+
651
+ Parameters
652
+ ----------
653
+ id : int
654
+ A unique integer value identifying this ml backend.
655
+
656
+ request_options : typing.Optional[RequestOptions]
657
+ Request-specific configuration.
658
+
659
+ Returns
660
+ -------
661
+ MlBackend
662
+
663
+
664
+ Examples
665
+ --------
666
+ from label_studio_sdk.client import AsyncLabelStudio
667
+
668
+ client = AsyncLabelStudio(
669
+ api_key="YOUR_API_KEY",
670
+ )
671
+ await client.ml.get(
672
+ id=1,
673
+ )
674
+ """
675
+ _response = await self._client_wrapper.httpx_client.request(
676
+ f"api/ml/{jsonable_encoder(id)}", method="GET", request_options=request_options
677
+ )
678
+ if 200 <= _response.status_code < 300:
679
+ return pydantic_v1.parse_obj_as(MlBackend, _response.json()) # type: ignore
680
+ try:
681
+ _response_json = _response.json()
682
+ except JSONDecodeError:
683
+ raise ApiError(status_code=_response.status_code, body=_response.text)
684
+ raise ApiError(status_code=_response.status_code, body=_response_json)
685
+
686
+ async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
687
+ """
688
+ Remove an existing ML backend connection. You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
689
+
690
+ For more information, see [Machine learning integration](https://labelstud.io/guide/ml).
691
+
692
+ Parameters
693
+ ----------
694
+ id : int
695
+ A unique integer value identifying this ml backend.
696
+
697
+ request_options : typing.Optional[RequestOptions]
698
+ Request-specific configuration.
699
+
700
+ Returns
701
+ -------
702
+ None
703
+
704
+ Examples
705
+ --------
706
+ from label_studio_sdk.client import AsyncLabelStudio
707
+
708
+ client = AsyncLabelStudio(
709
+ api_key="YOUR_API_KEY",
710
+ )
711
+ await client.ml.delete(
712
+ id=1,
713
+ )
714
+ """
715
+ _response = await self._client_wrapper.httpx_client.request(
716
+ f"api/ml/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
717
+ )
718
+ if 200 <= _response.status_code < 300:
719
+ return
720
+ try:
721
+ _response_json = _response.json()
722
+ except JSONDecodeError:
723
+ raise ApiError(status_code=_response.status_code, body=_response.text)
724
+ raise ApiError(status_code=_response.status_code, body=_response_json)
725
+
726
+ async def update(
727
+ self,
728
+ id: int,
729
+ *,
730
+ url: typing.Optional[str] = OMIT,
731
+ project: typing.Optional[int] = OMIT,
732
+ is_interactive: typing.Optional[bool] = OMIT,
733
+ title: typing.Optional[str] = OMIT,
734
+ description: typing.Optional[str] = OMIT,
735
+ auth_method: typing.Optional[MlUpdateRequestAuthMethod] = OMIT,
736
+ basic_auth_user: typing.Optional[str] = OMIT,
737
+ basic_auth_pass: typing.Optional[str] = OMIT,
738
+ extra_params: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
739
+ timeout: typing.Optional[int] = OMIT,
740
+ request_options: typing.Optional[RequestOptions] = None,
741
+ ) -> MlUpdateResponse:
742
+ """
743
+ Update the ML backend parameters. You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
744
+
745
+ For more information, see [Machine learning integration](https://labelstud.io/guide/ml).
746
+
747
+ Parameters
748
+ ----------
749
+ id : int
750
+ A unique integer value identifying this ml backend.
751
+
752
+ url : typing.Optional[str]
753
+ ML backend URL
754
+
755
+ project : typing.Optional[int]
756
+ Project ID
757
+
758
+ is_interactive : typing.Optional[bool]
759
+ Is interactive
760
+
761
+ title : typing.Optional[str]
762
+ Title
763
+
764
+ description : typing.Optional[str]
765
+ Description
766
+
767
+ auth_method : typing.Optional[MlUpdateRequestAuthMethod]
768
+ Auth method
769
+
770
+ basic_auth_user : typing.Optional[str]
771
+ Basic auth user
772
+
773
+ basic_auth_pass : typing.Optional[str]
774
+ Basic auth password
775
+
776
+ extra_params : typing.Optional[typing.Dict[str, typing.Any]]
777
+ Extra parameters
778
+
779
+ timeout : typing.Optional[int]
780
+ Response model timeout
781
+
782
+ request_options : typing.Optional[RequestOptions]
783
+ Request-specific configuration.
784
+
785
+ Returns
786
+ -------
787
+ MlUpdateResponse
788
+
789
+
790
+ Examples
791
+ --------
792
+ from label_studio_sdk.client import AsyncLabelStudio
793
+
794
+ client = AsyncLabelStudio(
795
+ api_key="YOUR_API_KEY",
796
+ )
797
+ await client.ml.update(
798
+ id=1,
799
+ )
800
+ """
801
+ _response = await self._client_wrapper.httpx_client.request(
802
+ f"api/ml/{jsonable_encoder(id)}",
803
+ method="PATCH",
804
+ json={
805
+ "url": url,
806
+ "project": project,
807
+ "is_interactive": is_interactive,
808
+ "title": title,
809
+ "description": description,
810
+ "auth_method": auth_method,
811
+ "basic_auth_user": basic_auth_user,
812
+ "basic_auth_pass": basic_auth_pass,
813
+ "extra_params": extra_params,
814
+ "timeout": timeout,
815
+ },
816
+ request_options=request_options,
817
+ omit=OMIT,
818
+ )
819
+ if 200 <= _response.status_code < 300:
820
+ return pydantic_v1.parse_obj_as(MlUpdateResponse, _response.json()) # type: ignore
821
+ try:
822
+ _response_json = _response.json()
823
+ except JSONDecodeError:
824
+ raise ApiError(status_code=_response.status_code, body=_response.text)
825
+ raise ApiError(status_code=_response.status_code, body=_response_json)
826
+
827
+ async def predict_interactive(
828
+ self,
829
+ id: int,
830
+ *,
831
+ task: int,
832
+ context: typing.Optional[typing.Dict[str, typing.Any]] = OMIT,
833
+ request_options: typing.Optional[RequestOptions] = None,
834
+ ) -> None:
835
+ """
836
+ Enable interactive pre-annotations for a specific task.
837
+
838
+ ML-assisted labeling with interactive pre-annotations works with image segmentation and object detection tasks using rectangles, ellipses, polygons, brush masks, and keypoints, as well as with HTML and text named entity recognition tasks. Your ML backend must support the type of labeling that you’re performing, recognize the input that you create, and be able to respond with the relevant output for a prediction. For more information, see [Interactive pre-annotations](https://labelstud.io/guide/ml.html#Interactive-pre-annotations).
839
+
840
+ Before you can use interactive annotations, it must be enabled for you ML backend connection (`"is_interactive": true`).
841
+
842
+ You will need the task ID and the ML backend connection ID. The task ID is available from the Label Studio URL when viewing the task, or you can retrieve it programmatically with [Get task list](../tasks/list). The ML backend connection ID is available via [List ML backends](list).
843
+
844
+ Parameters
845
+ ----------
846
+ id : int
847
+ A unique integer value identifying this ML backend.
848
+
849
+ task : int
850
+ ID of task to annotate
851
+
852
+ context : typing.Optional[typing.Dict[str, typing.Any]]
853
+ Context for ML model
854
+
855
+ request_options : typing.Optional[RequestOptions]
856
+ Request-specific configuration.
857
+
858
+ Returns
859
+ -------
860
+ None
861
+
862
+ Examples
863
+ --------
864
+ from label_studio_sdk.client import AsyncLabelStudio
865
+
866
+ client = AsyncLabelStudio(
867
+ api_key="YOUR_API_KEY",
868
+ )
869
+ await client.ml.predict_interactive(
870
+ id=1,
871
+ task=1,
872
+ )
873
+ """
874
+ _response = await self._client_wrapper.httpx_client.request(
875
+ f"api/ml/{jsonable_encoder(id)}/interactive-annotating",
876
+ method="POST",
877
+ json={"task": task, "context": context},
878
+ request_options=request_options,
879
+ omit=OMIT,
880
+ )
881
+ if 200 <= _response.status_code < 300:
882
+ return
883
+ try:
884
+ _response_json = _response.json()
885
+ except JSONDecodeError:
886
+ raise ApiError(status_code=_response.status_code, body=_response.text)
887
+ raise ApiError(status_code=_response.status_code, body=_response_json)
888
+
889
+ async def train(
890
+ self,
891
+ id: int,
892
+ *,
893
+ use_ground_truth: typing.Optional[bool] = OMIT,
894
+ request_options: typing.Optional[RequestOptions] = None,
895
+ ) -> None:
896
+ """
897
+ After you connect a model to Label Studio as a machine learning backend and annotate at least one task, you can start training the model. Training logs appear in stdout and the console.
898
+
899
+ For more information, see [Model training](https://labelstud.io/guide/ml.html#Model-training).
900
+
901
+ You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
902
+
903
+ Parameters
904
+ ----------
905
+ id : int
906
+ A unique integer value identifying this ML backend.
907
+
908
+ use_ground_truth : typing.Optional[bool]
909
+ Whether to include ground truth annotations in training
910
+
911
+ request_options : typing.Optional[RequestOptions]
912
+ Request-specific configuration.
913
+
914
+ Returns
915
+ -------
916
+ None
917
+
918
+ Examples
919
+ --------
920
+ from label_studio_sdk.client import AsyncLabelStudio
921
+
922
+ client = AsyncLabelStudio(
923
+ api_key="YOUR_API_KEY",
924
+ )
925
+ await client.ml.train(
926
+ id=1,
927
+ )
928
+ """
929
+ _response = await self._client_wrapper.httpx_client.request(
930
+ f"api/ml/{jsonable_encoder(id)}/train",
931
+ method="POST",
932
+ json={"use_ground_truth": use_ground_truth},
933
+ request_options=request_options,
934
+ omit=OMIT,
935
+ )
936
+ if 200 <= _response.status_code < 300:
937
+ return
938
+ if _response.status_code == 500:
939
+ raise InternalServerError(pydantic_v1.parse_obj_as(str, _response.json())) # type: ignore
940
+ try:
941
+ _response_json = _response.json()
942
+ except JSONDecodeError:
943
+ raise ApiError(status_code=_response.status_code, body=_response.text)
944
+ raise ApiError(status_code=_response.status_code, body=_response_json)
945
+
946
+ async def list_model_versions(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
947
+ """
948
+ Get available versions of the model. You will need to specify an ID for the backend connection. You can find this using [List ML backends](list).
949
+
950
+ Parameters
951
+ ----------
952
+ id : str
953
+
954
+ request_options : typing.Optional[RequestOptions]
955
+ Request-specific configuration.
956
+
957
+ Returns
958
+ -------
959
+ None
960
+
961
+ Examples
962
+ --------
963
+ from label_studio_sdk.client import AsyncLabelStudio
964
+
965
+ client = AsyncLabelStudio(
966
+ api_key="YOUR_API_KEY",
967
+ )
968
+ await client.ml.list_model_versions(
969
+ id="id",
970
+ )
971
+ """
972
+ _response = await self._client_wrapper.httpx_client.request(
973
+ f"api/ml/{jsonable_encoder(id)}/versions", method="GET", request_options=request_options
974
+ )
975
+ if 200 <= _response.status_code < 300:
976
+ return
977
+ try:
978
+ _response_json = _response.json()
979
+ except JSONDecodeError:
980
+ raise ApiError(status_code=_response.status_code, body=_response.text)
981
+ raise ApiError(status_code=_response.status_code, body=_response_json)