label-studio-sdk 1.0.7__py3-none-any.whl → 1.0.10__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 (206) hide show
  1. label_studio_sdk/__init__.py +26 -7
  2. label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +13 -4
  3. label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +16 -4
  4. label_studio_sdk/_extensions/label_studio_tools/core/utils/json_schema.py +86 -0
  5. label_studio_sdk/_extensions/pager_ext.py +8 -0
  6. label_studio_sdk/_legacy/schema/label_config_schema.json +42 -11
  7. label_studio_sdk/actions/client.py +91 -40
  8. label_studio_sdk/actions/types/actions_create_request_filters.py +14 -24
  9. label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +16 -26
  10. label_studio_sdk/actions/types/actions_create_request_filters_items_item_value.py +3 -1
  11. label_studio_sdk/actions/types/actions_create_request_selected_items.py +1 -2
  12. label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +15 -25
  13. label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +15 -25
  14. label_studio_sdk/annotations/__init__.py +2 -2
  15. label_studio_sdk/annotations/client.py +278 -104
  16. label_studio_sdk/annotations/types/__init__.py +2 -1
  17. label_studio_sdk/annotations/types/annotations_create_bulk_request_selected_items.py +34 -0
  18. label_studio_sdk/annotations/types/annotations_create_bulk_response_item.py +11 -21
  19. label_studio_sdk/base_client.py +46 -27
  20. label_studio_sdk/client.py +1 -0
  21. label_studio_sdk/comments/client.py +190 -44
  22. label_studio_sdk/converter/converter.py +66 -18
  23. label_studio_sdk/converter/imports/yolo.py +1 -1
  24. label_studio_sdk/converter/utils.py +3 -2
  25. label_studio_sdk/core/__init__.py +21 -4
  26. label_studio_sdk/core/client_wrapper.py +9 -10
  27. label_studio_sdk/core/file.py +37 -8
  28. label_studio_sdk/core/http_client.py +52 -28
  29. label_studio_sdk/core/jsonable_encoder.py +33 -31
  30. label_studio_sdk/core/pagination.py +5 -4
  31. label_studio_sdk/core/pydantic_utilities.py +272 -4
  32. label_studio_sdk/core/query_encoder.py +38 -13
  33. label_studio_sdk/core/request_options.py +3 -0
  34. label_studio_sdk/core/serialization.py +272 -0
  35. label_studio_sdk/errors/bad_request_error.py +2 -3
  36. label_studio_sdk/export_storage/azure/client.py +228 -58
  37. label_studio_sdk/export_storage/azure/types/azure_create_response.py +19 -29
  38. label_studio_sdk/export_storage/azure/types/azure_update_response.py +19 -29
  39. label_studio_sdk/export_storage/client.py +48 -18
  40. label_studio_sdk/export_storage/gcs/client.py +228 -58
  41. label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +19 -29
  42. label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +19 -29
  43. label_studio_sdk/export_storage/local/client.py +222 -56
  44. label_studio_sdk/export_storage/local/types/local_create_response.py +17 -27
  45. label_studio_sdk/export_storage/local/types/local_update_response.py +17 -27
  46. label_studio_sdk/export_storage/redis/client.py +228 -58
  47. label_studio_sdk/export_storage/redis/types/redis_create_response.py +20 -30
  48. label_studio_sdk/export_storage/redis/types/redis_update_response.py +20 -30
  49. label_studio_sdk/export_storage/s3/client.py +228 -58
  50. label_studio_sdk/export_storage/s3/types/s3create_response.py +27 -35
  51. label_studio_sdk/export_storage/s3/types/s3update_response.py +27 -35
  52. label_studio_sdk/export_storage/s3s/client.py +187 -43
  53. label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +11 -21
  54. label_studio_sdk/files/client.py +172 -56
  55. label_studio_sdk/import_storage/azure/client.py +223 -53
  56. label_studio_sdk/import_storage/azure/types/azure_create_response.py +22 -32
  57. label_studio_sdk/import_storage/azure/types/azure_update_response.py +22 -32
  58. label_studio_sdk/import_storage/client.py +48 -18
  59. label_studio_sdk/import_storage/gcs/client.py +223 -53
  60. label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +22 -32
  61. label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +22 -32
  62. label_studio_sdk/import_storage/local/client.py +223 -53
  63. label_studio_sdk/import_storage/local/types/local_create_response.py +17 -27
  64. label_studio_sdk/import_storage/local/types/local_update_response.py +17 -27
  65. label_studio_sdk/import_storage/redis/client.py +223 -53
  66. label_studio_sdk/import_storage/redis/types/redis_create_response.py +20 -30
  67. label_studio_sdk/import_storage/redis/types/redis_update_response.py +20 -30
  68. label_studio_sdk/import_storage/s3/client.py +223 -53
  69. label_studio_sdk/import_storage/s3/types/s3create_response.py +31 -39
  70. label_studio_sdk/import_storage/s3/types/s3update_response.py +31 -39
  71. label_studio_sdk/import_storage/s3s/client.py +222 -52
  72. label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +11 -21
  73. label_studio_sdk/label_interface/control_tags.py +205 -10
  74. label_studio_sdk/label_interface/interface.py +80 -6
  75. label_studio_sdk/label_interface/region.py +1 -10
  76. label_studio_sdk/ml/client.py +280 -78
  77. label_studio_sdk/ml/types/ml_create_response.py +21 -31
  78. label_studio_sdk/ml/types/ml_update_response.py +21 -31
  79. label_studio_sdk/model_providers/client.py +656 -21
  80. label_studio_sdk/predictions/client.py +247 -101
  81. label_studio_sdk/projects/__init__.py +3 -0
  82. label_studio_sdk/projects/client.py +309 -115
  83. label_studio_sdk/projects/client_ext.py +16 -0
  84. label_studio_sdk/projects/exports/__init__.py +3 -0
  85. label_studio_sdk/projects/exports/client.py +447 -296
  86. label_studio_sdk/projects/exports/client_ext.py +134 -0
  87. label_studio_sdk/projects/exports/types/__init__.py +6 -0
  88. label_studio_sdk/projects/exports/types/exports_convert_response.py +24 -0
  89. label_studio_sdk/projects/exports/types/exports_list_formats_response_item.py +44 -0
  90. label_studio_sdk/projects/types/projects_create_response.py +29 -34
  91. label_studio_sdk/projects/types/projects_import_tasks_response.py +19 -29
  92. label_studio_sdk/projects/types/projects_list_response.py +11 -21
  93. label_studio_sdk/projects/types/projects_update_response.py +24 -34
  94. label_studio_sdk/prompts/client.py +309 -92
  95. label_studio_sdk/prompts/indicators/client.py +67 -23
  96. label_studio_sdk/prompts/runs/client.py +95 -40
  97. label_studio_sdk/prompts/types/prompts_batch_failed_predictions_request_failed_predictions_item.py +14 -24
  98. label_studio_sdk/prompts/types/prompts_batch_failed_predictions_response.py +11 -21
  99. label_studio_sdk/prompts/types/prompts_batch_predictions_request_results_item.py +26 -29
  100. label_studio_sdk/prompts/types/prompts_batch_predictions_response.py +11 -21
  101. label_studio_sdk/prompts/versions/client.py +389 -75
  102. label_studio_sdk/tasks/client.py +263 -90
  103. label_studio_sdk/tasks/types/tasks_list_response.py +15 -25
  104. label_studio_sdk/types/__init__.py +16 -6
  105. label_studio_sdk/types/annotation.py +29 -38
  106. label_studio_sdk/types/annotation_filter_options.py +14 -24
  107. label_studio_sdk/types/annotations_dm_field.py +30 -39
  108. label_studio_sdk/types/azure_blob_export_storage.py +28 -37
  109. label_studio_sdk/types/azure_blob_import_storage.py +28 -37
  110. label_studio_sdk/types/base_task.py +30 -39
  111. label_studio_sdk/types/base_task_updated_by.py +3 -1
  112. label_studio_sdk/types/base_user.py +14 -21
  113. label_studio_sdk/types/comment.py +12 -21
  114. label_studio_sdk/types/comment_created_by.py +1 -1
  115. label_studio_sdk/types/converted_format.py +12 -22
  116. label_studio_sdk/types/data_manager_task_serializer.py +31 -40
  117. label_studio_sdk/types/data_manager_task_serializer_annotators_item.py +1 -1
  118. label_studio_sdk/types/data_manager_task_serializer_drafts_item.py +13 -22
  119. label_studio_sdk/types/data_manager_task_serializer_predictions_item.py +15 -24
  120. label_studio_sdk/types/export.py +17 -26
  121. label_studio_sdk/types/export_format.py +25 -0
  122. label_studio_sdk/types/export_snapshot.py +45 -0
  123. label_studio_sdk/types/export_snapshot_status.py +5 -0
  124. label_studio_sdk/types/file_upload.py +11 -21
  125. label_studio_sdk/types/filter.py +16 -26
  126. label_studio_sdk/types/filter_group.py +12 -22
  127. label_studio_sdk/types/gcs_export_storage.py +28 -37
  128. label_studio_sdk/types/gcs_import_storage.py +28 -37
  129. label_studio_sdk/types/inference_run.py +14 -23
  130. label_studio_sdk/types/inference_run_cost_estimate.py +47 -0
  131. label_studio_sdk/types/inference_run_created_by.py +1 -1
  132. label_studio_sdk/types/inference_run_organization.py +1 -1
  133. label_studio_sdk/types/key_indicator_value.py +12 -22
  134. label_studio_sdk/types/key_indicators.py +0 -1
  135. label_studio_sdk/types/key_indicators_item.py +15 -25
  136. label_studio_sdk/types/key_indicators_item_additional_kpis_item.py +13 -23
  137. label_studio_sdk/types/key_indicators_item_extra_kpis_item.py +13 -23
  138. label_studio_sdk/types/local_files_export_storage.py +25 -34
  139. label_studio_sdk/types/local_files_import_storage.py +24 -33
  140. label_studio_sdk/types/ml_backend.py +23 -32
  141. label_studio_sdk/types/model_provider_connection.py +47 -26
  142. label_studio_sdk/types/model_provider_connection_budget_reset_period.py +5 -0
  143. label_studio_sdk/types/model_provider_connection_created_by.py +1 -1
  144. label_studio_sdk/types/model_provider_connection_organization.py +1 -1
  145. label_studio_sdk/types/model_provider_connection_provider.py +3 -1
  146. label_studio_sdk/types/prediction.py +21 -30
  147. label_studio_sdk/types/project.py +48 -55
  148. label_studio_sdk/types/project_import.py +21 -30
  149. label_studio_sdk/types/project_label_config.py +12 -22
  150. label_studio_sdk/types/prompt.py +24 -32
  151. label_studio_sdk/types/prompt_associated_projects_item.py +6 -0
  152. label_studio_sdk/types/prompt_associated_projects_item_id.py +20 -0
  153. label_studio_sdk/types/prompt_created_by.py +1 -1
  154. label_studio_sdk/types/prompt_organization.py +1 -1
  155. label_studio_sdk/types/prompt_version.py +13 -22
  156. label_studio_sdk/types/prompt_version_created_by.py +1 -1
  157. label_studio_sdk/types/prompt_version_organization.py +1 -1
  158. label_studio_sdk/types/prompt_version_provider.py +3 -1
  159. label_studio_sdk/types/redis_export_storage.py +29 -38
  160. label_studio_sdk/types/redis_import_storage.py +28 -37
  161. label_studio_sdk/types/refined_prompt_response.py +19 -29
  162. label_studio_sdk/types/s3export_storage.py +36 -43
  163. label_studio_sdk/types/s3import_storage.py +37 -44
  164. label_studio_sdk/types/s3s_export_storage.py +26 -33
  165. label_studio_sdk/types/s3s_import_storage.py +35 -42
  166. label_studio_sdk/types/serialization_option.py +12 -22
  167. label_studio_sdk/types/serialization_options.py +18 -28
  168. label_studio_sdk/types/task.py +46 -48
  169. label_studio_sdk/types/task_annotators_item.py +1 -1
  170. label_studio_sdk/types/task_comment_authors_item.py +5 -0
  171. label_studio_sdk/types/task_filter_options.py +15 -25
  172. label_studio_sdk/types/user_simple.py +11 -21
  173. label_studio_sdk/types/view.py +16 -26
  174. label_studio_sdk/types/webhook.py +19 -28
  175. label_studio_sdk/types/webhook_serializer_for_update.py +19 -28
  176. label_studio_sdk/types/workspace.py +22 -31
  177. label_studio_sdk/users/client.py +257 -63
  178. label_studio_sdk/users/types/users_get_token_response.py +12 -22
  179. label_studio_sdk/users/types/users_reset_token_response.py +12 -22
  180. label_studio_sdk/version.py +0 -1
  181. label_studio_sdk/versions/__init__.py +5 -0
  182. label_studio_sdk/versions/client.py +112 -0
  183. label_studio_sdk/versions/types/__init__.py +6 -0
  184. label_studio_sdk/versions/types/versions_get_response.py +73 -0
  185. label_studio_sdk/versions/types/versions_get_response_edition.py +5 -0
  186. label_studio_sdk/views/client.py +219 -52
  187. label_studio_sdk/views/types/views_create_request_data.py +13 -23
  188. label_studio_sdk/views/types/views_create_request_data_filters.py +14 -24
  189. label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +16 -26
  190. label_studio_sdk/views/types/views_create_request_data_filters_items_item_value.py +3 -1
  191. label_studio_sdk/views/types/views_update_request_data.py +13 -23
  192. label_studio_sdk/views/types/views_update_request_data_filters.py +14 -24
  193. label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +16 -26
  194. label_studio_sdk/views/types/views_update_request_data_filters_items_item_value.py +3 -1
  195. label_studio_sdk/webhooks/client.py +191 -61
  196. label_studio_sdk/workspaces/client.py +164 -41
  197. label_studio_sdk/workspaces/members/client.py +109 -31
  198. label_studio_sdk/workspaces/members/types/members_create_response.py +12 -22
  199. label_studio_sdk/workspaces/members/types/members_list_response_item.py +12 -22
  200. {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.10.dist-info}/METADATA +9 -5
  201. {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.10.dist-info}/RECORD +203 -186
  202. {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.10.dist-info}/WHEEL +1 -1
  203. label_studio_sdk/types/export_convert.py +0 -32
  204. label_studio_sdk/types/export_create.py +0 -54
  205. label_studio_sdk/types/export_create_status.py +0 -5
  206. {label_studio_sdk-1.0.7.dist-info → label_studio_sdk-1.0.10.dist-info}/LICENSE +0 -0
