label-studio-sdk 1.0.8__py3-none-any.whl → 1.0.11__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 (218) hide show
  1. label_studio_sdk/__init__.py +37 -8
  2. label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +16 -4
  3. label_studio_sdk/_extensions/label_studio_tools/core/utils/json_schema.py +5 -0
  4. label_studio_sdk/_extensions/pager_ext.py +8 -0
  5. label_studio_sdk/actions/client.py +91 -40
  6. label_studio_sdk/actions/types/actions_create_request_filters.py +14 -24
  7. label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +16 -26
  8. label_studio_sdk/actions/types/actions_create_request_filters_items_item_value.py +3 -1
  9. label_studio_sdk/actions/types/actions_create_request_selected_items.py +1 -2
  10. label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +15 -25
  11. label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +15 -25
  12. label_studio_sdk/annotations/__init__.py +2 -2
  13. label_studio_sdk/annotations/client.py +278 -104
  14. label_studio_sdk/annotations/types/__init__.py +2 -1
  15. label_studio_sdk/annotations/types/annotations_create_bulk_request_selected_items.py +34 -0
  16. label_studio_sdk/annotations/types/annotations_create_bulk_response_item.py +11 -21
  17. label_studio_sdk/base_client.py +54 -27
  18. label_studio_sdk/client.py +1 -0
  19. label_studio_sdk/comments/client.py +190 -44
  20. label_studio_sdk/converter/converter.py +56 -13
  21. label_studio_sdk/converter/imports/yolo.py +1 -1
  22. label_studio_sdk/converter/utils.py +3 -2
  23. label_studio_sdk/core/__init__.py +21 -4
  24. label_studio_sdk/core/client_wrapper.py +37 -19
  25. label_studio_sdk/core/file.py +37 -8
  26. label_studio_sdk/core/http_client.py +52 -28
  27. label_studio_sdk/core/jsonable_encoder.py +33 -31
  28. label_studio_sdk/core/pagination.py +5 -4
  29. label_studio_sdk/core/pydantic_utilities.py +272 -4
  30. label_studio_sdk/core/query_encoder.py +38 -13
  31. label_studio_sdk/core/request_options.py +3 -0
  32. label_studio_sdk/core/serialization.py +272 -0
  33. label_studio_sdk/errors/__init__.py +3 -1
  34. label_studio_sdk/errors/bad_request_error.py +2 -3
  35. label_studio_sdk/errors/not_found_error.py +9 -0
  36. label_studio_sdk/errors/unauthorized_error.py +9 -0
  37. label_studio_sdk/export_storage/azure/client.py +228 -58
  38. label_studio_sdk/export_storage/azure/types/azure_create_response.py +19 -29
  39. label_studio_sdk/export_storage/azure/types/azure_update_response.py +19 -29
  40. label_studio_sdk/export_storage/client.py +48 -18
  41. label_studio_sdk/export_storage/gcs/client.py +228 -58
  42. label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +19 -29
  43. label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +19 -29
  44. label_studio_sdk/export_storage/local/client.py +222 -56
  45. label_studio_sdk/export_storage/local/types/local_create_response.py +17 -27
  46. label_studio_sdk/export_storage/local/types/local_update_response.py +17 -27
  47. label_studio_sdk/export_storage/redis/client.py +228 -58
  48. label_studio_sdk/export_storage/redis/types/redis_create_response.py +20 -30
  49. label_studio_sdk/export_storage/redis/types/redis_update_response.py +20 -30
  50. label_studio_sdk/export_storage/s3/client.py +228 -58
  51. label_studio_sdk/export_storage/s3/types/s3create_response.py +27 -35
  52. label_studio_sdk/export_storage/s3/types/s3update_response.py +27 -35
  53. label_studio_sdk/export_storage/s3s/client.py +187 -43
  54. label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +11 -21
  55. label_studio_sdk/files/client.py +172 -56
  56. label_studio_sdk/import_storage/azure/client.py +223 -53
  57. label_studio_sdk/import_storage/azure/types/azure_create_response.py +22 -32
  58. label_studio_sdk/import_storage/azure/types/azure_update_response.py +22 -32
  59. label_studio_sdk/import_storage/client.py +48 -18
  60. label_studio_sdk/import_storage/gcs/client.py +223 -53
  61. label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +22 -32
  62. label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +22 -32
  63. label_studio_sdk/import_storage/local/client.py +223 -53
  64. label_studio_sdk/import_storage/local/types/local_create_response.py +17 -27
  65. label_studio_sdk/import_storage/local/types/local_update_response.py +17 -27
  66. label_studio_sdk/import_storage/redis/client.py +223 -53
  67. label_studio_sdk/import_storage/redis/types/redis_create_response.py +20 -30
  68. label_studio_sdk/import_storage/redis/types/redis_update_response.py +20 -30
  69. label_studio_sdk/import_storage/s3/client.py +223 -53
  70. label_studio_sdk/import_storage/s3/types/s3create_response.py +31 -39
  71. label_studio_sdk/import_storage/s3/types/s3update_response.py +31 -39
  72. label_studio_sdk/import_storage/s3s/client.py +222 -52
  73. label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +11 -21
  74. label_studio_sdk/jwt_settings/__init__.py +2 -0
  75. label_studio_sdk/jwt_settings/client.py +259 -0
  76. label_studio_sdk/label_interface/control_tags.py +16 -3
  77. label_studio_sdk/label_interface/interface.py +80 -1
  78. label_studio_sdk/label_interface/object_tags.py +2 -2
  79. label_studio_sdk/ml/client.py +280 -78
  80. label_studio_sdk/ml/types/ml_create_response.py +21 -31
  81. label_studio_sdk/ml/types/ml_update_response.py +21 -31
  82. label_studio_sdk/model_providers/client.py +173 -56
  83. label_studio_sdk/predictions/client.py +247 -101
  84. label_studio_sdk/projects/__init__.py +5 -1
  85. label_studio_sdk/projects/client.py +313 -115
  86. label_studio_sdk/projects/client_ext.py +16 -0
  87. label_studio_sdk/projects/exports/__init__.py +3 -0
  88. label_studio_sdk/projects/exports/client.py +447 -296
  89. label_studio_sdk/projects/exports/client_ext.py +200 -0
  90. label_studio_sdk/projects/exports/types/__init__.py +6 -0
  91. label_studio_sdk/projects/exports/types/exports_convert_response.py +24 -0
  92. label_studio_sdk/projects/exports/types/exports_list_formats_response_item.py +44 -0
  93. label_studio_sdk/projects/pauses/__init__.py +2 -0
  94. label_studio_sdk/projects/pauses/client.py +704 -0
  95. label_studio_sdk/projects/types/projects_create_response.py +29 -34
  96. label_studio_sdk/projects/types/projects_import_tasks_response.py +19 -29
  97. label_studio_sdk/projects/types/projects_list_response.py +11 -21
  98. label_studio_sdk/projects/types/projects_update_response.py +34 -34
  99. label_studio_sdk/prompts/client.py +309 -92
  100. label_studio_sdk/prompts/indicators/client.py +67 -23
  101. label_studio_sdk/prompts/runs/client.py +95 -40
  102. label_studio_sdk/prompts/types/prompts_batch_failed_predictions_request_failed_predictions_item.py +14 -24
  103. label_studio_sdk/prompts/types/prompts_batch_failed_predictions_response.py +11 -21
  104. label_studio_sdk/prompts/types/prompts_batch_predictions_request_results_item.py +26 -29
  105. label_studio_sdk/prompts/types/prompts_batch_predictions_response.py +11 -21
  106. label_studio_sdk/prompts/versions/client.py +277 -88
  107. label_studio_sdk/tasks/client.py +263 -90
  108. label_studio_sdk/tasks/types/tasks_list_response.py +15 -25
  109. label_studio_sdk/tokens/__init__.py +2 -0
  110. label_studio_sdk/tokens/client.py +470 -0
  111. label_studio_sdk/tokens/client_ext.py +94 -0
  112. label_studio_sdk/types/__init__.py +20 -6
  113. label_studio_sdk/types/access_token_response.py +22 -0
  114. label_studio_sdk/types/annotation.py +29 -38
  115. label_studio_sdk/types/annotation_filter_options.py +14 -24
  116. label_studio_sdk/types/annotations_dm_field.py +30 -39
  117. label_studio_sdk/types/api_token_response.py +32 -0
  118. label_studio_sdk/types/azure_blob_export_storage.py +28 -37
  119. label_studio_sdk/types/azure_blob_import_storage.py +28 -37
  120. label_studio_sdk/types/base_task.py +30 -39
  121. label_studio_sdk/types/base_task_updated_by.py +3 -1
  122. label_studio_sdk/types/base_user.py +14 -21
  123. label_studio_sdk/types/comment.py +12 -21
  124. label_studio_sdk/types/comment_created_by.py +1 -1
  125. label_studio_sdk/types/converted_format.py +12 -22
  126. label_studio_sdk/types/data_manager_task_serializer.py +31 -40
  127. label_studio_sdk/types/data_manager_task_serializer_annotators_item.py +1 -1
  128. label_studio_sdk/types/data_manager_task_serializer_drafts_item.py +13 -22
  129. label_studio_sdk/types/data_manager_task_serializer_predictions_item.py +15 -24
  130. label_studio_sdk/types/export.py +17 -26
  131. label_studio_sdk/types/export_format.py +25 -0
  132. label_studio_sdk/types/export_snapshot.py +45 -0
  133. label_studio_sdk/types/export_snapshot_status.py +5 -0
  134. label_studio_sdk/types/file_upload.py +11 -21
  135. label_studio_sdk/types/filter.py +16 -26
  136. label_studio_sdk/types/filter_group.py +12 -22
  137. label_studio_sdk/types/gcs_export_storage.py +28 -37
  138. label_studio_sdk/types/gcs_import_storage.py +28 -37
  139. label_studio_sdk/types/inference_run.py +14 -23
  140. label_studio_sdk/types/inference_run_cost_estimate.py +17 -27
  141. label_studio_sdk/types/inference_run_created_by.py +1 -1
  142. label_studio_sdk/types/inference_run_organization.py +1 -1
  143. label_studio_sdk/types/jwt_settings_response.py +32 -0
  144. label_studio_sdk/types/key_indicator_value.py +12 -22
  145. label_studio_sdk/types/key_indicators.py +0 -1
  146. label_studio_sdk/types/key_indicators_item.py +15 -25
  147. label_studio_sdk/types/key_indicators_item_additional_kpis_item.py +13 -23
  148. label_studio_sdk/types/key_indicators_item_extra_kpis_item.py +13 -23
  149. label_studio_sdk/types/local_files_export_storage.py +25 -34
  150. label_studio_sdk/types/local_files_import_storage.py +24 -33
  151. label_studio_sdk/types/ml_backend.py +23 -32
  152. label_studio_sdk/types/model_provider_connection.py +22 -31
  153. label_studio_sdk/types/model_provider_connection_created_by.py +1 -1
  154. label_studio_sdk/types/model_provider_connection_organization.py +1 -1
  155. label_studio_sdk/types/model_provider_connection_provider.py +3 -1
  156. label_studio_sdk/types/pause.py +34 -0
  157. label_studio_sdk/types/pause_paused_by.py +5 -0
  158. label_studio_sdk/types/prediction.py +21 -30
  159. label_studio_sdk/types/project.py +58 -55
  160. label_studio_sdk/types/project_import.py +21 -30
  161. label_studio_sdk/types/project_label_config.py +12 -22
  162. label_studio_sdk/types/prompt.py +24 -32
  163. label_studio_sdk/types/prompt_associated_projects_item.py +6 -0
  164. label_studio_sdk/types/prompt_associated_projects_item_id.py +20 -0
  165. label_studio_sdk/types/prompt_created_by.py +1 -1
  166. label_studio_sdk/types/prompt_organization.py +1 -1
  167. label_studio_sdk/types/prompt_version.py +13 -22
  168. label_studio_sdk/types/prompt_version_created_by.py +1 -1
  169. label_studio_sdk/types/prompt_version_organization.py +1 -1
  170. label_studio_sdk/types/prompt_version_provider.py +3 -1
  171. label_studio_sdk/types/redis_export_storage.py +29 -38
  172. label_studio_sdk/types/redis_import_storage.py +28 -37
  173. label_studio_sdk/types/refined_prompt_response.py +19 -29
  174. label_studio_sdk/types/s3export_storage.py +36 -43
  175. label_studio_sdk/types/s3import_storage.py +37 -44
  176. label_studio_sdk/types/s3s_export_storage.py +26 -33
  177. label_studio_sdk/types/s3s_import_storage.py +35 -42
  178. label_studio_sdk/types/serialization_option.py +12 -22
  179. label_studio_sdk/types/serialization_options.py +18 -28
  180. label_studio_sdk/types/task.py +44 -47
  181. label_studio_sdk/types/task_annotators_item.py +1 -1
  182. label_studio_sdk/types/task_comment_authors_item.py +1 -1
  183. label_studio_sdk/types/task_filter_options.py +15 -25
  184. label_studio_sdk/types/user_simple.py +11 -21
  185. label_studio_sdk/types/view.py +16 -26
  186. label_studio_sdk/types/webhook.py +19 -28
  187. label_studio_sdk/types/webhook_serializer_for_update.py +19 -28
  188. label_studio_sdk/types/workspace.py +22 -31
  189. label_studio_sdk/users/client.py +257 -63
  190. label_studio_sdk/users/types/users_get_token_response.py +12 -22
  191. label_studio_sdk/users/types/users_reset_token_response.py +12 -22
  192. label_studio_sdk/version.py +0 -1
  193. label_studio_sdk/versions/__init__.py +5 -0
  194. label_studio_sdk/versions/client.py +112 -0
  195. label_studio_sdk/versions/types/__init__.py +6 -0
  196. label_studio_sdk/versions/types/versions_get_response.py +73 -0
  197. label_studio_sdk/versions/types/versions_get_response_edition.py +5 -0
  198. label_studio_sdk/views/client.py +219 -52
  199. label_studio_sdk/views/types/views_create_request_data.py +13 -23
  200. label_studio_sdk/views/types/views_create_request_data_filters.py +14 -24
  201. label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +16 -26
  202. label_studio_sdk/views/types/views_create_request_data_filters_items_item_value.py +3 -1
  203. label_studio_sdk/views/types/views_update_request_data.py +13 -23
  204. label_studio_sdk/views/types/views_update_request_data_filters.py +14 -24
  205. label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +16 -26
  206. label_studio_sdk/views/types/views_update_request_data_filters_items_item_value.py +3 -1
  207. label_studio_sdk/webhooks/client.py +191 -61
  208. label_studio_sdk/workspaces/client.py +164 -41
  209. label_studio_sdk/workspaces/members/client.py +109 -31
  210. label_studio_sdk/workspaces/members/types/members_create_response.py +12 -22
  211. label_studio_sdk/workspaces/members/types/members_list_response_item.py +12 -22
  212. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.11.dist-info}/METADATA +8 -5
  213. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.11.dist-info}/RECORD +215 -188
  214. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.11.dist-info}/WHEEL +1 -1
  215. label_studio_sdk/types/export_convert.py +0 -32
  216. label_studio_sdk/types/export_create.py +0 -54
  217. label_studio_sdk/types/export_create_status.py +0 -5
  218. {label_studio_sdk-1.0.8.dist-info → label_studio_sdk-1.0.11.dist-info}/LICENSE +0 -0
