label-studio-sdk 2.0.3__py3-none-any.whl → 2.0.5__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 (50) hide show
  1. label_studio_sdk/__init__.py +18 -0
  2. label_studio_sdk/activity_logs/__init__.py +5 -0
  3. label_studio_sdk/activity_logs/client.py +246 -0
  4. label_studio_sdk/activity_logs/types/__init__.py +5 -0
  5. label_studio_sdk/activity_logs/types/activity_logs_list_request_method.py +5 -0
  6. label_studio_sdk/base_client.py +4 -0
  7. label_studio_sdk/errors/internal_server_error.py +2 -1
  8. label_studio_sdk/label_interface/interface.py +0 -4
  9. label_studio_sdk/ml/client.py +4 -4
  10. label_studio_sdk/projects/__init__.py +14 -2
  11. label_studio_sdk/projects/client.py +4 -0
  12. label_studio_sdk/projects/members/__init__.py +4 -0
  13. label_studio_sdk/projects/members/bulk/__init__.py +5 -0
  14. label_studio_sdk/projects/members/bulk/client.py +273 -0
  15. label_studio_sdk/projects/members/bulk/types/__init__.py +6 -0
  16. label_studio_sdk/projects/members/bulk/types/bulk_delete_response.py +19 -0
  17. label_studio_sdk/projects/members/bulk/types/bulk_post_response.py +19 -0
  18. label_studio_sdk/projects/members/client.py +4 -0
  19. label_studio_sdk/projects/metrics/__init__.py +6 -0
  20. label_studio_sdk/projects/metrics/client.py +282 -0
  21. label_studio_sdk/projects/metrics/custom/__init__.py +5 -0
  22. label_studio_sdk/projects/metrics/custom/client.py +535 -0
  23. label_studio_sdk/projects/metrics/custom/types/__init__.py +5 -0
  24. label_studio_sdk/projects/metrics/custom/types/custom_get_lambda_response.py +19 -0
  25. label_studio_sdk/projects/stats/__init__.py +18 -2
  26. label_studio_sdk/projects/stats/client.py +129 -0
  27. label_studio_sdk/projects/stats/types/__init__.py +12 -1
  28. label_studio_sdk/projects/stats/types/stats_total_agreement_response.py +7 -0
  29. label_studio_sdk/projects/stats/types/stats_total_agreement_response_one.py +19 -0
  30. label_studio_sdk/projects/stats/types/stats_total_agreement_response_zero.py +19 -0
  31. label_studio_sdk/types/__init__.py +14 -0
  32. label_studio_sdk/types/activity_log.py +49 -0
  33. label_studio_sdk/types/activity_log_response.py +28 -0
  34. label_studio_sdk/types/metric_param.py +31 -0
  35. label_studio_sdk/types/who_am_i_lse_fields.py +50 -0
  36. label_studio_sdk/types/who_am_i_lse_fields_onboarding_state.py +8 -0
  37. label_studio_sdk/types/who_am_i_lse_fields_trial_role.py +8 -0
  38. label_studio_sdk/types/who_am_i_user.py +49 -0
  39. label_studio_sdk/users/client.py +9 -8
  40. label_studio_sdk/workspaces/members/__init__.py +4 -0
  41. label_studio_sdk/workspaces/members/bulk/__init__.py +5 -0
  42. label_studio_sdk/workspaces/members/bulk/client.py +273 -0
  43. label_studio_sdk/workspaces/members/bulk/types/__init__.py +6 -0
  44. label_studio_sdk/workspaces/members/bulk/types/bulk_delete_response.py +19 -0
  45. label_studio_sdk/workspaces/members/bulk/types/bulk_post_response.py +19 -0
  46. label_studio_sdk/workspaces/members/client.py +4 -0
  47. {label_studio_sdk-2.0.3.dist-info → label_studio_sdk-2.0.5.dist-info}/METADATA +1 -1
  48. {label_studio_sdk-2.0.3.dist-info → label_studio_sdk-2.0.5.dist-info}/RECORD +50 -20
  49. {label_studio_sdk-2.0.3.dist-info → label_studio_sdk-2.0.5.dist-info}/LICENSE +0 -0
  50. {label_studio_sdk-2.0.3.dist-info → label_studio_sdk-2.0.5.dist-info}/WHEEL +0 -0