@@ -1,16 +1,17 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
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
4
+ from ..core.client_wrapper import SyncClientWrapper
10
5
  from ..core.request_options import RequestOptions
11
6
  from ..types.view import View
7
+ from ..core.pydantic_utilities import parse_obj_as
8
+ from json.decoder import JSONDecodeError
9
+ from ..core.api_error import ApiError
12
10
  from .types.views_create_request_data import ViewsCreateRequestData
11
+ from ..core.serialization import convert_and_respect_annotation_metadata
12
+ from ..core.jsonable_encoder import jsonable_encoder
13
13
  from .types.views_update_request_data import ViewsUpdateRequestData
14
+ from ..core.client_wrapper import AsyncClientWrapper
14
15
 
15
16
  # this is used as the default value for optional parameters
16
17
  OMIT = typing.cast(typing.Any, ...)
@@ -24,6 +25,7 @@ class ViewsClient:
24
25
  self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
25
26
  ) -> typing.List[View]:
26
27
  """
28
+
27
29
  List all views for a specific project. A view is a tab in the Data Manager where you can set filters and customize which tasks and information appears.
28
30
 
29
31
  You will need to provide the project ID. You can find this in the URL when viewing the project in Label Studio, or you can use [List all projects](../projects/list).
@@ -43,7 +45,7 @@ class ViewsClient:
43
45
 
44
46
  Examples
45
47
  --------
46
- from label_studio_sdk.client import LabelStudio
48
+ from label_studio_sdk import LabelStudio
47
49
 
48
50
  client = LabelStudio(
49
51
  api_key="YOUR_API_KEY",
@@ -51,11 +53,22 @@ class ViewsClient:
51
53
  client.views.list()
52
54
  """