@@ -1,15 +1,15 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
+ from ...core.client_wrapper import SyncClientWrapper
3
4
  import typing
5
+ from ...core.request_options import RequestOptions
6
+ from ...types.key_indicators import KeyIndicators
7
+ from ...core.jsonable_encoder import jsonable_encoder
8
+ from ...core.pydantic_utilities import parse_obj_as
4
9
  from json.decoder import JSONDecodeError
5
-
6
10
  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
11
  from ...types.key_indicator_value import KeyIndicatorValue
12
- from ...types.key_indicators import KeyIndicators
12
+ from ...core.client_wrapper import AsyncClientWrapper
13
13
 
14
14
 
15
15
  class IndicatorsClient:
@@ -35,7 +35,7 @@ class IndicatorsClient:
35
35
 
36
36
  Examples
37
37
  --------
38
- from label_studio_sdk.client import LabelStudio
38
+ from label_studio_sdk import LabelStudio
39
39
 
40
40
  client = LabelStudio(
41
41
  api_key="YOUR_API_KEY",
@@ -45,11 +45,19 @@ class IndicatorsClient:
45
45
  )
46
46
  """
47
47
  _response = self._client_wrapper.httpx_client.request(
48
- f"api/inference-runs/{jsonable_encoder(pk)}/indicators", method="GET", request_options=request_options
48
+ f"api/inference-runs/{jsonable_encoder(pk)}/indicators",
49
+ method="GET",
50
+ request_options=request_options,
49
51
  )
50
52
  try:
51
53
  if 200 <= _response.status_code < 300:
52
- return pydantic_v1.parse_obj_as(KeyIndicators, _response.json()) # type: ignore
54
+ return typing.cast(
55
+ KeyIndicators,
56
+ parse_obj_as(
57
+ type_=KeyIndicators, # type: ignore
58
+ object_=_response.json(),
59
+ ),
60
+ )
53
61
  _response_json = _response.json()
54
62
  except JSONDecodeError:
55
63
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -79,7 +87,7 @@ class IndicatorsClient:
79
87
 
80
88
  Examples
81
89
  --------
82
- from label_studio_sdk.client import LabelStudio
90
+ from label_studio_sdk import LabelStudio
83
91
 
84
92
  client = LabelStudio(
85
93
  api_key="YOUR_API_KEY",
@@ -96,7 +104,13 @@ class IndicatorsClient:
96
104
  )
97
105
  try:
98
106
  if 200 <= _response.status_code < 300:
99
- return pydantic_v1.parse_obj_as(KeyIndicatorValue, _response.json()) # type: ignore
107
+ return typing.cast(
108
+ KeyIndicatorValue,
109
+ parse_obj_as(
110
+ type_=KeyIndicatorValue, # type: ignore
111
+ object_=_response.json(),
112
+ ),
113
+ )
100
114
  _response_json = _response.json()
101
115
  except JSONDecodeError:
102
116
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -126,21 +140,37 @@ class AsyncIndicatorsClient:
126
140
 
127
141
  Examples
128
142
  --------
129
- from label_studio_sdk.client import AsyncLabelStudio
143
+ import asyncio
144
+
145
+ from label_studio_sdk import AsyncLabelStudio
130
146
 
131
147
  client = AsyncLabelStudio(
132
148
  api_key="YOUR_API_KEY",
133
149
  )
134
- await client.prompts.indicators.list(
135
- pk=1,
136
- )
150
+
151
+
152
+ async def main() -> None:
153
+ await client.prompts.indicators.list(
154
+ pk=1,
155
+ )
156
+
157
+
158
+ asyncio.run(main())
137
159
  """
