Skip to content
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
1 change: 1 addition & 0 deletions docs/source/superannotate.sdk.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Subsets
______

.. automethod:: superannotate.SAClient.get_subsets
.. automethod:: superannotate.SAClient.add_items_to_subset

----------

Expand Down
77 changes: 77 additions & 0 deletions src/superannotate/lib/app/interface/sdk_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -3044,3 +3044,80 @@ def delete_custom_values(
)
if response.errors:
raise AppException(response.errors)

def add_items_to_subset(
self, project: NotEmptyStr, subset: NotEmptyStr, items: List[dict]
):
"""

Associates selected items with a given subset. Non-existing subset will be automatically created.

:param project: project name (e.g., “project1”)
:type project: str

:param subset: a name of an existing/new subset to associate items with. New subsets will be automatically created.
:type subset: str

:param items: list of items metadata. Required keys are 'name' and 'path'
:type items: list of dicts

Request Example:
::
client = SAClient()

# option 1
queried_items = client.query(
project="Image Project",
query="instance(error = true)"
)

client.add_items_to_subset(
project="Medical Annotations",
subset="Brain Study - Disapproved",
items=queried_items
)

items_list = [
{
'name': 'image_1.jpeg',
'path': 'Image Project'
},
{
'name': 'image_2.jpeg',
'path': 'Image Project/Subfolder A'
}
]

client.add_items_to_subset(
project="Image Project",
subset="Subset Name",
items=items_list

)

Response Example:
::
{
"succeeded": [
{
'name': 'image_1.jpeg',
'path': 'Image Project'
},
{
'name': 'image_2.jpeg',
'path': 'Image Project/Subfolder A'
}
],
"failed": [],
"skipped": []
}
"""

project_name, _ = extract_project_folder(project)

response = self.controller.add_items_to_subset(project_name, subset, items)

if response.errors:
raise AppException(response.errors)

return response.data
1 change: 1 addition & 0 deletions src/superannotate/lib/core/entities/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ class BaseItemEntity(TimedBaseModel):
createdAt: str = Field(description="Date of creation")
updatedAt: str = Field(description="Update date")
custom_metadata: Optional[dict]
id: Optional[int]

class Config:
extra = Extra.allow
Expand Down
Loading