53
55
  _response = self._client_wrapper.httpx_client.request(
54
- "api/dm/views/", method="GET", params={"project": project}, request_options=request_options
56
+ "api/dm/views/",
57
+ method="GET",
58
+ params={
59
+ "project": project,
60
+ },
61
+ request_options=request_options,
55
62
  )
56
63
  try:
57
64
  if 200 <= _response.status_code < 300:
58
- return pydantic_v1.parse_obj_as(typing.List[View], _response.json()) # type: ignore
65
+ return typing.cast(
66
+ typing.List[View],
67
+ parse_obj_as(
68
+ type_=typing.List[View], # type: ignore
69
+ object_=_response.json(),
70
+ ),
71
+ )
59
72
  _response_json = _response.json()
60
73
  except JSONDecodeError:
61
74
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -69,6 +82,7 @@ class ViewsClient:
69
82
  request_options: typing.Optional[RequestOptions] = None,
70
83
  ) -> View:
71
84
  """
85
+
72
86
  Create a new Data Manager view for a specific project. A view is a tab in the Data Manager where you can set filters and customize what tasks and information appears.
73
87
 
74
88
  You will need to provide the project ID. You can find this in the URL when viewing the project in Label Studio, or you can use [List all projects](../projects/list).
@@ -91,7 +105,7 @@ class ViewsClient:
91
105
 
92
106
  Examples
93
107
  --------
94
- from label_studio_sdk.client import LabelStudio
108
+ from label_studio_sdk import LabelStudio
95
109
 
96
110
  client = LabelStudio(
97
111
  api_key="YOUR_API_KEY",
@@ -101,13 +115,27 @@ class ViewsClient:
101
115
  _response = self._client_wrapper.httpx_client.request(
102
116
  "api/dm/views/",
103
117
  method="POST",
104
- json={"data": data, "project": project},
118
+ json={
119
+ "data": convert_and_respect_annotation_metadata(
120
+ object_=data, annotation=ViewsCreateRequestData, direction="write"
121
+ ),
122
+ "project": project,
123
+ },
124
+ headers={
125
+ "content-type": "application/json",
126
+ },
105
127
  request_options=request_options,
106
128
  omit=OMIT,
107
129
  )
108
130
  try:
109
131
  if 200 <= _response.status_code < 300:
110
- return pydantic_v1.parse_obj_as(View, _response.json()) # type: ignore
132
+ return typing.cast(
133
+ View,
134
+ parse_obj_as(
135
+ type_=View, # type: ignore
136
+ object_=_response.json(),
137
+ ),
138
+ )
111
139
  _response_json = _response.json()
112
140
  except JSONDecodeError:
113
141
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -115,6 +143,7 @@ class ViewsClient:
115
143
 
116
144
  def delete_all(self, *, project: int, request_options: typing.Optional[RequestOptions] = None) -> None:
117
145
  """
