Skip to content

Commit 68c4372

Browse files
fix: PLT-1018: Change http method for bulk deletion api (#762)
Co-authored-by: fern-api[bot] <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 15e5849 commit 68c4372

3 files changed

Lines changed: 301 additions & 238 deletions

File tree

reference.md

Lines changed: 79 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,85 @@ client.annotation_reviews.update(
919919
</details>
920920

921921
## Annotations
922+
<details><summary><code>client.annotations.<a href="src/label_studio_sdk/annotations/client.py">delete_bulk</a>(...) -&gt; AsyncHttpResponse[DeleteBulkAnnotationsResponse]</code></summary>
923+
<dl>
924+
<dd>
925+
926+
#### 📝 Description
927+
928+
<dl>
929+
<dd>
930+
931+
<dl>
932+
<dd>
933+
934+
Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response.
935+
</dd>
936+
</dl>
937+
</dd>
938+
</dl>
939+
940+
#### 🔌 Usage
941+
942+
<dl>
943+
<dd>
944+
945+
<dl>
946+
<dd>
947+
948+
```python
949+
from label_studio_sdk import LabelStudio
950+
951+
client = LabelStudio(
952+
api_key="YOUR_API_KEY",
953+
)
954+
client.annotations.delete_bulk(
955+
ids=[1],
956+
project=1,
957+
)
958+
959+
```
960+
</dd>
961+
</dl>
962+
</dd>
963+
</dl>
964+
965+
#### ⚙️ Parameters
966+
967+
<dl>
968+
<dd>
969+
970+
<dl>
971+
<dd>
972+
973+
**ids:** `typing.Sequence[int]` — List of annotation IDs to delete
974+
975+
</dd>
976+
</dl>
977+
978+
<dl>
979+
<dd>
980+
981+
**project:** `int`
982+
983+
</dd>
984+
</dl>
985+
986+
<dl>
987+
<dd>
988+
989+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
990+
991+
</dd>
992+
</dl>
993+
</dd>
994+
</dl>
995+
996+
997+
</dd>
998+
</dl>
999+
</details>
1000+
9221001
<details><summary><code>client.annotations.<a href="src/label_studio_sdk/annotations/client.py">create_bulk</a>(...) -&gt; AsyncHttpResponse[typing.List[CreateBulkAnnotationsResponseItem]]</code></summary>
9231002
<dl>
9241003
<dd>
@@ -1132,66 +1211,6 @@ Action which was performed in the last annotation history item
11321211
</dl>
11331212

11341213

1135-
</dd>
1136-
</dl>
1137-
</details>
1138-
1139-
<details><summary><code>client.annotations.<a href="src/label_studio_sdk/annotations/client.py">delete_bulk</a>() -&gt; AsyncHttpResponse[DeleteBulkAnnotationsResponse]</code></summary>
1140-
<dl>
1141-
<dd>
1142-
1143-
#### 📝 Description
1144-
1145-
<dl>
1146-
<dd>
1147-
1148-
<dl>
1149-
<dd>
1150-
1151-
Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response.
1152-
</dd>
1153-
</dl>
1154-
</dd>
1155-
</dl>
1156-
1157-
#### 🔌 Usage
1158-
1159-
<dl>
1160-
<dd>
1161-
1162-
<dl>
1163-
<dd>
1164-
1165-
```python
1166-
from label_studio_sdk import LabelStudio
1167-
1168-
client = LabelStudio(
1169-
api_key="YOUR_API_KEY",
1170-
)
1171-
client.annotations.delete_bulk()
1172-
1173-
```
1174-
</dd>
1175-
</dl>
1176-
</dd>
1177-
</dl>
1178-
1179-
#### ⚙️ Parameters
1180-
1181-
<dl>
1182-
<dd>
1183-
1184-
<dl>
1185-
<dd>
1186-
1187-
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
1188-
1189-
</dd>
1190-
</dl>
1191-
</dd>
1192-
</dl>
1193-
1194-
11951214
</dd>
11961215
</dl>
11971216
</details>

src/label_studio_sdk/annotations/client.py

Lines changed: 80 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,42 @@ def with_raw_response(self) -> RawAnnotationsClient:
3131
"""
3232
return self._raw_client
3333

34+
def delete_bulk(
35+
self, *, ids: typing.Sequence[int], project: int, request_options: typing.Optional[RequestOptions] = None
36+
) -> DeleteBulkAnnotationsResponse:
37+
"""
38+
Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response.
39+
40+
Parameters
41+
----------
42+
ids : typing.Sequence[int]
43+
List of annotation IDs to delete
44+
45+
project : int
46+
47+
request_options : typing.Optional[RequestOptions]
48+
Request-specific configuration.
49+
50+
Returns
51+
-------
52+
DeleteBulkAnnotationsResponse
53+
Annotations deleted successfully
54+
55+
Examples
56+
--------
57+
from label_studio_sdk import LabelStudio
58+
59+
client = LabelStudio(
60+
api_key="YOUR_API_KEY",
61+
)
62+
client.annotations.delete_bulk(
63+
ids=[1],
64+
project=1,
65+
)
66+
"""
67+
_response = self._raw_client.delete_bulk(ids=ids, project=project, request_options=request_options)
68+
return _response.data
69+
3470
def create_bulk(
3571
self,
3672
*,
@@ -160,32 +196,6 @@ def create_bulk(
160196
)
161197
return _response.data
162198

163-
def delete_bulk(self, *, request_options: typing.Optional[RequestOptions] = None) -> DeleteBulkAnnotationsResponse:
164-
"""
165-
Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response.
166-
167-
Parameters
168-
----------
169-
request_options : typing.Optional[RequestOptions]
170-
Request-specific configuration.
171-
172-
Returns
173-
-------
174-
DeleteBulkAnnotationsResponse
175-
Annotations deleted successfully
176-
177-
Examples
178-
--------
179-
from label_studio_sdk import LabelStudio
180-
181-
client = LabelStudio(
182-
api_key="YOUR_API_KEY",
183-
)
184-
client.annotations.delete_bulk()
185-
"""
186-
_response = self._raw_client.delete_bulk(request_options=request_options)
187-
return _response.data
188-
189199
def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Annotation:
190200
"""
191201
Retrieve a specific annotation for a task using the annotation result ID.
@@ -509,6 +519,50 @@ def with_raw_response(self) -> AsyncRawAnnotationsClient:
509519
"""
510520
return self._raw_client
511521

522+
async def delete_bulk(
523+
self, *, ids: typing.Sequence[int], project: int, request_options: typing.Optional[RequestOptions] = None
524+
) -> DeleteBulkAnnotationsResponse:
525+
"""
526+
Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response.
527+
528+
Parameters
529+
----------
530+
ids : typing.Sequence[int]
531+
List of annotation IDs to delete
532+
533+
project : int
534+
535+
request_options : typing.Optional[RequestOptions]
536+
Request-specific configuration.
537+
538+
Returns
539+
-------
540+
DeleteBulkAnnotationsResponse
541+
Annotations deleted successfully
542+
543+
Examples
544+
--------
545+
import asyncio
546+
547+
from label_studio_sdk import AsyncLabelStudio
548+
549+
client = AsyncLabelStudio(
550+
api_key="YOUR_API_KEY",
551+
)
552+
553+
554+
async def main() -> None:
555+
await client.annotations.delete_bulk(
556+
ids=[1],
557+
project=1,
558+
)
559+
560+
561+
asyncio.run(main())
562+
"""
563+
_response = await self._raw_client.delete_bulk(ids=ids, project=project, request_options=request_options)
564+
return _response.data
565+
512566
async def create_bulk(
513567
self,
514568
*,
@@ -646,42 +700,6 @@ async def main() -> None:
646700
)
647701
return _response.data
648702

649-
async def delete_bulk(
650-
self, *, request_options: typing.Optional[RequestOptions] = None
651-
) -> DeleteBulkAnnotationsResponse:
652-
"""
653-
Delete multiple annotations by their IDs. The deletion is processed synchronously. Returns the count of deleted annotations in the response.
654-
655-
Parameters
656-
----------
657-
request_options : typing.Optional[RequestOptions]
658-
Request-specific configuration.
659-
660-
Returns
661-
-------
662-
DeleteBulkAnnotationsResponse
663-
Annotations deleted successfully
664-
665-
Examples
666-
--------
667-
import asyncio
668-
669-
from label_studio_sdk import AsyncLabelStudio
670-
671-
client = AsyncLabelStudio(
672-
api_key="YOUR_API_KEY",
673-
)
674-
675-
676-
async def main() -> None:
677-
await client.annotations.delete_bulk()
678-
679-
680-
asyncio.run(main())
681-
"""
682-
_response = await self._raw_client.delete_bulk(request_options=request_options)
683-
return _response.data
684-
685703
async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> Annotation:
686704
"""
687705
Retrieve a specific annotation for a task using the annotation result ID.

0 commit comments

Comments
 (0)