Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .mock/definition/__package__.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5934,6 +5934,15 @@ types:
user: integer
source:
openapi: openapi/openapi.yaml
ProjectMemberBulkAssignRolesRequest:
properties:
role: Role9E7Enum
user_id:
type: integer
validation:
min: 1
source:
openapi: openapi/openapi.yaml
ProjectReimport:
properties:
annotation_count:
Expand Down
17 changes: 17 additions & 0 deletions .mock/definition/projects/members/bulk.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
imports:
root: ../../__package__.yml
types:
BulkPostResponse:
properties:
Expand Down Expand Up @@ -25,11 +27,18 @@ service:
display-name: Bulk assign project members
request:
name: ProjectMemberBulkAssignRequest
query-parameters:
search:
type: optional<string>
docs: >-
Search term for filtering members by name, email, or username.
Only when all=True.
body:
properties:
all: boolean
excluded: optional<list<integer>>
included: optional<list<integer>>
roles: optional<list<root.ProjectMemberBulkAssignRolesRequest>>
content-type: application/json
response:
docs: ''
Expand All @@ -56,6 +65,14 @@ service:
path-parameters:
id: integer
display-name: Bulk unassign project members
request:
name: BulkDeleteRequest
query-parameters:
search:
type: optional<string>
docs: >-
Search term for filtering members by name, email, or username.
Only when all=True.
response:
docs: ''
type: BulkDeleteResponse
Expand Down
20 changes: 15 additions & 5 deletions .mock/definition/stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,23 @@ service:
method: GET
auth: true
docs: >-
Mean agreement of annotator annotations vs predictions for a specific
model version.
Mean agreement between the given model version and all other model
versions in the project.

Mirrors prediction_per_user_agreement but filtered by
prediction.model_version.

:return: {"average_prediction_agreement_per_model": float[0..1]}
Computed as the average of pairwise model-to-model agreement scores from
PredictionPairStats where either

prediction pair's model_version_from or model_version_to equals the
provided model_version.


When per_label=true, returns a mapping of label -> average agreement
across the same set of pairs.


:return: {"average_prediction_agreement_per_model": float[0..1] |
{label: float[0..1]}}
source:
openapi: openapi/openapi.yaml
path-parameters:
Expand Down
36 changes: 33 additions & 3 deletions .mock/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7386,6 +7386,11 @@ paths:
required: true
schema:
type: integer
- description: Search term for filtering members by name, email, or username. Only when all=True.
in: query
name: search
schema:
type: string
responses:
'200':
content:
Expand Down Expand Up @@ -7417,6 +7422,11 @@ paths:
required: true
schema:
type: integer
- description: Search term for filtering members by name, email, or username. Only when all=True.
in: query
name: search
schema:
type: string
requestBody:
content:
application/json:
Expand Down Expand Up @@ -7664,9 +7674,14 @@ paths:
/api/projects/{id}/model-stats/{model_version}/prediction:
get:
description: |-
Mean agreement of annotator annotations vs predictions for a specific model version.
Mirrors prediction_per_user_agreement but filtered by prediction.model_version.
:return: {"average_prediction_agreement_per_model": float[0..1]}
Mean agreement between the given model version and all other model versions in the project.

Computed as the average of pairwise model-to-model agreement scores from PredictionPairStats where either
prediction pair's model_version_from or model_version_to equals the provided model_version.

When per_label=true, returns a mapping of label -> average agreement across the same set of pairs.