146
+
118
147
  Delete all views for a specific project. A view is a tab in the Data Manager where you can set filters and customize what tasks appear.
119
148
 
120
149
  You will need to provide the project ID. You can find this in the URL when viewing the project in Label Studio, or you can use [List all projects](../projects/list).
@@ -132,7 +161,7 @@ class ViewsClient:
132
161
 
133
162
  Examples
134
163
  --------
135
- from label_studio_sdk.client import LabelStudio
164
+ from label_studio_sdk import LabelStudio
136
165
 
137
166
  client = LabelStudio(
138
167
  api_key="YOUR_API_KEY",
@@ -144,7 +173,12 @@ class ViewsClient:
144
173
  _response = self._client_wrapper.httpx_client.request(
145
174
  "api/dm/views/reset/",
146
175
  method="DELETE",
147
- json={"project": project},
176
+ json={
177
+ "project": project,
178
+ },
179
+ headers={
180
+ "content-type": "application/json",
181
+ },
148
182
  request_options=request_options,
149
183
  omit=OMIT,
150
184
  )
@@ -158,6 +192,7 @@ class ViewsClient:
158
192
 
159
193
  def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> View:
160
194
  """
195
+
161
196
  Get the details about a specific Data Manager view (tab). You will need to supply the view ID. You can find this using [List views](list).
162
197
 
163
198
  Parameters
@@ -175,7 +210,7 @@ class ViewsClient:
175
210
 
176
211
  Examples
177
212
  --------
178
- from label_studio_sdk.client import LabelStudio
213
+ from label_studio_sdk import LabelStudio
179
214
 
180
215
  client = LabelStudio(
181
216
  api_key="YOUR_API_KEY",
@@ -185,11 +220,19 @@ class ViewsClient:
185
220
  )
186
221
  """
187
222
  _response = self._client_wrapper.httpx_client.request(
188
- f"api/dm/views/{jsonable_encoder(id)}/", method="GET", request_options=request_options
223
+ f"api/dm/views/{jsonable_encoder(id)}/",
224
+ method="GET",
225
+ request_options=request_options,
189
226
  )
190
227
  try:
191
228
  if 200 <= _response.status_code < 300:
192
- return pydantic_v1.parse_obj_as(View, _response.json()) # type: ignore
229
+ return typing.cast(
230
+ View,
231
+ parse_obj_as(
232
+ type_=View, # type: ignore
233
+ object_=_response.json(),
234
+ ),
235
+ )
193
236
  _response_json = _response.json()
194
237
  except JSONDecodeError:
195
238
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -213,7 +256,7 @@ class ViewsClient:
213
256
 
214
257
  Examples
215
258
  --------
216
- from label_studio_sdk.client import LabelStudio
259
+ from label_studio_sdk import LabelStudio
217
260
 
218
261
  client = LabelStudio(
219
262
  api_key="YOUR_API_KEY",
@@ -223,7 +266,9 @@ class ViewsClient:
223
266
  )
224
267
  """
225
268
  _response = self._client_wrapper.httpx_client.request(
226
- f"api/dm/views/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
269
+ f"api/dm/views/{jsonable_encoder(id)}/",
270
+ method="DELETE",
271
+ request_options=request_options,
227
272
  )
228
273
  try:
229
274
  if 200 <= _response.status_code < 300:
@@ -242,6 +287,7 @@ class ViewsClient:
242
287
  request_options: typing.Optional[RequestOptions] = None,
243
288
  ) -> View:
244
289
  """
290
+
245
291
  You can update a specific Data Manager view (tab) with additional filters and other customizations. You will need to supply the view ID. You can find this using [List views](list).
246
292
 
247
293
  Parameters
@@ -265,7 +311,7 @@ class ViewsClient:
265
311
 
266
312
  Examples
267
313
  --------
268
- from label_studio_sdk.client import LabelStudio
314
+ from label_studio_sdk import LabelStudio
269
315
 
270
316
  client = LabelStudio(
271
317
  api_key="YOUR_API_KEY",
@@ -277,13 +323,27 @@ class ViewsClient:
277
323
  _response = self._client_wrapper.httpx_client.request(
278
324
  f"api/dm/views/{jsonable_encoder(id)}/",
279
325
  method="PATCH",
280
- json={"data": data, "project": project},
326
+ json={
327
+ "data": convert_and_respect_annotation_metadata(
328
+ object_=data, annotation=ViewsUpdateRequestData, direction="write"
329
+ ),
330
+ "project": project,
331
+ },
332
+ headers={
333
+ "content-type": "application/json",
334
+ },
281
335
  request_options=request_options,
282
336
  omit=OMIT,
283
337
  )
284
338
  try:
285
339
  if 200 <= _response.status_code < 300:
286
- return pydantic_v1.parse_obj_as(View, _response.json()) # type: ignore
340
+ return typing.cast(
341
+ View,
342
+ parse_obj_as(
343
+ type_=View, # type: ignore
344
+ object_=_response.json(),
345
+ ),
346
+ )
287
347
  _response_json = _response.json()
288
348
  except JSONDecodeError:
289
349
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -298,6 +358,7 @@ class AsyncViewsClient:
298
358
  self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
299
359
  ) -> typing.List[View]:
300
360
  """
361
+
301
362
  List all views for a specific project. A view is a tab in the Data Manager where you can set filters and customize which tasks and information appears.
302
363
 
303
364
  You will need to provide the project ID. You can find this in the URL when viewing the project in Label Studio, or you can use [List all projects](../projects/list).
@@ -317,19 +378,38 @@ class AsyncViewsClient:
317
378
 
318
379
  Examples
319
380
  --------
320
- from label_studio_sdk.client import AsyncLabelStudio
381
+ import asyncio
382
+
383
+ from label_studio_sdk import AsyncLabelStudio
321
384
 
322
385
  client = AsyncLabelStudio(
323
386
  api_key="YOUR_API_KEY",
324
387
  )
325
- await client.views.list()
388
+
389
+
390
+ async def main() -> None:
391
+ await client.views.list()
392
+
393
+
394
+ asyncio.run(main())
326
395
  """
327
396
  _response = await self._client_wrapper.httpx_client.request(
328
- "api/dm/views/", method="GET", params={"project": project}, request_options=request_options
397
+ "api/dm/views/",
398
+ method="GET",
399
+ params={
400
+ "project": project,
401
+ },
402
+ request_options=request_options,
329
403
  )
330
404
  try:
331
405
  if 200 <= _response.status_code < 300:
332
- return pydantic_v1.parse_obj_as(typing.List[View], _response.json()) # type: ignore
406
+ return typing.cast(
407
+ typing.List[View],
408
+ parse_obj_as(
409
+ type_=typing.List[View], # type: ignore
410
+ object_=_response.json(),
411
+ ),
412
+ )
333
413
  _response_json = _response.json()
334
414
  except JSONDecodeError:
335
415
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -343,6 +423,7 @@ class AsyncViewsClient:
343
423
  request_options: typing.Optional[RequestOptions] = None,
344
424
  ) -> View:
