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.
- label_studio_sdk/__init__.py +18 -0
- label_studio_sdk/activity_logs/__init__.py +5 -0
- label_studio_sdk/activity_logs/client.py +246 -0
- label_studio_sdk/activity_logs/types/__init__.py +5 -0
- label_studio_sdk/activity_logs/types/activity_logs_list_request_method.py +5 -0
- label_studio_sdk/base_client.py +4 -0
- label_studio_sdk/errors/internal_server_error.py +2 -1
- label_studio_sdk/label_interface/interface.py +0 -4
- label_studio_sdk/ml/client.py +4 -4
- label_studio_sdk/projects/__init__.py +14 -2
- label_studio_sdk/projects/client.py +4 -0
- label_studio_sdk/projects/members/__init__.py +4 -0
- label_studio_sdk/projects/members/bulk/__init__.py +5 -0
- label_studio_sdk/projects/members/bulk/client.py +273 -0
- label_studio_sdk/projects/members/bulk/types/__init__.py +6 -0
- label_studio_sdk/projects/members/bulk/types/bulk_delete_response.py +19 -0
- label_studio_sdk/projects/members/bulk/types/bulk_post_response.py +19 -0
- label_studio_sdk/projects/members/client.py +4 -0
- label_studio_sdk/projects/metrics/__init__.py +6 -0
- label_studio_sdk/projects/metrics/client.py +282 -0
- label_studio_sdk/projects/metrics/custom/__init__.py +5 -0
- label_studio_sdk/projects/metrics/custom/client.py +535 -0
- label_studio_sdk/projects/metrics/custom/types/__init__.py +5 -0
- label_studio_sdk/projects/metrics/custom/types/custom_get_lambda_response.py +19 -0
- label_studio_sdk/projects/stats/__init__.py +18 -2
- label_studio_sdk/projects/stats/client.py +129 -0
- label_studio_sdk/projects/stats/types/__init__.py +12 -1
- label_studio_sdk/projects/stats/types/stats_total_agreement_response.py +7 -0
- label_studio_sdk/projects/stats/types/stats_total_agreement_response_one.py +19 -0
- label_studio_sdk/projects/stats/types/stats_total_agreement_response_zero.py +19 -0
- label_studio_sdk/types/__init__.py +14 -0
- label_studio_sdk/types/activity_log.py +49 -0
- label_studio_sdk/types/activity_log_response.py +28 -0
- label_studio_sdk/types/metric_param.py +31 -0
- label_studio_sdk/types/who_am_i_lse_fields.py +50 -0
- label_studio_sdk/types/who_am_i_lse_fields_onboarding_state.py +8 -0
- label_studio_sdk/types/who_am_i_lse_fields_trial_role.py +8 -0
- label_studio_sdk/types/who_am_i_user.py +49 -0
- label_studio_sdk/users/client.py +9 -8
- label_studio_sdk/workspaces/members/__init__.py +4 -0
- label_studio_sdk/workspaces/members/bulk/__init__.py +5 -0
- label_studio_sdk/workspaces/members/bulk/client.py +273 -0
- label_studio_sdk/workspaces/members/bulk/types/__init__.py +6 -0
- label_studio_sdk/workspaces/members/bulk/types/bulk_delete_response.py +19 -0
- label_studio_sdk/workspaces/members/bulk/types/bulk_post_response.py +19 -0
- label_studio_sdk/workspaces/members/client.py +4 -0
- {label_studio_sdk-2.0.3.dist-info → label_studio_sdk-2.0.5.dist-info}/METADATA +1 -1
- {label_studio_sdk-2.0.3.dist-info → label_studio_sdk-2.0.5.dist-info}/RECORD +50 -20
- {label_studio_sdk-2.0.3.dist-info → label_studio_sdk-2.0.5.dist-info}/LICENSE +0 -0
- {label_studio_sdk-2.0.3.dist-info → label_studio_sdk-2.0.5.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,273 @@
|
|
|
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.bulk_post_response import BulkPostResponse
|
|
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 .types.bulk_delete_response import BulkDeleteResponse
|
|
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 BulkClient:
|
|
19
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
20
|
+
self._client_wrapper = client_wrapper
|
|
21
|
+
|
|
22
|
+
def post(
|
|
23
|
+
self,
|
|
24
|
+
id: int,
|
|
25
|
+
*,
|
|
26
|
+
all_: bool,
|
|
27
|
+
excluded: typing.Optional[typing.Sequence[int]] = OMIT,
|
|
28
|
+
included: typing.Optional[typing.Sequence[int]] = OMIT,
|
|
29
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
30
|
+
) -> BulkPostResponse:
|
|
31
|
+
"""
|
|
32
|
+
Assign project members in bulk.
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
id : int
|
|
37
|
+
|
|
38
|
+
all_ : bool
|
|
39
|
+
|
|
40
|
+
excluded : typing.Optional[typing.Sequence[int]]
|
|
41
|
+
|
|
42
|
+
included : typing.Optional[typing.Sequence[int]]
|
|
43
|
+
|
|
44
|
+
request_options : typing.Optional[RequestOptions]
|
|
45
|
+
Request-specific configuration.
|
|
46
|
+
|
|
47
|
+
Returns
|
|
48
|
+
-------
|
|
49
|
+
BulkPostResponse
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
Examples
|
|
53
|
+
--------
|
|
54
|
+
from label_studio_sdk import LabelStudio
|
|
55
|
+
|
|
56
|
+
client = LabelStudio(
|
|
57
|
+
api_key="YOUR_API_KEY",
|
|
58
|
+
)
|
|
59
|
+
client.projects.members.bulk.post(
|
|
60
|
+
id=1,
|
|
61
|
+
all_=True,
|
|
62
|
+
)
|
|
63
|
+
"""
|
|
64
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
65
|
+
f"api/projects/{jsonable_encoder(id)}/members/bulk/",
|
|
66
|
+
method="POST",
|
|
67
|
+
json={
|
|
68
|
+
"all": all_,
|
|
69
|
+
"excluded": excluded,
|
|
70
|
+
"included": included,
|
|
71
|
+
},
|
|
72
|
+
headers={
|
|
73
|
+
"content-type": "application/json",
|
|
74
|
+
},
|
|
75
|
+
request_options=request_options,
|
|
76
|
+
omit=OMIT,
|
|
77
|
+
)
|
|
78
|
+
try:
|
|
79
|
+
if 200 <= _response.status_code < 300:
|
|
80
|
+
return typing.cast(
|
|
81
|
+
BulkPostResponse,
|
|
82
|
+
construct_type(
|
|
83
|
+
type_=BulkPostResponse, # type: ignore
|
|
84
|
+
object_=_response.json(),
|
|
85
|
+
),
|
|
86
|
+
)
|
|
87
|
+
_response_json = _response.json()
|
|
88
|
+
except JSONDecodeError:
|
|
89
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
90
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
91
|
+
|
|
92
|
+
def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> BulkDeleteResponse:
|
|
93
|
+
"""
|
|
94
|
+
Unassign project members in bulk. Allows the same request body as bulk assign.
|
|
95
|
+
|
|
96
|
+
Parameters
|
|
97
|
+
----------
|
|
98
|
+
id : int
|
|
99
|
+
|
|
100
|
+
request_options : typing.Optional[RequestOptions]
|
|
101
|
+
Request-specific configuration.
|
|
102
|
+
|
|
103
|
+
Returns
|
|
104
|
+
-------
|
|
105
|
+
BulkDeleteResponse
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
Examples
|
|
109
|
+
--------
|
|
110
|
+
from label_studio_sdk import LabelStudio
|
|
111
|
+
|
|
112
|
+
client = LabelStudio(
|
|
113
|
+
api_key="YOUR_API_KEY",
|
|
114
|
+
)
|
|
115
|
+
client.projects.members.bulk.delete(
|
|
116
|
+
id=1,
|
|
117
|
+
)
|
|
118
|
+
"""
|
|
119
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
120
|
+
f"api/projects/{jsonable_encoder(id)}/members/bulk/",
|
|
121
|
+
method="DELETE",
|
|
122
|
+
request_options=request_options,
|
|
123
|
+
)
|
|
124
|
+
try:
|
|
125
|
+
if 200 <= _response.status_code < 300:
|
|
126
|
+
return typing.cast(
|
|
127
|
+
BulkDeleteResponse,
|
|
128
|
+
construct_type(
|
|
129
|
+
type_=BulkDeleteResponse, # type: ignore
|
|
130
|
+
object_=_response.json(),
|
|
131
|
+
),
|
|
132
|
+
)
|
|
133
|
+
_response_json = _response.json()
|
|
134
|
+
except JSONDecodeError:
|
|
135
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
136
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class AsyncBulkClient:
|
|
140
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
141
|
+
self._client_wrapper = client_wrapper
|
|
142
|
+
|
|
143
|
+
async def post(
|
|
144
|
+
self,
|
|
145
|
+
id: int,
|
|
146
|
+
*,
|
|
147
|
+
all_: bool,
|
|
148
|
+
excluded: typing.Optional[typing.Sequence[int]] = OMIT,
|
|
149
|
+
included: typing.Optional[typing.Sequence[int]] = OMIT,
|
|
150
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
151
|
+
) -> BulkPostResponse:
|
|
152
|
+
"""
|
|
153
|
+
Assign project members in bulk.
|
|
154
|
+
|
|
155
|
+
Parameters
|
|
156
|
+
----------
|
|
157
|
+
id : int
|
|
158
|
+
|
|
159
|
+
all_ : bool
|
|
160
|
+
|
|
161
|
+
excluded : typing.Optional[typing.Sequence[int]]
|
|
162
|
+
|
|
163
|
+
included : typing.Optional[typing.Sequence[int]]
|
|
164
|
+
|
|
165
|
+
request_options : typing.Optional[RequestOptions]
|
|
166
|
+
Request-specific configuration.
|
|
167
|
+
|
|
168
|
+
Returns
|
|
169
|
+
-------
|
|
170
|
+
BulkPostResponse
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
Examples
|
|
174
|
+
--------
|
|
175
|
+
import asyncio
|
|
176
|
+
|
|
177
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
178
|
+
|
|
179
|
+
client = AsyncLabelStudio(
|
|
180
|
+
api_key="YOUR_API_KEY",
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
async def main() -> None:
|
|
185
|
+
await client.projects.members.bulk.post(
|
|
186
|
+
id=1,
|
|
187
|
+
all_=True,
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
asyncio.run(main())
|
|
192
|
+
"""
|
|
193
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
194
|
+
f"api/projects/{jsonable_encoder(id)}/members/bulk/",
|
|
195
|
+
method="POST",
|
|
196
|
+
json={
|
|
197
|
+
"all": all_,
|
|
198
|
+
"excluded": excluded,
|
|
199
|
+
"included": included,
|
|
200
|
+
},
|
|
201
|
+
headers={
|
|
202
|
+
"content-type": "application/json",
|
|
203
|
+
},
|
|
204
|
+
request_options=request_options,
|
|
205
|
+
omit=OMIT,
|
|
206
|
+
)
|
|
207
|
+
try:
|
|
208
|
+
if 200 <= _response.status_code < 300:
|
|
209
|
+
return typing.cast(
|
|
210
|
+
BulkPostResponse,
|
|
211
|
+
construct_type(
|
|
212
|
+
type_=BulkPostResponse, # type: ignore
|
|
213
|
+
object_=_response.json(),
|
|
214
|
+
),
|
|
215
|
+
)
|
|
216
|
+
_response_json = _response.json()
|
|
217
|
+
except JSONDecodeError:
|
|
218
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
219
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
220
|
+
|
|
221
|
+
async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> BulkDeleteResponse:
|
|
222
|
+
"""
|
|
223
|
+
Unassign project members in bulk. Allows the same request body as bulk assign.
|
|
224
|
+
|
|
225
|
+
Parameters
|
|
226
|
+
----------
|
|
227
|
+
id : int
|
|
228
|
+
|
|
229
|
+
request_options : typing.Optional[RequestOptions]
|
|
230
|
+
Request-specific configuration.
|
|
231
|
+
|
|
232
|
+
Returns
|
|
233
|
+
-------
|
|
234
|
+
BulkDeleteResponse
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
Examples
|
|
238
|
+
--------
|
|
239
|
+
import asyncio
|
|
240
|
+
|
|
241
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
242
|
+
|
|
243
|
+
client = AsyncLabelStudio(
|
|
244
|
+
api_key="YOUR_API_KEY",
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
async def main() -> None:
|
|
249
|
+
await client.projects.members.bulk.delete(
|
|
250
|
+
id=1,
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
asyncio.run(main())
|
|
255
|
+
"""
|
|
256
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
257
|
+
f"api/projects/{jsonable_encoder(id)}/members/bulk/",
|
|
258
|
+
method="DELETE",
|
|
259
|
+
request_options=request_options,
|
|
260
|
+
)
|
|
261
|
+
try:
|
|
262
|
+
if 200 <= _response.status_code < 300:
|
|
263
|
+
return typing.cast(
|
|
264
|
+
BulkDeleteResponse,
|
|
265
|
+
construct_type(
|
|
266
|
+
type_=BulkDeleteResponse, # type: ignore
|
|
267
|
+
object_=_response.json(),
|
|
268
|
+
),
|
|
269
|
+
)
|
|
270
|
+
_response_json = _response.json()
|
|
271
|
+
except JSONDecodeError:
|
|
272
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
273
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
@@ -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
|
+
import typing
|
|
5
|
+
from .....core.pydantic_utilities import IS_PYDANTIC_V2
|
|
6
|
+
import pydantic
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BulkDeleteResponse(UncheckedBaseModel):
|
|
10
|
+
unassignments: typing.Optional[int] = None
|
|
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
|
|
@@ -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
|
+
import typing
|
|
5
|
+
from .....core.pydantic_utilities import IS_PYDANTIC_V2
|
|
6
|
+
import pydantic
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class BulkPostResponse(UncheckedBaseModel):
|
|
10
|
+
assignments: typing.Optional[int] = None
|
|
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,6 +1,7 @@
|
|
|
1
1
|
# This file was auto-generated by Fern from our API Definition.
|
|
2
2
|
|
|
3
3
|
from ...core.client_wrapper import SyncClientWrapper
|
|
4
|
+
from .bulk.client import BulkClient
|
|
4
5
|
import typing
|
|
5
6
|
from ...core.request_options import RequestOptions
|
|
6
7
|
from ...types.lse_user import LseUser
|
|
@@ -9,11 +10,13 @@ from ...core.unchecked_base_model import construct_type
|
|
|
9
10
|
from json.decoder import JSONDecodeError
|
|
10
11
|
from ...core.api_error import ApiError
|
|
11
12
|
from ...core.client_wrapper import AsyncClientWrapper
|
|
13
|
+
from .bulk.client import AsyncBulkClient
|
|
12
14
|
|
|
13
15
|
|
|
14
16
|
class MembersClient:
|
|
15
17
|
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
16
18
|
self._client_wrapper = client_wrapper
|
|
19
|
+
self.bulk = BulkClient(client_wrapper=self._client_wrapper)
|
|
17
20
|
|
|
18
21
|
def get(
|
|
19
22
|
self, id: int, *, user_ids: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
|
|
@@ -73,6 +76,7 @@ class MembersClient:
|
|
|
73
76
|
class AsyncMembersClient:
|
|
74
77
|
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
75
78
|
self._client_wrapper = client_wrapper
|
|
79
|
+
self.bulk = AsyncBulkClient(client_wrapper=self._client_wrapper)
|
|
76
80
|
|
|
77
81
|
async def get(
|
|
78
82
|
self, id: int, *, user_ids: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
|
|
@@ -0,0 +1,282 @@
|
|
|
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 .custom.client import CustomClient
|
|
6
|
+
from ...core.request_options import RequestOptions
|
|
7
|
+
from ...types.metric_param import MetricParam
|
|
8
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
|
9
|
+
from ...core.unchecked_base_model import construct_type
|
|
10
|
+
from json.decoder import JSONDecodeError
|
|
11
|
+
from ...core.api_error import ApiError
|
|
12
|
+
from ...core.client_wrapper import AsyncClientWrapper
|
|
13
|
+
from .custom.client import AsyncCustomClient
|
|
14
|
+
|
|
15
|
+
# this is used as the default value for optional parameters
|
|
16
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class MetricsClient:
|
|
20
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
21
|
+
self._client_wrapper = client_wrapper
|
|
22
|
+
self.custom = CustomClient(client_wrapper=self._client_wrapper)
|
|
23
|
+
|
|
24
|
+
def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> MetricParam:
|
|
25
|
+
"""
|
|
26
|
+
Get the current metrics configuration for a project.
|
|
27
|
+
|
|
28
|
+
Parameters
|
|
29
|
+
----------
|
|
30
|
+
id : int
|
|
31
|
+
|
|
32
|
+
request_options : typing.Optional[RequestOptions]
|
|
33
|
+
Request-specific configuration.
|
|
34
|
+
|
|
35
|
+
Returns
|
|
36
|
+
-------
|
|
37
|
+
MetricParam
|
|
38
|
+
Current metrics configuration
|
|
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.get(
|
|
48
|
+
id=1,
|
|
49
|
+
)
|
|
50
|
+
"""
|
|
51
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
52
|
+
f"api/projects/{jsonable_encoder(id)}/metricparam/",
|
|
53
|
+
method="GET",
|
|
54
|
+
request_options=request_options,
|
|
55
|
+
)
|
|
56
|
+
try:
|
|
57
|
+
if 200 <= _response.status_code < 300:
|
|
58
|
+
return typing.cast(
|
|
59
|
+
MetricParam,
|
|
60
|
+
construct_type(
|
|
61
|
+
type_=MetricParam, # 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(
|
|
71
|
+
self,
|
|
72
|
+
id: int,
|
|
73
|
+
*,
|
|
74
|
+
additional_params: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
75
|
+
agreement_threshold: typing.Optional[int] = OMIT,
|
|
76
|
+
max_additional_annotators_assignable: typing.Optional[int] = OMIT,
|
|
77
|
+
metric_name: typing.Optional[str] = OMIT,
|
|
78
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
79
|
+
) -> MetricParam:
|
|
80
|
+
"""
|
|
81
|
+
Update metrics strategy and parameters for a project.
|
|
82
|
+
|
|
83
|
+
Parameters
|
|
84
|
+
----------
|
|
85
|
+
id : int
|
|
86
|
+
|
|
87
|
+
additional_params : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
88
|
+
|
|
89
|
+
agreement_threshold : typing.Optional[int]
|
|
90
|
+
|
|
91
|
+
max_additional_annotators_assignable : typing.Optional[int]
|
|
92
|
+
|
|
93
|
+
metric_name : typing.Optional[str]
|
|
94
|
+
|
|
95
|
+
request_options : typing.Optional[RequestOptions]
|
|
96
|
+
Request-specific configuration.
|
|
97
|
+
|
|
98
|
+
Returns
|
|
99
|
+
-------
|
|
100
|
+
MetricParam
|
|
101
|
+
Updated metrics configuration
|
|
102
|
+
|
|
103
|
+
Examples
|
|
104
|
+
--------
|
|
105
|
+
from label_studio_sdk import LabelStudio
|
|
106
|
+
|
|
107
|
+
client = LabelStudio(
|
|
108
|
+
api_key="YOUR_API_KEY",
|
|
109
|
+
)
|
|
110
|
+
client.projects.metrics.update(
|
|
111
|
+
id=1,
|
|
112
|
+
)
|
|
113
|
+
"""
|
|
114
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
115
|
+
f"api/projects/{jsonable_encoder(id)}/metricparam/",
|
|
116
|
+
method="POST",
|
|
117
|
+
json={
|
|
118
|
+
"additional_params": additional_params,
|
|
119
|
+
"agreement_threshold": agreement_threshold,
|
|
120
|
+
"max_additional_annotators_assignable": max_additional_annotators_assignable,
|
|
121
|
+
"metric_name": metric_name,
|
|
122
|
+
},
|
|
123
|
+
headers={
|
|
124
|
+
"content-type": "application/json",
|
|
125
|
+
},
|
|
126
|
+
request_options=request_options,
|
|
127
|
+
omit=OMIT,
|
|
128
|
+
)
|
|
129
|
+
try:
|
|
130
|
+
if 200 <= _response.status_code < 300:
|
|
131
|
+
return typing.cast(
|
|
132
|
+
MetricParam,
|
|
133
|
+
construct_type(
|
|
134
|
+
type_=MetricParam, # type: ignore
|
|
135
|
+
object_=_response.json(),
|
|
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
|
+
|
|
144
|
+
class AsyncMetricsClient:
|
|
145
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
146
|
+
self._client_wrapper = client_wrapper
|
|
147
|
+
self.custom = AsyncCustomClient(client_wrapper=self._client_wrapper)
|
|
148
|
+
|
|
149
|
+
async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> MetricParam:
|
|
150
|
+
"""
|
|
151
|
+
Get the current metrics configuration for a project.
|
|
152
|
+
|
|
153
|
+
Parameters
|
|
154
|
+
----------
|
|
155
|
+
id : int
|
|
156
|
+
|
|
157
|
+
request_options : typing.Optional[RequestOptions]
|
|
158
|
+
Request-specific configuration.
|
|
159
|
+
|
|
160
|
+
Returns
|
|
161
|
+
-------
|
|
162
|
+
MetricParam
|
|
163
|
+
Current metrics configuration
|
|
164
|
+
|
|
165
|
+
Examples
|
|
166
|
+
--------
|
|
167
|
+
import asyncio
|
|
168
|
+
|
|
169
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
170
|
+
|
|
171
|
+
client = AsyncLabelStudio(
|
|
172
|
+
api_key="YOUR_API_KEY",
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
async def main() -> None:
|
|
177
|
+
await client.projects.metrics.get(
|
|
178
|
+
id=1,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
asyncio.run(main())
|
|
183
|
+
"""
|
|
184
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
185
|
+
f"api/projects/{jsonable_encoder(id)}/metricparam/",
|
|
186
|
+
method="GET",
|
|
187
|
+
request_options=request_options,
|
|
188
|
+
)
|
|
189
|
+
try:
|
|
190
|
+
if 200 <= _response.status_code < 300:
|
|
191
|
+
return typing.cast(
|
|
192
|
+
MetricParam,
|
|
193
|
+
construct_type(
|
|
194
|
+
type_=MetricParam, # type: ignore
|
|
195
|
+
object_=_response.json(),
|
|
196
|
+
),
|
|
197
|
+
)
|
|
198
|
+
_response_json = _response.json()
|
|
199
|
+
except JSONDecodeError:
|
|
200
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
201
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
202
|
+
|
|
203
|
+
async def update(
|
|
204
|
+
self,
|
|
205
|
+
id: int,
|
|
206
|
+
*,
|
|
207
|
+
additional_params: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
|
|
208
|
+
agreement_threshold: typing.Optional[int] = OMIT,
|
|
209
|
+
max_additional_annotators_assignable: typing.Optional[int] = OMIT,
|
|
210
|
+
metric_name: typing.Optional[str] = OMIT,
|
|
211
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
212
|
+
) -> MetricParam:
|
|
213
|
+
"""
|
|
214
|
+
Update metrics strategy and parameters for a project.
|
|
215
|
+
|
|
216
|
+
Parameters
|
|
217
|
+
----------
|
|
218
|
+
id : int
|
|
219
|
+
|
|
220
|
+
additional_params : typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]]
|
|
221
|
+
|
|
222
|
+
agreement_threshold : typing.Optional[int]
|
|
223
|
+
|
|
224
|
+
max_additional_annotators_assignable : typing.Optional[int]
|
|
225
|
+
|
|
226
|
+
metric_name : typing.Optional[str]
|
|
227
|
+
|
|
228
|
+
request_options : typing.Optional[RequestOptions]
|
|
229
|
+
Request-specific configuration.
|
|
230
|
+
|
|
231
|
+
Returns
|
|
232
|
+
-------
|
|
233
|
+
MetricParam
|
|
234
|
+
Updated metrics configuration
|
|
235
|
+
|
|
236
|
+
Examples
|
|
237
|
+
--------
|
|
238
|
+
import asyncio
|
|
239
|
+
|
|
240
|
+
from label_studio_sdk import AsyncLabelStudio
|
|
241
|
+
|
|
242
|
+
client = AsyncLabelStudio(
|
|
243
|
+
api_key="YOUR_API_KEY",
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
async def main() -> None:
|
|
248
|
+
await client.projects.metrics.update(
|
|
249
|
+
id=1,
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
|
|
253
|
+
asyncio.run(main())
|
|
254
|
+
"""
|
|
255
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
256
|
+
f"api/projects/{jsonable_encoder(id)}/metricparam/",
|
|
257
|
+
method="POST",
|
|
258
|
+
json={
|
|
259
|
+
"additional_params": additional_params,
|
|
260
|
+
"agreement_threshold": agreement_threshold,
|
|
261
|
+
"max_additional_annotators_assignable": max_additional_annotators_assignable,
|
|
262
|
+
"metric_name": metric_name,
|
|
263
|
+
},
|
|
264
|
+
headers={
|
|
265
|
+
"content-type": "application/json",
|
|
266
|
+
},
|
|
267
|
+
request_options=request_options,
|
|
268
|
+
omit=OMIT,
|
|
269
|
+
)
|
|
270
|
+
try:
|
|
271
|
+
if 200 <= _response.status_code < 300:
|
|
272
|
+
return typing.cast(
|
|
273
|
+
MetricParam,
|
|
274
|
+
construct_type(
|
|
275
|
+
type_=MetricParam, # type: ignore
|
|
276
|
+
object_=_response.json(),
|
|
277
|
+
),
|
|
278
|
+
)
|
|
279
|
+
_response_json = _response.json()
|
|
280
|
+
except JSONDecodeError:
|
|
281
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
282
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|