:return: {"average_prediction_agreement_per_model": float[0..1] | {label: float[0..1]}}
operationId: api_projects_model_stats_prediction_retrieve
parameters:
- in: path
Expand Down Expand Up @@ -26012,9 +26027,24 @@ components:
minimum: 1
type: integer
type: array
roles:
items:
$ref: '#/components/schemas/ProjectMemberBulkAssignRolesRequest'
type: array
required:
- all
type: object
ProjectMemberBulkAssignRolesRequest:
properties:
role:
$ref: '#/components/schemas/Role9e7Enum'
user_id:
minimum: 1
type: integer
required:
- role
- user_id
type: object
ProjectMemberRequest:
properties:
user:
Expand Down
24 changes: 24 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -21880,6 +21880,14 @@ client.projects.members.bulk.post(
<dl>
<dd>

**search:** `typing.Optional[str]` — Search term for filtering members by name, email, or username. Only when all=True.

</dd>
</dl>

<dl>
<dd>

**excluded:** `typing.Optional[typing.Sequence[int]]`

</dd>
Expand All @@ -21896,6 +21904,14 @@ client.projects.members.bulk.post(
<dl>
<dd>

**roles:** `typing.Optional[typing.Sequence[ProjectMemberBulkAssignRolesRequest]]`

</dd>
</dl>

<dl>
<dd>

**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.

</dd>
Expand Down Expand Up @@ -21966,6 +21982,14 @@ client.projects.members.bulk.delete(
<dl>
<dd>

**search:** `typing.Optional[str]` — Search term for filtering members by name, email, or username. Only when all=True.

</dd>
</dl>

<dl>
<dd>

**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.

</dd>
Expand Down
2 changes: 2 additions & 0 deletions src/label_studio_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
ProjectImport,
ProjectLabelConfig,
ProjectLabelConfigRequest,
ProjectMemberBulkAssignRolesRequest,
ProjectSampling,
ProjectSkipQueue,
ProjectSubsetEnum,
Expand Down Expand Up @@ -472,6 +473,7 @@
"ProjectImport",
"ProjectLabelConfig",
"ProjectLabelConfigRequest",
"ProjectMemberBulkAssignRolesRequest",
"ProjectSampling",
"ProjectSkipQueue",
"ProjectSubsetEnum",
Expand Down
48 changes: 46 additions & 2 deletions src/label_studio_sdk/projects/members/bulk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import typing
from ....core.client_wrapper import SyncClientWrapper
from ....types.project_member_bulk_assign_roles_request import ProjectMemberBulkAssignRolesRequest
from ....core.request_options import RequestOptions
from .types.bulk_post_response import BulkPostResponse
from ....core.jsonable_encoder import jsonable_encoder
from ....core.serialization import convert_and_respect_annotation_metadata
from ....core.unchecked_base_model import construct_type
from json.decoder import JSONDecodeError
from ....core.api_error import ApiError
Expand All @@ -24,8 +26,10 @@ def post(
id: int,
*,
all_: bool,
search: typing.Optional[str] = None,
excluded: typing.Optional[typing.Sequence[int]] = OMIT,
included: typing.Optional[typing.Sequence[int]] = OMIT,
roles: typing.Optional[typing.Sequence[ProjectMemberBulkAssignRolesRequest]] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> BulkPostResponse:
"""
Expand All @@ -37,10 +41,15 @@ def post(

all_ : bool

search : typing.Optional[str]
Search term for filtering members by name, email, or username. Only when all=True.

excluded : typing.Optional[typing.Sequence[int]]

included : typing.Optional[typing.Sequence[int]]

roles : typing.Optional[typing.Sequence[ProjectMemberBulkAssignRolesRequest]]

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand All @@ -64,10 +73,16 @@ def post(
_response = self._client_wrapper.httpx_client.request(
f"api/projects/{jsonable_encoder(id)}/members/bulk/",
method="POST",
params={
"search": search,
},
json={
"all": all_,
"excluded": excluded,
"included": included,
"roles": convert_and_respect_annotation_metadata(
object_=roles, annotation=typing.Sequence[ProjectMemberBulkAssignRolesRequest], direction="write"
),
},
headers={
"content-type": "application/json",
Expand All @@ -89,14 +104,19 @@ def post(
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> BulkDeleteResponse:
def delete(
self, id: int, *, search: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
) -> BulkDeleteResponse:
"""
Unassign project members in bulk. Allows the same request body as bulk assign.

Parameters
----------
id : int

search : typing.Optional[str]
Search term for filtering members by name, email, or username. Only when all=True.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand All @@ -119,6 +139,9 @@ def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] =
_response = self._client_wrapper.httpx_client.request(
f"api/projects/{jsonable_encoder(id)}/members/bulk/",
method="DELETE",
params={
"search": search,
},
request_options=request_options,
)
try:
Expand All @@ -145,8 +168,10 @@ async def post(
id: int,
*,
all_: bool,
search: typing.Optional[str] = None,
excluded: typing.Optional[typing.Sequence[int]] = OMIT,
included: typing.Optional[typing.Sequence[int]] = OMIT,
roles: typing.Optional[typing.Sequence[ProjectMemberBulkAssignRolesRequest]] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> BulkPostResponse:
"""
Expand All @@ -158,10 +183,15 @@ async def post(

all_ : bool

search : typing.Optional[str]
Search term for filtering members by name, email, or username. Only when all=True.

excluded : typing.Optional[typing.Sequence[int]]

included : typing.Optional[typing.Sequence[int]]

roles : typing.Optional[typing.Sequence[ProjectMemberBulkAssignRolesRequest]]

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -193,10 +223,16 @@ async def main() -> None:
_response = await self._client_wrapper.httpx_client.request(
f"api/projects/{jsonable_encoder(id)}/members/bulk/",
method="POST",
params={
"search": search,
},
json={
"all": all_,
"excluded": excluded,
"included": included,
"roles": convert_and_respect_annotation_metadata(
object_=roles, annotation=typing.Sequence[ProjectMemberBulkAssignRolesRequest], direction="write"
),
},
headers={
"content-type": "application/json",
Expand All @@ -218,14 +254,19 @@ async def main() -> None:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> BulkDeleteResponse:
async def delete(
self, id: int, *, search: typing.Optional[str] = None, request_options: typing.Optional[RequestOptions] = None
) -> BulkDeleteResponse:
"""
Unassign project members in bulk. Allows the same request body as bulk assign.

Parameters
----------
id : int

search : typing.Optional[str]
Search term for filtering members by name, email, or username. Only when all=True.

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Expand Down Expand Up @@ -256,6 +297,9 @@ async def main() -> None:
_response = await self._client_wrapper.httpx_client.request(
f"api/projects/{jsonable_encoder(id)}/members/bulk/",
method="DELETE",
params={
"search": search,
},
request_options=request_options,
)
try:
Expand Down
2 changes: 2 additions & 0 deletions src/label_studio_sdk/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
from .project_import import ProjectImport
from .project_label_config import ProjectLabelConfig
from .project_label_config_request import ProjectLabelConfigRequest
from .project_member_bulk_assign_roles_request import ProjectMemberBulkAssignRolesRequest
from .project_sampling import ProjectSampling
from .project_skip_queue import ProjectSkipQueue
from .project_subset_enum import ProjectSubsetEnum
Expand Down Expand Up @@ -331,6 +332,7 @@
"ProjectImport",
"ProjectLabelConfig",
"ProjectLabelConfigRequest",
"ProjectMemberBulkAssignRolesRequest",
"ProjectSampling",
"ProjectSkipQueue",
"ProjectSubsetEnum",
Expand Down
Loading
Loading