345
425
  """
426
+
346
427
  Create a new Data Manager view for a specific project. A view is a tab in the Data Manager where you can set filters and customize what tasks and information appears.
347
428
 
348
429
  You will need to provide the project ID. You can find this in the URL when viewing the project in Label Studio, or you can use [List all projects](../projects/list).
@@ -365,23 +446,45 @@ class AsyncViewsClient:
365
446
 
366
447
  Examples
367
448
  --------
368
- from label_studio_sdk.client import AsyncLabelStudio
449
+ import asyncio
450
+
451
+ from label_studio_sdk import AsyncLabelStudio
369
452
 
370
453
  client = AsyncLabelStudio(
371
454
  api_key="YOUR_API_KEY",
372
455
  )
373
- await client.views.create()
456
+
457
+
458
+ async def main() -> None:
459
+ await client.views.create()
460
+
461
+
462
+ asyncio.run(main())
374
463
  """
375
464
  _response = await self._client_wrapper.httpx_client.request(
376
465
  "api/dm/views/",
377
466
  method="POST",
378
- json={"data": data, "project": project},
467
+ json={
468
+ "data": convert_and_respect_annotation_metadata(
469
+ object_=data, annotation=ViewsCreateRequestData, direction="write"
470
+ ),
471
+ "project": project,
472
+ },
473
+ headers={
474
+ "content-type": "application/json",
475
+ },
379
476
  request_options=request_options,
380
477
  omit=OMIT,
381
478
  )