138
160
  _response = await self._client_wrapper.httpx_client.request(
139
- f"api/inference-runs/{jsonable_encoder(pk)}/indicators", method="GET", request_options=request_options
161
+ f"api/inference-runs/{jsonable_encoder(pk)}/indicators",
162
+ method="GET",
163
+ request_options=request_options,
140
164
  )
141
165
  try:
142
166
  if 200 <= _response.status_code < 300:
143
- return pydantic_v1.parse_obj_as(KeyIndicators, _response.json()) # type: ignore
167
+ return typing.cast(
168
+ KeyIndicators,
169
+ parse_obj_as(
170
+ type_=KeyIndicators, # type: ignore
171
+ object_=_response.json(),
172
+ ),
173
+ )
144
174
  _response_json = _response.json()
145
175
  except JSONDecodeError:
146
176
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -170,15 +200,23 @@ class AsyncIndicatorsClient:
170
200
 
171
201
  Examples
172
202
  --------
173
- from label_studio_sdk.client import AsyncLabelStudio
203
+ import asyncio
204
+
205
+ from label_studio_sdk import AsyncLabelStudio
174
206
 
175
207
  client = AsyncLabelStudio(
176
208
  api_key="YOUR_API_KEY",
177
209
  )
178
- await client.prompts.indicators.get(
179
- indicator_key="indicator_key",
180
- pk=1,
181
- )
210
+
211
+
212
+ async def main() -> None:
213
+ await client.prompts.indicators.get(
214
+ indicator_key="indicator_key",
215
+ pk=1,
216
+ )
217
+
218
+
219
+ asyncio.run(main())
182
220
  """
183
221
  _response = await self._client_wrapper.httpx_client.request(
184
222
  f"api/inference-runs/{jsonable_encoder(pk)}/indicators/{jsonable_encoder(indicator_key)}",
@@ -187,7 +225,13 @@ class AsyncIndicatorsClient:
187
225
  )
188
226
  try:
189
227
  if 200 <= _response.status_code < 300:
190
- return pydantic_v1.parse_obj_as(KeyIndicatorValue, _response.json()) # type: ignore
228
+ return typing.cast(
229
+ KeyIndicatorValue,
230
+ parse_obj_as(
231
+ type_=KeyIndicatorValue, # type: ignore
232
+ object_=_response.json(),
233
+ ),
234
+ )
191
235
  _response_json = _response.json()
192
236
  except JSONDecodeError:
193
237
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -1,20 +1,21 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import datetime as dt
4
3
  import typing
5
- from json.decoder import JSONDecodeError
6
-
7
- from ...core.api_error import ApiError
8
- from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
9
- from ...core.jsonable_encoder import jsonable_encoder
10
- from ...core.pydantic_utilities import pydantic_v1
4
+ from ...core.client_wrapper import SyncClientWrapper
5
+ from .types.runs_list_request_project_subset import RunsListRequestProjectSubset
11
6
  from ...core.request_options import RequestOptions
12
7
  from ...types.inference_run import InferenceRun
13
- from ...types.inference_run_created_by import InferenceRunCreatedBy
14
- from ...types.inference_run_organization import InferenceRunOrganization
8
+ from ...core.jsonable_encoder import jsonable_encoder
9
+ from ...core.pydantic_utilities import parse_obj_as
10
+ from json.decoder import JSONDecodeError
11
+ from ...core.api_error import ApiError
15
12
  from ...types.inference_run_project_subset import InferenceRunProjectSubset
13
+ from ...types.inference_run_organization import InferenceRunOrganization
14
+ from ...types.inference_run_created_by import InferenceRunCreatedBy
16
15
  from ...types.inference_run_status import InferenceRunStatus
17
- from .types.runs_list_request_project_subset import RunsListRequestProjectSubset
16
+ import datetime as dt
17
+ from ...core.serialization import convert_and_respect_annotation_metadata
18
+ from ...core.client_wrapper import AsyncClientWrapper
18
19
 
19
20
  # this is used as the default value for optional parameters
20
21
  OMIT = typing.cast(typing.Any, ...)
@@ -60,7 +61,7 @@ class RunsClient:
60
61
 
61
62
  Examples
62
63
  --------
63
- from label_studio_sdk.client import LabelStudio
64
+ from label_studio_sdk import LabelStudio
64
65
 
65
66
  client = LabelStudio(
66
67
  api_key="YOUR_API_KEY",
@@ -75,12 +76,21 @@ class RunsClient:
75
76
  _response = self._client_wrapper.httpx_client.request(
76
77
  f"api/prompts/{jsonable_encoder(id)}/versions/{jsonable_encoder(version_id)}/inference-runs",
77
78
  method="GET",
78
- params={"project": project, "project_subset": project_subset},
79
+ params={
80
+ "project": project,
81
+ "project_subset": project_subset,
82
+ },
79
83
  request_options=request_options,
80
84
  )
81
85
  try:
82
86
  if 200 <= _response.status_code < 300:
83
- return pydantic_v1.parse_obj_as(InferenceRun, _response.json()) # type: ignore
87
+ return typing.cast(
88
+ InferenceRun,
89
+ parse_obj_as(
90
+ type_=InferenceRun, # type: ignore
91
+ object_=_response.json(),
92
+ ),
93
+ )
84
94
  _response_json = _response.json()
85
95
  except JSONDecodeError:
86
96
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -94,7 +104,7 @@ class RunsClient:
94
104
  project: int,
95
105
  project_subset: InferenceRunProjectSubset,
96
106
  organization: typing.Optional[InferenceRunOrganization] = OMIT,
97
- model_version: typing.Optional[str] = OMIT,
107
+ model_version: typing.Optional[int] = OMIT,
98
108
  created_by: typing.Optional[InferenceRunCreatedBy] = OMIT,
99
109
  status: typing.Optional[InferenceRunStatus] = OMIT,
100
110
  job_id: typing.Optional[str] = OMIT,
@@ -121,7 +131,7 @@ class RunsClient:
121
131
 
122
132
  organization : typing.Optional[InferenceRunOrganization]
123
133
 
124
- model_version : typing.Optional[str]
134
+ model_version : typing.Optional[int]
125
135
 
126
136
  created_by : typing.Optional[InferenceRunCreatedBy]
127
137
 
@@ -147,7 +157,7 @@ class RunsClient:
147
157
 
148
158
  Examples
149
159
  --------
150
- from label_studio_sdk.client import LabelStudio
160
+ from label_studio_sdk import LabelStudio
151
161
 
152
162
  client = LabelStudio(
153
163
  api_key="YOUR_API_KEY",
@@ -163,10 +173,14 @@ class RunsClient:
163
173
  f"api/prompts/{jsonable_encoder(id)}/versions/{jsonable_encoder(version_id)}/inference-runs",
164
174
  method="POST",
165
175
  json={
166
- "organization": organization,
176
+ "organization": convert_and_respect_annotation_metadata(
177
+ object_=organization, annotation=InferenceRunOrganization, direction="write"
178
+ ),
167
179
  "project": project,
168
180
  "model_version": model_version,
169
- "created_by": created_by,
181
+ "created_by": convert_and_respect_annotation_metadata(
182
+ object_=created_by, annotation=InferenceRunCreatedBy, direction="write"
183
+ ),
170
184
  "project_subset": project_subset,
171
185
  "status": status,
172
186
  "job_id": job_id,
@@ -180,7 +194,13 @@ class RunsClient:
180
194
  )
181
195
  try:
182
196
  if 200 <= _response.status_code < 300:
183
- return pydantic_v1.parse_obj_as(InferenceRun, _response.json()) # type: ignore
197
+ return typing.cast(
198
+ InferenceRun,
199
+ parse_obj_as(
200
+ type_=InferenceRun, # type: ignore
201
+ object_=_response.json(),
202
+ ),
203
+ )
184
204
  _response_json = _response.json()
185
205
  except JSONDecodeError:
186
206
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -227,27 +247,44 @@ class AsyncRunsClient:
227
247
 
228
248
  Examples
229
249
  --------
230
- from label_studio_sdk.client import AsyncLabelStudio
250
+ import asyncio
251
+
252
+ from label_studio_sdk import AsyncLabelStudio
231
253
 
232
254
  client = AsyncLabelStudio(
233
255
  api_key="YOUR_API_KEY",
234
256
  )
235
- await client.prompts.runs.list(
236
- id=1,
237
- version_id=1,
238
- project=1,
239
- project_subset="All",
240
- )
257
+
258
+
259
+ async def main() -> None:
260
+ await client.prompts.runs.list(
261
+ id=1,
262
+ version_id=1,
263
+ project=1,
264
+ project_subset="All",
265
+ )
266
+
267
+
268
+ asyncio.run(main())
241
269
  """