@@ -0,0 +1,535 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+ from ....core.client_wrapper import SyncClientWrapper
5
+ from ....core.request_options import RequestOptions
6
+ from .types.custom_get_lambda_response import CustomGetLambdaResponse
7
+ from ....core.jsonable_encoder import jsonable_encoder
8
+ from ....core.unchecked_base_model import construct_type
9
+ from json.decoder import JSONDecodeError
10
+ from ....core.api_error import ApiError
11
+ from ....errors.internal_server_error import InternalServerError
12
+ from ....core.client_wrapper import AsyncClientWrapper
13
+
14
+ # this is used as the default value for optional parameters
15
+ OMIT = typing.cast(typing.Any, ...)
16
+
17
+
18
+ class CustomClient:
19
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
20
+ self._client_wrapper = client_wrapper
21
+
22
+ def get_lambda(
23
+ self, id: int, *, request_options: typing.Optional[RequestOptions] = None
24
+ ) -> CustomGetLambdaResponse:
25
+ """
26
+ Get the AWS Lambda code for the custom metric configured for this project.
27
+
28
+ Parameters
29
+ ----------
30
+ id : int
31
+
32
+ request_options : typing.Optional[RequestOptions]
33
+ Request-specific configuration.
34
+
35
+ Returns
36
+ -------
37
+ CustomGetLambdaResponse
38
+ Lambda code
39
+
40
+ Examples
41
+ --------
42
+ from label_studio_sdk import LabelStudio
43
+
44
+ client = LabelStudio(
45
+ api_key="YOUR_API_KEY",
46
+ )
47
+ client.projects.metrics.custom.get_lambda(
48
+ id=1,
49
+ )
50
+ """
51
+ _response = self._client_wrapper.httpx_client.request(
52
+ f"api/projects/{jsonable_encoder(id)}/aws-custom-function",
53
+ method="GET",
54
+ request_options=request_options,
55
+ )
56
+ try:
57
+ if 200 <= _response.status_code < 300:
58
+ return typing.cast(
59
+ CustomGetLambdaResponse,
60
+ construct_type(
61
+ type_=CustomGetLambdaResponse, # type: ignore
62
+ object_=_response.json(),
63
+ ),
64
+ )
65
+ _response_json = _response.json()
66
+ except JSONDecodeError:
67
+ raise ApiError(status_code=_response.status_code, body=_response.text)
68
+ raise ApiError(status_code=_response.status_code, body=_response_json)
69
+
70
+ def update_lambda(
71
+ self,
72
+ id: int,
73
+ *,
74
+ code: str,
75
+ region: typing.Optional[str] = OMIT,
76
+ role: typing.Optional[str] = OMIT,
77
+ request_options: typing.Optional[RequestOptions] = None,
78
+ ) -> None:
79
+ """
80
+ Create or update the AWS Lambda function used for custom metrics in this project.
81
+
82
+ Parameters
83
+ ----------
84
+ id : int
85
+
86
+ code : str
87
+
88
+ region : typing.Optional[str]
89
+
90
+ role : typing.Optional[str]
91
+
92
+ request_options : typing.Optional[RequestOptions]
93
+ Request-specific configuration.
94
+
95
+ Returns
96
+ -------
97
+ None
98
+
99
+ Examples
100
+ --------
101
+ from label_studio_sdk import LabelStudio
102
+
103
+ client = LabelStudio(
104
+ api_key="YOUR_API_KEY",
105
+ )
106
+ client.projects.metrics.custom.update_lambda(
107
+ id=1,
108
+ code="code",
109
+ )
110
+ """
111
+ _response = self._client_wrapper.httpx_client.request(
112
+ f"api/projects/{jsonable_encoder(id)}/aws-custom-function",
113
+ method="POST",
114
+ json={
115
+ "code": code,
116
+ "region": region,
117
+ "role": role,
118
+ },
119
+ headers={
120
+ "content-type": "application/json",
121
+ },
122
+ request_options=request_options,
123
+ omit=OMIT,
124
+ )
125
+ try:
126
+ if 200 <= _response.status_code < 300:
127
+ return
128
+ if _response.status_code == 500:
129
+ raise InternalServerError(
130
+ typing.cast(
131
+ typing.Optional[typing.Any],
132
+ construct_type(
133
+ type_=typing.Optional[typing.Any], # type: ignore
134
+ object_=_response.json(),
135
+ ),
136
+ )
137
+ )
138
+ _response_json = _response.json()
139
+ except JSONDecodeError:
140
+ raise ApiError(status_code=_response.status_code, body=_response.text)
141
+ raise ApiError(status_code=_response.status_code, body=_response_json)
142
+
143
+ def logs(
144
+ self,
145
+ id: int,
146
+ *,
147
+ end_date: typing.Optional[str] = None,
148
+ limit: typing.Optional[int] = None,
149
+ start_date: typing.Optional[str] = None,
150
+ request_options: typing.Optional[RequestOptions] = None,
151
+ ) -> typing.Dict[str, typing.Optional[typing.Any]]:
152
+ """
153
+ Get AWS lambda logs for project, including filtering by start and end dates
154
+
155
+ Parameters
156
+ ----------
157
+ id : int
158
+
159
+ end_date : typing.Optional[str]
160
+ End date for AWS logs filtering in format %Y-%m-%d
161
+
162
+ limit : typing.Optional[int]
163
+ Limit the number of logs to return
164
+
165
+ start_date : typing.Optional[str]
166
+ Start date for AWS logs filtering in format %Y-%m-%d
167
+
168
+ request_options : typing.Optional[RequestOptions]
169
+ Request-specific configuration.
170
+
171
+ Returns
172
+ -------
173
+ typing.Dict[str, typing.Optional[typing.Any]]
174
+ Successful response returns list of AWS lambda logs
175
+
176
+ Examples
177
+ --------
178
+ from label_studio_sdk import LabelStudio
179
+
180
+ client = LabelStudio(
181
+ api_key="YOUR_API_KEY",
182
+ )
183
+ client.projects.metrics.custom.logs(
184
+ id=1,
185
+ )
186
+ """
187
+ _response = self._client_wrapper.httpx_client.request(
188
+ f"api/projects/{jsonable_encoder(id)}/aws-custom-function-logs",
189
+ method="GET",
190
+ params={
191
+ "end_date": end_date,
192
+ "limit": limit,
193
+ "start_date": start_date,
194
+ },
195
+ request_options=request_options,
196
+ )
197
+ try:
198
+ if 200 <= _response.status_code < 300:
199
+ return typing.cast(
200
+ typing.Dict[str, typing.Optional[typing.Any]],
201
+ construct_type(
202
+ type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore
203
+ object_=_response.json(),
204
+ ),
205
+ )
206
+ _response_json = _response.json()
207
+ except JSONDecodeError:
208
+ raise ApiError(status_code=_response.status_code, body=_response.text)
209
+ raise ApiError(status_code=_response.status_code, body=_response_json)
210
+
211
+ def check_function(self, id: int, *, code: str, request_options: typing.Optional[RequestOptions] = None) -> None:
212
+ """
213
+ Validate custom matching function code for the project.
214
+
215
+ Parameters
216
+ ----------
217
+ id : int
218
+
219
+ code : str
220
+
221
+ request_options : typing.Optional[RequestOptions]
222
+ Request-specific configuration.
223
+
224
+ Returns
225
+ -------
226
+ None
227
+
228
+ Examples
229
+ --------
230
+ from label_studio_sdk import LabelStudio
231
+
232
+ client = LabelStudio(
233
+ api_key="YOUR_API_KEY",
234
+ )
235
+ client.projects.metrics.custom.check_function(
236
+ id=1,
237
+ code="code",
238
+ )
239
+ """
240
+ _response = self._client_wrapper.httpx_client.request(
241
+ f"api/projects/{jsonable_encoder(id)}/check-function",
242
+ method="POST",
243
+ json={
244
+ "code": code,
245
+ },
246
+ headers={
247
+ "content-type": "application/json",
248
+ },
249
+ request_options=request_options,
250
+ omit=OMIT,
251
+ )
252
+ try:
253
+ if 200 <= _response.status_code < 300:
254
+ return
255
+ _response_json = _response.json()
256
+ except JSONDecodeError:
257
+ raise ApiError(status_code=_response.status_code, body=_response.text)
258
+ raise ApiError(status_code=_response.status_code, body=_response_json)
259
+
260
+
261
+ class AsyncCustomClient:
262
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
263
+ self._client_wrapper = client_wrapper
264
+
265
+ async def get_lambda(
266
+ self, id: int, *, request_options: typing.Optional[RequestOptions] = None
267
+ ) -> CustomGetLambdaResponse:
268
+ """
269
+ Get the AWS Lambda code for the custom metric configured for this project.
270
+
271
+ Parameters
272
+ ----------
273
+ id : int
274
+
275
+ request_options : typing.Optional[RequestOptions]
276
+ Request-specific configuration.
277
+
278
+ Returns
279
+ -------
280
+ CustomGetLambdaResponse
281
+ Lambda code
282
+
283
+ Examples
284
+ --------
285
+ import asyncio
286
+
287
+ from label_studio_sdk import AsyncLabelStudio
288
+
289
+ client = AsyncLabelStudio(
290
+ api_key="YOUR_API_KEY",
291
+ )
292
+
293
+
294
+ async def main() -> None:
295
+ await client.projects.metrics.custom.get_lambda(
296
+ id=1,
297
+ )
298
+
299
+
300
+ asyncio.run(main())
301
+ """
302
+ _response = await self._client_wrapper.httpx_client.request(
303
+ f"api/projects/{jsonable_encoder(id)}/aws-custom-function",
304
+ method="GET",
305
+ request_options=request_options,
306
+ )
307
+ try:
308
+ if 200 <= _response.status_code < 300:
309
+ return typing.cast(
310
+ CustomGetLambdaResponse,
311
+ construct_type(
312
+ type_=CustomGetLambdaResponse, # type: ignore
313
+ object_=_response.json(),
314
+ ),
315
+ )
316
+ _response_json = _response.json()
317
+ except JSONDecodeError:
318
+ raise ApiError(status_code=_response.status_code, body=_response.text)
319
+ raise ApiError(status_code=_response.status_code, body=_response_json)
320
+
321
+ async def update_lambda(
322
+ self,
323
+ id: int,
324
+ *,
325
+ code: str,
326
+ region: typing.Optional[str] = OMIT,
327
+ role: typing.Optional[str] = OMIT,
328
+ request_options: typing.Optional[RequestOptions] = None,
329
+ ) -> None:
330
+ """
331
+ Create or update the AWS Lambda function used for custom metrics in this project.
332
+
333
+ Parameters
334
+ ----------
335
+ id : int
336
+
337
+ code : str
338
+
339
+ region : typing.Optional[str]
340
+
341
+ role : typing.Optional[str]
342
+
343
+ request_options : typing.Optional[RequestOptions]
344
+ Request-specific configuration.
345
+
346
+ Returns
347
+ -------
348
+ None
349
+
350
+ Examples
351
+ --------
352
+ import asyncio
353
+
354
+ from label_studio_sdk import AsyncLabelStudio
355
+
356
+ client = AsyncLabelStudio(
357
+ api_key="YOUR_API_KEY",
358
+ )
359
+
360
+
361
+ async def main() -> None:
362
+ await client.projects.metrics.custom.update_lambda(
363
+ id=1,
364
+ code="code",
365
+ )
366
+
367
+
368
+ asyncio.run(main())
369
+ """
370
+ _response = await self._client_wrapper.httpx_client.request(
371
+ f"api/projects/{jsonable_encoder(id)}/aws-custom-function",
372
+ method="POST",
373
+ json={
374
+ "code": code,
375
+ "region": region,
376
+ "role": role,
377
+ },
378
+ headers={
379
+ "content-type": "application/json",
380
+ },
381
+ request_options=request_options,
382
+ omit=OMIT,
383
+ )
384
+ try:
385
+ if 200 <= _response.status_code < 300:
386
+ return
387
+ if _response.status_code == 500:
388
+ raise InternalServerError(
389
+ typing.cast(
390
+ typing.Optional[typing.Any],
391
+ construct_type(
392
+ type_=typing.Optional[typing.Any], # type: ignore
393
+ object_=_response.json(),
394
+ ),
395
+ )
396
+ )
397
+ _response_json = _response.json()
398
+ except JSONDecodeError:
399
+ raise ApiError(status_code=_response.status_code, body=_response.text)
400
+ raise ApiError(status_code=_response.status_code, body=_response_json)
401
+
402
+ async def logs(
403
+ self,
404
+ id: int,
405
+ *,
406
+ end_date: typing.Optional[str] = None,
407
+ limit: typing.Optional[int] = None,
408
+ start_date: typing.Optional[str] = None,
409
+ request_options: typing.Optional[RequestOptions] = None,
410
+ ) -> typing.Dict[str, typing.Optional[typing.Any]]:
411
+ """
412
+ Get AWS lambda logs for project, including filtering by start and end dates
413
+
414
+ Parameters
415
+ ----------
416
+ id : int
417
+
418
+ end_date : typing.Optional[str]
419
+ End date for AWS logs filtering in format %Y-%m-%d
420
+
421
+ limit : typing.Optional[int]
422
+ Limit the number of logs to return
423
+
424
+ start_date : typing.Optional[str]
425
+ Start date for AWS logs filtering in format %Y-%m-%d
426
+
427
+ request_options : typing.Optional[RequestOptions]
428
+ Request-specific configuration.
429
+
430
+ Returns
431
+ -------
432
+ typing.Dict[str, typing.Optional[typing.Any]]
433
+ Successful response returns list of AWS lambda logs
434
+
435
+ Examples
436
+ --------
437
+ import asyncio
438
+
439
+ from label_studio_sdk import AsyncLabelStudio
440
+
441
+ client = AsyncLabelStudio(
442
+ api_key="YOUR_API_KEY",
443
+ )
444
+
445
+
446
+ async def main() -> None:
447
+ await client.projects.metrics.custom.logs(
448
+ id=1,
449
+ )
450
+
451
+
452
+ asyncio.run(main())
453
+ """
454
+ _response = await self._client_wrapper.httpx_client.request(
455
+ f"api/projects/{jsonable_encoder(id)}/aws-custom-function-logs",
456
+ method="GET",
457
+ params={
458
+ "end_date": end_date,
459
+ "limit": limit,
460
+ "start_date": start_date,
461
+ },
462
+ request_options=request_options,
463
+ )
464
+ try:
465
+ if 200 <= _response.status_code < 300:
466
+ return typing.cast(
467
+ typing.Dict[str, typing.Optional[typing.Any]],
468
+ construct_type(
469
+ type_=typing.Dict[str, typing.Optional[typing.Any]], # type: ignore
470
+ object_=_response.json(),
471
+ ),
472
+ )
473
+ _response_json = _response.json()
474
+ except JSONDecodeError:
475
+ raise ApiError(status_code=_response.status_code, body=_response.text)
476
+ raise ApiError(status_code=_response.status_code, body=_response_json)
477
+
478
+ async def check_function(
479
+ self, id: int, *, code: str, request_options: typing.Optional[RequestOptions] = None
480
+ ) -> None:
481
+ """
482
+ Validate custom matching function code for the project.
483
+
484
+ Parameters
485
+ ----------
486
+ id : int
487
+
488
+ code : str
489
+
490
+ request_options : typing.Optional[RequestOptions]
491
+ Request-specific configuration.
492
+
493
+ Returns
494
+ -------
495
+ None
496
+
497
+ Examples
498
+ --------
499
+ import asyncio
500
+
501
+ from label_studio_sdk import AsyncLabelStudio
502
+
503
+ client = AsyncLabelStudio(
504
+ api_key="YOUR_API_KEY",
505
+ )
506
+
507
+
508
+ async def main() -> None:
509
+ await client.projects.metrics.custom.check_function(
510
+ id=1,
511
+ code="code",
512
+ )
513
+
514
+
515
+ asyncio.run(main())
516
+ """
517
+ _response = await self._client_wrapper.httpx_client.request(
518
+ f"api/projects/{jsonable_encoder(id)}/check-function",
519
+ method="POST",
520
+ json={
521
+ "code": code,
522
+ },
523
+ headers={
524
+ "content-type": "application/json",
525
+ },
526
+ request_options=request_options,
527
+ omit=OMIT,
528
+ )
529
+ try:
530
+ if 200 <= _response.status_code < 300:
531
+ return
532
+ _response_json = _response.json()
533
+ except JSONDecodeError:
534
+ raise ApiError(status_code=_response.status_code, body=_response.text)
535
+ raise ApiError(status_code=_response.status_code, body=_response_json)
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .custom_get_lambda_response import CustomGetLambdaResponse
4
+
5
+ __all__ = ["CustomGetLambdaResponse"]
@@ -0,0 +1,19 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .....core.unchecked_base_model import UncheckedBaseModel
4
+ from .....core.pydantic_utilities import IS_PYDANTIC_V2
5
+ import typing
6
+ import pydantic
7
+
8
+
9
+ class CustomGetLambdaResponse(UncheckedBaseModel):
10
+ code: str
11
+
12
+ if IS_PYDANTIC_V2:
13
+ model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
14
+ else:
15
+
16
+ class Config:
17
+ frozen = True
18
+ smart_union = True
19
+ extra = pydantic.Extra.allow
@@ -1,5 +1,21 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
- from .types import StatsIaaResponse, StatsIaaResponseCommonTasks, StatsIaaResponseIaa, StatsIaaResponseStd
3
+ from .types import (
4
+ StatsIaaResponse,
5
+ StatsIaaResponseCommonTasks,
6
+ StatsIaaResponseIaa,
7
+ StatsIaaResponseStd,
8
+ StatsTotalAgreementResponse,
9
+ StatsTotalAgreementResponseOne,
10
+ StatsTotalAgreementResponseZero,
11
+ )
4
12
 
5
- __all__ = ["StatsIaaResponse", "StatsIaaResponseCommonTasks", "StatsIaaResponseIaa", "StatsIaaResponseStd"]
13
+ __all__ = [
14
+ "StatsIaaResponse",
15
+ "StatsIaaResponseCommonTasks",
16
+ "StatsIaaResponseIaa",
17
+ "StatsIaaResponseStd",
18
+ "StatsTotalAgreementResponse",
19
+ "StatsTotalAgreementResponseOne",
20
+ "StatsTotalAgreementResponseZero",
21
+ ]