382
479
  try:
383
480
  if 200 <= _response.status_code < 300:
384
- return pydantic_v1.parse_obj_as(View, _response.json()) # type: ignore
481
+ return typing.cast(
482
+ View,
483
+ parse_obj_as(
484
+ type_=View, # type: ignore
485
+ object_=_response.json(),
486
+ ),
487
+ )
385
488
  _response_json = _response.json()
386
489
  except JSONDecodeError:
387
490
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -389,6 +492,7 @@ class AsyncViewsClient:
389
492
 
390
493
  async def delete_all(self, *, project: int, request_options: typing.Optional[RequestOptions] = None) -> None:
391
494
  """
495
+
392
496
  Delete all views for a specific project. A view is a tab in the Data Manager where you can set filters and customize what tasks appear.
393
497
 
394
498
  You will need to provide the project ID. You can find this in the URL when viewing the project in Label Studio, or you can use [List all projects](../projects/list).
@@ -406,19 +510,32 @@ class AsyncViewsClient:
406
510
 
407
511
  Examples
408
512
  --------
409
- from label_studio_sdk.client import AsyncLabelStudio
513
+ import asyncio
514
+
515
+ from label_studio_sdk import AsyncLabelStudio
410
516
 
411
517
  client = AsyncLabelStudio(
412
518
  api_key="YOUR_API_KEY",
413
519
  )
414
- await client.views.delete_all(
415
- project=1,
416
- )
520
+
521
+
522
+ async def main() -> None:
523
+ await client.views.delete_all(
524
+ project=1,
525
+ )
526
+
527
+
528
+ asyncio.run(main())
417
529
  """
418
530
  _response = await self._client_wrapper.httpx_client.request(
419
531
  "api/dm/views/reset/",
420
532
  method="DELETE",
421
- json={"project": project},
533
+ json={
534
+ "project": project,
535
+ },
536
+ headers={
537
+ "content-type": "application/json",
538
+ },
422
539
  request_options=request_options,
423
540
  omit=OMIT,
424
541
  )