242
270
  _response = await self._client_wrapper.httpx_client.request(
243
271
  f"api/prompts/{jsonable_encoder(id)}/versions/{jsonable_encoder(version_id)}/inference-runs",
244
272
  method="GET",
245
- params={"project": project, "project_subset": project_subset},
273
+ params={
274
+ "project": project,
275
+ "project_subset": project_subset,
276
+ },
246
277
  request_options=request_options,
247
278
  )
248
279
  try:
249
280
  if 200 <= _response.status_code < 300:
250
- return pydantic_v1.parse_obj_as(InferenceRun, _response.json()) # type: ignore
281
+ return typing.cast(
282
+ InferenceRun,
283
+ parse_obj_as(
284
+ type_=InferenceRun, # type: ignore
285
+ object_=_response.json(),
286
+ ),
287
+ )
251
288
  _response_json = _response.json()
252
289
  except JSONDecodeError:
253
290
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -261,7 +298,7 @@ class AsyncRunsClient:
261
298
  project: int,
262
299
  project_subset: InferenceRunProjectSubset,
263
300
  organization: typing.Optional[InferenceRunOrganization] = OMIT,
264
- model_version: typing.Optional[str] = OMIT,
301
+ model_version: typing.Optional[int] = OMIT,
265
302
  created_by: typing.Optional[InferenceRunCreatedBy] = OMIT,
