Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LEAP-1762: Add selectItems support #398

Merged
merged 2 commits into from
Jan 27, 2025
Merged
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
19 changes: 19 additions & 0 deletions .mock/definition/annotations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ service:
body:
properties:
tasks: optional<list<integer>>
selectedItems: optional<AnnotationsCreateBulkRequestSelectedItems>
lead_time: optional<double>
project: optional<integer>
result: optional<map<string, unknown>>
Expand All @@ -464,6 +465,24 @@ service:
source:
openapi: openapi/openapi.yaml
types:
AnnotationsCreateBulkRequestSelectedItems:
properties:
all:
type: optional<boolean>
docs: >
Indicates whether to apply the operation to all tasks. If true, this
overrides any included or excluded lists.
included:
type: optional<list<integer>>
docs: |
An explicit list of task IDs to include.
excluded:
type: optional<list<integer>>
docs: |
An explicit list of task IDs to exclude.
source:
openapi: openapi/openapi.yaml
inline: true
AnnotationsCreateBulkResponseItem:
properties:
id: optional<integer>
Expand Down
8 changes: 8 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,14 @@ client.annotations.create_bulk()
<dl>
<dd>

**selected_items:** `typing.Optional[AnnotationsCreateBulkRequestSelectedItems]`

</dd>
</dl>

<dl>
<dd>

**lead_time:** `typing.Optional[float]`

</dd>
Expand Down
3 changes: 2 additions & 1 deletion src/label_studio_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
ActionsCreateRequestSelectedItemsExcluded,
ActionsCreateRequestSelectedItemsIncluded,
)
from .annotations import AnnotationsCreateBulkResponseItem
from .annotations import AnnotationsCreateBulkRequestSelectedItems, AnnotationsCreateBulkResponseItem
from .client import AsyncLabelStudio, LabelStudio
from .environment import LabelStudioEnvironment
from .export_storage import ExportStorageListTypesResponseItem
Expand Down Expand Up @@ -192,6 +192,7 @@
"Annotation",
"AnnotationFilterOptions",
"AnnotationLastAction",
"AnnotationsCreateBulkRequestSelectedItems",
"AnnotationsCreateBulkResponseItem",
"AnnotationsDmField",
"AnnotationsDmFieldLastAction",
Expand Down
4 changes: 2 additions & 2 deletions src/label_studio_sdk/annotations/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file was auto-generated by Fern from our API Definition.

from .types import AnnotationsCreateBulkResponseItem
from .types import AnnotationsCreateBulkRequestSelectedItems, AnnotationsCreateBulkResponseItem

__all__ = ["AnnotationsCreateBulkResponseItem"]
__all__ = ["AnnotationsCreateBulkRequestSelectedItems", "AnnotationsCreateBulkResponseItem"]
14 changes: 14 additions & 0 deletions src/label_studio_sdk/annotations/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
from ..core.pydantic_utilities import parse_obj_as
from json.decoder import JSONDecodeError
from ..core.api_error import ApiError
from .types.annotations_create_bulk_request_selected_items import AnnotationsCreateBulkRequestSelectedItems
from .types.annotations_create_bulk_response_item import AnnotationsCreateBulkResponseItem
from ..core.serialization import convert_and_respect_annotation_metadata
from ..core.client_wrapper import AsyncClientWrapper

# this is used as the default value for optional parameters
Expand Down Expand Up @@ -427,6 +429,7 @@ def create_bulk(
self,
*,
tasks: typing.Optional[typing.Sequence[int]] = OMIT,
selected_items: typing.Optional[AnnotationsCreateBulkRequestSelectedItems] = OMIT,
lead_time: typing.Optional[float] = OMIT,
project: typing.Optional[int] = OMIT,
result: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
Expand All @@ -439,6 +442,8 @@ def create_bulk(
----------
tasks : typing.Optional[typing.Sequence[int]]
selected_items : typing.Optional[AnnotationsCreateBulkRequestSelectedItems]
lead_time : typing.Optional[float]
project : typing.Optional[int]
Expand Down Expand Up @@ -467,6 +472,9 @@ def create_bulk(
method="POST",
json={
"tasks": tasks,
"selectedItems": convert_and_respect_annotation_metadata(
object_=selected_items, annotation=AnnotationsCreateBulkRequestSelectedItems, direction="write"
),
"lead_time": lead_time,
"project": project,
"result": result,
Expand Down Expand Up @@ -946,6 +954,7 @@ async def create_bulk(
self,
*,
tasks: typing.Optional[typing.Sequence[int]] = OMIT,
selected_items: typing.Optional[AnnotationsCreateBulkRequestSelectedItems] = OMIT,
lead_time: typing.Optional[float] = OMIT,
project: typing.Optional[int] = OMIT,
result: typing.Optional[typing.Dict[str, typing.Optional[typing.Any]]] = OMIT,
Expand All @@ -958,6 +967,8 @@ async def create_bulk(
----------
tasks : typing.Optional[typing.Sequence[int]]
selected_items : typing.Optional[AnnotationsCreateBulkRequestSelectedItems]
lead_time : typing.Optional[float]
project : typing.Optional[int]
Expand Down Expand Up @@ -994,6 +1005,9 @@ async def main() -> None:
method="POST",
json={
"tasks": tasks,
"selectedItems": convert_and_respect_annotation_metadata(
object_=selected_items, annotation=AnnotationsCreateBulkRequestSelectedItems, direction="write"
),
"lead_time": lead_time,
"project": project,
"result": result,
Expand Down
3 changes: 2 additions & 1 deletion src/label_studio_sdk/annotations/types/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# This file was auto-generated by Fern from our API Definition.

from .annotations_create_bulk_request_selected_items import AnnotationsCreateBulkRequestSelectedItems
from .annotations_create_bulk_response_item import AnnotationsCreateBulkResponseItem

__all__ = ["AnnotationsCreateBulkResponseItem"]
__all__ = ["AnnotationsCreateBulkRequestSelectedItems", "AnnotationsCreateBulkResponseItem"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file was auto-generated by Fern from our API Definition.

from ...core.pydantic_utilities import UniversalBaseModel
import typing_extensions
import typing
from ...core.serialization import FieldMetadata
import pydantic
from ...core.pydantic_utilities import IS_PYDANTIC_V2


class AnnotationsCreateBulkRequestSelectedItems(UniversalBaseModel):
all_: typing_extensions.Annotated[typing.Optional[bool], FieldMetadata(alias="all")] = pydantic.Field(default=None)
"""
Indicates whether to apply the operation to all tasks. If true, this overrides any included or excluded lists.
"""

included: typing.Optional[typing.List[int]] = pydantic.Field(default=None)
"""
An explicit list of task IDs to include.
"""

excluded: typing.Optional[typing.List[int]] = pydantic.Field(default=None)
"""
An explicit list of task IDs to exclude.
"""

if IS_PYDANTIC_V2:
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
else:

class Config:
frozen = True
smart_union = True
extra = pydantic.Extra.allow
Loading