@@ -432,6 +549,7 @@ class AsyncViewsClient:
432
549
 
433
550
  async def get(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> View:
434
551
  """
552
+
435
553
  Get the details about a specific Data Manager view (tab). You will need to supply the view ID. You can find this using [List views](list).
436
554
 
437
555
  Parameters
@@ -449,21 +567,37 @@ class AsyncViewsClient:
449
567
 
450
568
  Examples
451
569
  --------
452
- from label_studio_sdk.client import AsyncLabelStudio
570
+ import asyncio
571
+
572
+ from label_studio_sdk import AsyncLabelStudio
453
573
 
454
574
  client = AsyncLabelStudio(
455
575
  api_key="YOUR_API_KEY",
456
576
  )
457
- await client.views.get(
458
- id="id",
459
- )
577
+
578
+
579
+ async def main() -> None:
580
+ await client.views.get(
581
+ id="id",
582
+ )
583
+
584
+
585
+ asyncio.run(main())
460
586
  """
461
587
  _response = await self._client_wrapper.httpx_client.request(
462
- f"api/dm/views/{jsonable_encoder(id)}/", method="GET", request_options=request_options
588
+ f"api/dm/views/{jsonable_encoder(id)}/",
589
+ method="GET",
590
+ request_options=request_options,
463
591
  )
464
592
  try:
465
593
  if 200 <= _response.status_code < 300:
466
- return pydantic_v1.parse_obj_as(View, _response.json()) # type: ignore
594
+ return typing.cast(
595
+ View,
596
+ parse_obj_as(
597
+ type_=View, # type: ignore
598
+ object_=_response.json(),
599
+ ),
600
+ )
467
601
  _response_json = _response.json()
468
602
  except JSONDecodeError:
469
603
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -487,17 +621,27 @@ class AsyncViewsClient:
487
621
 
488
622
  Examples
489
623
  --------
490
- from label_studio_sdk.client import AsyncLabelStudio
624
+ import asyncio
625
+
626
+ from label_studio_sdk import AsyncLabelStudio
491
627
 
492
628
  client = AsyncLabelStudio(
493
629
  api_key="YOUR_API_KEY",
494
630
  )
495
- await client.views.delete(
496
- id="id",
497
- )
631
+
632
+
633
+ async def main() -> None:
634
+ await client.views.delete(
635
+ id="id",
636
+ )
637
+
638
+
639
+ asyncio.run(main())
498
640
  """
499
641
  _response = await self._client_wrapper.httpx_client.request(
500
- f"api/dm/views/{jsonable_encoder(id)}/", method="DELETE", request_options=request_options
642
+ f"api/dm/views/{jsonable_encoder(id)}/",
643
+ method="DELETE",
644
+ request_options=request_options,
501
645
  )
502
646
  try:
503
647
  if 200 <= _response.status_code < 300:
@@ -516,6 +660,7 @@ class AsyncViewsClient:
516
660
  request_options: typing.Optional[RequestOptions] = None,
517
661
  ) -> View:
518
662
  """
663
+
519
664
  You can update a specific Data Manager view (tab) with additional filters and other customizations. You will need to supply the view ID. You can find this using [List views](list).
520
665
 
521
666
  Parameters
@@ -539,25 +684,47 @@ class AsyncViewsClient:
539
684
 
540
685
  Examples
541
686
  --------
542
- from label_studio_sdk.client import AsyncLabelStudio
687
+ import asyncio
688
+
689
+ from label_studio_sdk import AsyncLabelStudio
543
690
 
544
691
  client = AsyncLabelStudio(
545
692
  api_key="YOUR_API_KEY",
546
693
  )
547
- await client.views.update(
548
- id="id",
549
- )
694
+
695
+
696
+ async def main() -> None:
697
+ await client.views.update(
698
+ id="id",
699
+ )
700
+
701
+
702
+ asyncio.run(main())
550
703
  """
551
704
  _response = await self._client_wrapper.httpx_client.request(
552
705
  f"api/dm/views/{jsonable_encoder(id)}/",
553
706
  method="PATCH",
554
- json={"data": data, "project": project},
707
+ json={
708
+ "data": convert_and_respect_annotation_metadata(
709
+ object_=data, annotation=ViewsUpdateRequestData, direction="write"
710
+ ),
711
+ "project": project,
712
+ },
713
+ headers={
714
+ "content-type": "application/json",
715
+ },
555
716
  request_options=request_options,
556
717
  omit=OMIT,
557
718
  )
558
719
  try:
559
720
  if 200 <= _response.status_code < 300:
560
- return pydantic_v1.parse_obj_as(View, _response.json()) # type: ignore
721
+ return typing.cast(
722
+ View,
723
+ parse_obj_as(
724
+ type_=View, # type: ignore
725
+ object_=_response.json(),
726
+ ),
727
+ )
561
728
  _response_json = _response.json()
562
729
  except JSONDecodeError:
563
730
  raise ApiError(status_code=_response.status_code, body=_response.text)
@@ -1,43 +1,33 @@
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
-
6
- from ...core.datetime_utils import serialize_datetime
7
- from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
8
5
  from .views_create_request_data_filters import ViewsCreateRequestDataFilters
6
+ import pydantic
9
7
  from .views_create_request_data_ordering_item import ViewsCreateRequestDataOrderingItem
8
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
10
9
 
11
10
 
12
- class ViewsCreateRequestData(pydantic_v1.BaseModel):
11
+ class ViewsCreateRequestData(UniversalBaseModel):
13
12
  """
14
13
  Custom view data
15
14
  """
16
15
 
17
- filters: typing.Optional[ViewsCreateRequestDataFilters] = pydantic_v1.Field(default=None)
16
+ filters: typing.Optional[ViewsCreateRequestDataFilters] = pydantic.Field(default=None)
18
17
  """
19
18
  Filters to apply on tasks. You can use [the helper class `Filters` from this page](https://labelstud.io/sdk/data_manager.html) to create Data Manager Filters.<br>Example: `{"conjunction": "or", "items": [{"filter": "filter:tasks:completed_at", "operator": "greater", "type": "Datetime", "value": "2021-01-01T00:00:00.000Z"}]}`
20
19
  """
21
20
 
22
- ordering: typing.Optional[typing.List[ViewsCreateRequestDataOrderingItem]] = pydantic_v1.Field(default=None)
21
+ ordering: typing.Optional[typing.List[ViewsCreateRequestDataOrderingItem]] = pydantic.Field(default=None)
23
22
  """
24
23
  List of fields to order by. Fields are similar to filters but without the `filter:` prefix. To reverse the order, add a minus sign before the field name, e.g. `-tasks:created_at`.
25
24
  """
26
25
 
27
- def json(self, **kwargs: typing.Any) -> str:
28
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
29
- return super().json(**kwargs_with_defaults)
30
-
31
- def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
32
- kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
33
- kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
34
-
35
- return deep_union_pydantic_dicts(
36
- super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
37
- )
26
+ if IS_PYDANTIC_V2:
27
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
28
+ else:
38
29
 
39
- class Config:
40
- frozen = True
41
- smart_union = True
42
- extra = pydantic_v1.Extra.allow
43
- json_encoders = {dt.datetime: serialize_datetime}
30
+ class Config:
31
+ frozen = True
32
+ smart_union = True
33
+ extra = pydantic.Extra.allow
@@ -1,43 +1,33 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- import datetime as dt
4
- import typing
5
-
6
- from ...core.datetime_utils import serialize_datetime
7
- from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
3
+ from ...core.pydantic_utilities import UniversalBaseModel
8
4
  from .views_create_request_data_filters_conjunction import ViewsCreateRequestDataFiltersConjunction
5
+ import pydantic
6
+ import typing
9
7
  from .views_create_request_data_filters_items_item import ViewsCreateRequestDataFiltersItemsItem
8
+ from ...core.pydantic_utilities import IS_PYDANTIC_V2
10
9
 
11
10
 
12
- class ViewsCreateRequestDataFilters(pydantic_v1.BaseModel):
11
+ class ViewsCreateRequestDataFilters(UniversalBaseModel):
13
12
  """
14
13
  Filters to apply on tasks. You can use [the helper class `Filters` from this page](https://labelstud.io/sdk/data_manager.html) to create Data Manager Filters.<br>Example: `{"conjunction": "or", "items": [{"filter": "filter:tasks:completed_at", "operator": "greater", "type": "Datetime", "value": "2021-01-01T00:00:00.000Z"}]}`
15
14
  """
16
15
 
17
- conjunction: ViewsCreateRequestDataFiltersConjunction = pydantic_v1.Field()
16
+ conjunction: ViewsCreateRequestDataFiltersConjunction = pydantic.Field()
18
17
  """
19
18
  Logical conjunction for the filters. This conjunction (either "or" or "and") will be applied to all items in the filters list. It is not possible to combine "or" and "and" within one list of filters. All filters will be either combined with "or" or with "and", but not a mix of both.
20
19
  """
21
20
 
22
- items: typing.List[ViewsCreateRequestDataFiltersItemsItem] = pydantic_v1.Field()
21
+ items: typing.List[ViewsCreateRequestDataFiltersItemsItem] = pydantic.Field()
23
22
  """
24
23
  List of filter items
25
24
  """
26
25
 
27
- def json(self, **kwargs: typing.Any) -> str:
28
- kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
29
- return super().json(**kwargs_with_defaults)
30
-
31
- def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
32
- kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
33
- kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
34
-
35
- return deep_union_pydantic_dicts(
36
- super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
37
- )
26
+ if IS_PYDANTIC_V2:
27
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
28
+ else:
38
29
 
39
- class Config:
40
- frozen = True
41
- smart_union = True
42
- extra = pydantic_v1.Extra.allow
43
- json_encoders = {dt.datetime: serialize_datetime}
30
+ class Config:
31
+ frozen = True
32
+ smart_union = True
33
+ extra = pydantic.Extra.allow