266
303
  status: typing.Optional[InferenceRunStatus] = OMIT,
267
304
  job_id: typing.Optional[str] = OMIT,
@@ -288,7 +325,7 @@ class AsyncRunsClient:
288
325
 
289
326
  organization : typing.Optional[InferenceRunOrganization]
290
327
 
291
- model_version : typing.Optional[str]
328
+ model_version : typing.Optional[int]
292
329
 
293
330
  created_by : typing.Optional[InferenceRunCreatedBy]
294
331
 
@@ -314,26 +351,38 @@ class AsyncRunsClient:
314
351
 
315
352
  Examples
316
353
  --------
317
- from label_studio_sdk.client import AsyncLabelStudio
354
+ import asyncio
355
+
356
+ from label_studio_sdk import AsyncLabelStudio
318
357
 
319
358
  client = AsyncLabelStudio(
320
359
  api_key="YOUR_API_KEY",
321
360
  )
322
- await client.prompts.runs.create(
323
- id=1,
324
- version_id=1,
325
- project=1,
326
- project_subset="All",
327
- )
361
+
362
+
363
+ async def main() -> None:
364
+ await client.prompts.runs.create(
365
+ id=1,
366
+ version_id=1,
367
+ project=1,
368
+ project_subset="All",
369
+ )
370
+
371
+
372
+ asyncio.run(main())
328
373
  """
329
374
  _response = await self._client_wrapper.httpx_client.request(
330
375
  f"api/prompts/{jsonable_encoder(id)}/versions/{jsonable_encoder(version_id)}/inference-runs",
331
376
  method="POST",
332
377
  json={
333
- "organization": organization,
378
+ "organization": convert_and_respect_annotation_metadata(
379
+ object_=organization, annotation=InferenceRunOrganization, direction="write"
380
+ ),
334
381
  "project": project,
335
382
  "model_version": model_version,
336
- "created_by": created_by,
383
+ "created_by": convert_and_respect_annotation_metadata(
384
+ object_=created_by, annotation=InferenceRunCreatedBy, direction="write"
385
+ ),
337
386
  "project_subset": project_subset,
338
387
  "status": status,
339
388
  "job_id": job_id,
@@ -347,7 +396,13 @@ class AsyncRunsClient:
347
396
  )
348
397
  try:
349
398
  if 200 <= _response.status_code < 300:
350
- return pydantic_v1.parse_obj_as(InferenceRun, _response.json()) # type: ignore
399
+ return typing.cast(
400
+ InferenceRun,
401
+ parse_obj_as(
402
+ type_=InferenceRun, # type: ignore
403
+ object_=_response.json(),
404
+ ),
405
+ )
351
406
  _response_json = _response.json()
352
407
  except JSONDecodeError:
353
408
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -1,42 +1,32 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import datetime as dt
3
+ from ...core.pydantic_utilities import UniversalBaseModel
4
4
  import typing
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
5
7
 
6
- from ...core.datetime_utils import serialize_datetime
7
- from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
8
8
 
9
-
10
- class PromptsBatchFailedPredictionsRequestFailedPredictionsItem(pydantic_v1.BaseModel):
11
- task_id: typing.Optional[int] = pydantic_v1.Field(default=None)
9
+ class PromptsBatchFailedPredictionsRequestFailedPredictionsItem(UniversalBaseModel):
10
+ task_id: typing.Optional[int] = pydantic.Field(default=None)
12
11
  """
13
12
  Task ID to associate the prediction with
14
13
  """
15
14
 
16
- error_type: typing.Optional[str] = pydantic_v1.Field(default=None)
15
+ error_type: typing.Optional[str] = pydantic.Field(default=None)
17
16
  """
18
17
  Type of error (e.g. "Timeout", "Rate Limit", etc)
19
18
  """
20
19
 
21
- message: typing.Optional[str] = pydantic_v1.Field(default=None)
20
+ message: typing.Optional[str] = pydantic.Field(default=None)
22
21
  """
23
22
  Error message details
24
23
  """
25
24
 
26
- def json(self, **kwargs: typing.Any) -> str:
27
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
28
- return super().json(**kwargs_with_defaults)
29
-
30
- def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
31
- kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
32
- kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
33
-
34
- return deep_union_pydantic_dicts(
35
- super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
36
- )
25
+ if IS_PYDANTIC_V2:
26
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
27
+ else:
37
28
 
38
- class Config:
39
- frozen = True
40
- smart_union = True
41
- extra = pydantic_v1.Extra.allow
42
- json_encoders = {dt.datetime: serialize_datetime}
29
+ class Config:
30
+ frozen = True
31
+ smart_union = True
32
+ extra = pydantic.Extra.allow
@@ -1,29 +1,19 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import datetime as dt
3
+ from ...core.pydantic_utilities import UniversalBaseModel
4
4
  import typing
5
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
6
+ import pydantic
5
7
 
6
- from ...core.datetime_utils import serialize_datetime
7
- from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
8
8
 
9
-
10
- class PromptsBatchFailedPredictionsResponse(pydantic_v1.BaseModel):
9
+ class PromptsBatchFailedPredictionsResponse(UniversalBaseModel):
11
10
  detail: typing.Optional[str] = None
12
11
 
13
- def json(self, **kwargs: typing.Any) -> str:
14
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
15
- return super().json(**kwargs_with_defaults)
16
-
17
- def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
18
- kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
19
- kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
20
-
21
- return deep_union_pydantic_dicts(
22
- super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
23
- )
12
+ if IS_PYDANTIC_V2:
13
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
14
+ else:
24
15
 
25
- class Config:
26
- frozen = True
27
- smart_union = True
28
- extra = pydantic_v1.Extra.allow
29
- json_encoders = {dt.datetime: serialize_datetime}
16
+ class Config:
17
+ frozen = True
18
+ smart_union = True
19
+ extra = pydantic.Extra.allow
@@ -1,62 +1,59 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import datetime as dt
3
+ from ...core.pydantic_utilities import UniversalBaseModel
4
4
  import typing
5
+ import pydantic
6
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
5
7
 
6
- from ...core.datetime_utils import serialize_datetime
7
- from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
8
8
 
9
-
10
- class PromptsBatchPredictionsRequestResultsItem(pydantic_v1.BaseModel):
11
- task_id: typing.Optional[int] = pydantic_v1.Field(default=None)
9
+ class PromptsBatchPredictionsRequestResultsItem(UniversalBaseModel):
10
+ task_id: typing.Optional[int] = pydantic.Field(default=None)
12
11
  """
13
12
  Task ID to associate the prediction with
14
13
  """
15
14
 
16
- output: typing.Optional[typing.Dict[str, typing.Any]] = pydantic_v1.Field(default=None)
15
+ output: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = pydantic.Field(default=None)
17
16
  """
18
- Prediction output that contains keys from labeling config. Each key must be a valid control tag name from the labeling config. For example, given the output: `json {"sentiment": "positive"} ` it will be converted to the internal LS annotation format: `json { "value": { "choices": ["positive"] }, "from_name": "label", "to_name": "", ... } `
17
+ Prediction output that contains keys from labeling config. Each key must be a valid control tag name from the labeling config. For example, given the output: ```json {"sentiment": "positive"} ``` it will be converted to the internal LS annotation format: ```json {
18
+ "value": {
19
+ "choices": ["positive"]
20
+ },
21
+ "from_name": "label",
22
+ "to_name": "",
23
+ ...
24
+ } ```
19
25
  """
20
26
 
21
- prompt_tokens: typing.Optional[int] = pydantic_v1.Field(default=None)
27
+ prompt_tokens: typing.Optional[int] = pydantic.Field(default=None)
22
28
  """
23
29
  Number of tokens in the prompt
24
30
  """
25
31
 
26
- completion_tokens: typing.Optional[int] = pydantic_v1.Field(default=None)
32
+ completion_tokens: typing.Optional[int] = pydantic.Field(default=None)
27
33
  """
28
34
  Number of tokens in the completion
29
35
  """
30
36
 
31
- prompt_cost_usd: typing.Optional[float] = pydantic_v1.Field(default=None)
37
+ prompt_cost_usd: typing.Optional[float] = pydantic.Field(default=None)
32
38
  """
33
39
  Cost of the prompt (in USD)
34
40
  """
35
41
 
36
- completion_cost_usd: typing.Optional[float] = pydantic_v1.Field(default=None)
42
+ completion_cost_usd: typing.Optional[float] = pydantic.Field(default=None)
37
43
  """
38
44
  Cost of the completion (in USD)
39
45
  """
40
46
 
41
- total_cost_usd: typing.Optional[float] = pydantic_v1.Field(default=None)
47
+ total_cost_usd: typing.Optional[float] = pydantic.Field(default=None)
42
48
  """
43
49
  Total cost of the inference (in USD)
44
50
  """
45
51
 
46
- def json(self, **kwargs: typing.Any) -> str:
47
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
48
- return super().json(**kwargs_with_defaults)
49
-
50
- def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
51
- kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
52
- kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
53
-
54
- return deep_union_pydantic_dicts(
55
- super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
56
- )
52
+ if IS_PYDANTIC_V2:
53
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
54
+ else:
57
55
 
58
- class Config:
59
- frozen = True
60
- smart_union = True
61
- extra = pydantic_v1.Extra.allow
62
- json_encoders = {dt.datetime: serialize_datetime}
56
+ class Config:
57
+ frozen = True
58
+ smart_union = True
59
+ extra = pydantic.Extra.allow
@@ -1,29 +1,19 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import datetime as dt
3
+ from ...core.pydantic_utilities import UniversalBaseModel
4
4
  import typing
5
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
6
+ import pydantic
5
7
 
6
- from ...core.datetime_utils import serialize_datetime
7
- from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
8
8
 
9
-
10
- class PromptsBatchPredictionsResponse(pydantic_v1.BaseModel):
9
+ class PromptsBatchPredictionsResponse(UniversalBaseModel):
11
10
  detail: typing.Optional[str] = None
12
11
 
13
- def json(self, **kwargs: typing.Any) -> str:
14
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
15
- return super().json(**kwargs_with_defaults)
16
-
17
- def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
18
- kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
19
- kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
20
-
21
- return deep_union_pydantic_dicts(
22
- super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
23
- )
12
+ if IS_PYDANTIC_V2:
13
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
14
+ else:
24
15
 
25
- class Config:
26
- frozen = True
27
- smart_union = True
28
- extra = pydantic_v1.Extra.allow
29
- json_encoders = {dt.datetime: serialize_datetime}
16
+ class Config:
17
+ frozen = True
18
+ smart_union = True
19
+ extra = pydantic.Extra.allow