label-studio-sdk 1.0.0__py3-none-any.whl → 1.0.2__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.
Files changed (99) hide show
  1. label_studio_sdk/__init__.py +46 -4
  2. label_studio_sdk/_extensions/pager_ext.py +49 -0
  3. label_studio_sdk/_legacy/schema/label_config_schema.json +14 -14
  4. label_studio_sdk/actions/__init__.py +27 -0
  5. label_studio_sdk/actions/client.py +129 -8
  6. label_studio_sdk/actions/types/__init__.py +27 -0
  7. label_studio_sdk/actions/types/actions_create_request_filters.py +43 -0
  8. label_studio_sdk/actions/types/actions_create_request_filters_conjunction.py +5 -0
  9. label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +50 -0
  10. label_studio_sdk/actions/types/actions_create_request_filters_items_item_filter.py +31 -0
  11. label_studio_sdk/actions/types/actions_create_request_filters_items_item_operator.py +23 -0
  12. label_studio_sdk/actions/types/actions_create_request_filters_items_item_value.py +5 -0
  13. label_studio_sdk/actions/types/actions_create_request_id.py +19 -0
  14. label_studio_sdk/actions/types/actions_create_request_ordering_item.py +31 -0
  15. label_studio_sdk/actions/types/actions_create_request_selected_items.py +10 -0
  16. label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +39 -0
  17. label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +39 -0
  18. label_studio_sdk/base_client.py +183 -0
  19. label_studio_sdk/client.py +17 -175
  20. label_studio_sdk/core/client_wrapper.py +1 -1
  21. label_studio_sdk/core/http_client.py +5 -1
  22. label_studio_sdk/errors/bad_request_error.py +3 -1
  23. label_studio_sdk/export_storage/azure/client.py +176 -10
  24. label_studio_sdk/export_storage/azure/types/azure_create_response.py +15 -0
  25. label_studio_sdk/export_storage/azure/types/azure_update_response.py +15 -0
  26. label_studio_sdk/export_storage/gcs/client.py +180 -14
  27. label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +16 -1
  28. label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +16 -1
  29. label_studio_sdk/export_storage/local/client.py +168 -22
  30. label_studio_sdk/export_storage/local/types/local_create_response.py +12 -2
  31. label_studio_sdk/export_storage/local/types/local_update_response.py +12 -2
  32. label_studio_sdk/export_storage/redis/client.py +234 -30
  33. label_studio_sdk/export_storage/redis/types/redis_create_response.py +20 -5
  34. label_studio_sdk/export_storage/redis/types/redis_update_response.py +20 -5
  35. label_studio_sdk/export_storage/s3/client.py +214 -26
  36. label_studio_sdk/export_storage/s3/types/s3create_response.py +15 -0
  37. label_studio_sdk/export_storage/s3/types/s3update_response.py +15 -0
  38. label_studio_sdk/import_storage/azure/client.py +266 -90
  39. label_studio_sdk/import_storage/azure/types/azure_create_response.py +28 -18
  40. label_studio_sdk/import_storage/azure/types/azure_update_response.py +28 -18
  41. label_studio_sdk/import_storage/gcs/client.py +270 -94
  42. label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +28 -18
  43. label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +28 -18
  44. label_studio_sdk/import_storage/local/client.py +168 -22
  45. label_studio_sdk/import_storage/local/types/local_create_response.py +12 -2
  46. label_studio_sdk/import_storage/local/types/local_update_response.py +12 -2
  47. label_studio_sdk/import_storage/redis/client.py +206 -50
  48. label_studio_sdk/import_storage/redis/types/redis_create_response.py +20 -10
  49. label_studio_sdk/import_storage/redis/types/redis_update_response.py +20 -10
  50. label_studio_sdk/import_storage/s3/client.py +336 -110
  51. label_studio_sdk/import_storage/s3/types/s3create_response.py +35 -25
  52. label_studio_sdk/import_storage/s3/types/s3update_response.py +35 -25
  53. label_studio_sdk/{_legacy/label_interface → label_interface}/base.py +10 -0
  54. label_studio_sdk/{_legacy/label_interface → label_interface}/control_tags.py +109 -71
  55. label_studio_sdk/{_legacy/label_interface → label_interface}/interface.py +97 -51
  56. label_studio_sdk/{_legacy/label_interface → label_interface}/object_tags.py +8 -13
  57. label_studio_sdk/label_interface/objects.py +60 -0
  58. label_studio_sdk/label_interface/region.py +75 -0
  59. label_studio_sdk/projects/client.py +6 -4
  60. label_studio_sdk/projects/client_ext.py +19 -0
  61. label_studio_sdk/tasks/client.py +35 -8
  62. label_studio_sdk/tasks/client_ext.py +18 -0
  63. label_studio_sdk/types/__init__.py +10 -0
  64. label_studio_sdk/types/annotation.py +5 -5
  65. label_studio_sdk/types/annotations_dm_field.py +120 -0
  66. label_studio_sdk/types/annotations_dm_field_last_action.py +19 -0
  67. label_studio_sdk/types/data_manager_task_serializer.py +123 -0
  68. label_studio_sdk/types/data_manager_task_serializer_drafts_item.py +31 -0
  69. label_studio_sdk/types/data_manager_task_serializer_predictions_item.py +37 -0
  70. label_studio_sdk/types/task.py +1 -1
  71. label_studio_sdk/views/__init__.py +12 -4
  72. label_studio_sdk/views/types/__init__.py +12 -4
  73. label_studio_sdk/views/types/views_create_request_data.py +2 -2
  74. label_studio_sdk/views/types/views_create_request_data_filters.py +5 -5
  75. label_studio_sdk/views/types/views_create_request_data_filters_conjunction.py +1 -1
  76. label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +11 -8
  77. label_studio_sdk/views/types/views_create_request_data_filters_items_item_filter.py +31 -0
  78. label_studio_sdk/views/types/views_create_request_data_filters_items_item_operator.py +23 -0
  79. label_studio_sdk/views/types/views_create_request_data_filters_items_item_value.py +5 -0
  80. label_studio_sdk/views/types/views_create_request_data_ordering_item.py +27 -34
  81. label_studio_sdk/views/types/views_update_request_data.py +2 -2
  82. label_studio_sdk/views/types/views_update_request_data_filters.py +5 -5
  83. label_studio_sdk/views/types/views_update_request_data_filters_conjunction.py +1 -1
  84. label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +11 -8
  85. label_studio_sdk/views/types/views_update_request_data_filters_items_item_filter.py +31 -0
  86. label_studio_sdk/views/types/views_update_request_data_filters_items_item_operator.py +23 -0
  87. label_studio_sdk/views/types/views_update_request_data_filters_items_item_value.py +5 -0
  88. label_studio_sdk/views/types/views_update_request_data_ordering_item.py +27 -34
  89. label_studio_sdk-1.0.2.dist-info/METADATA +195 -0
  90. {label_studio_sdk-1.0.0.dist-info → label_studio_sdk-1.0.2.dist-info}/RECORD +94 -69
  91. label_studio_sdk/_legacy/label_interface/region.py +0 -43
  92. label_studio_sdk/_legacy/objects.py +0 -35
  93. label_studio_sdk/views/types/views_create_request_data_ordering_item_direction.py +0 -5
  94. label_studio_sdk/views/types/views_update_request_data_ordering_item_direction.py +0 -5
  95. label_studio_sdk-1.0.0.dist-info/METADATA +0 -307
  96. /label_studio_sdk/{_legacy/label_interface → label_interface}/__init__.py +0 -0
  97. /label_studio_sdk/{_legacy/label_interface → label_interface}/data_examples.json +0 -0
  98. /label_studio_sdk/{_legacy/label_interface → label_interface}/label_tags.py +0 -0
  99. {label_studio_sdk-1.0.0.dist-info → label_studio_sdk-1.0.2.dist-info}/WHEEL +0 -0
@@ -4,6 +4,8 @@ from .types import (
4
4
  Annotation,
5
5
  AnnotationFilterOptions,
6
6
  AnnotationLastAction,
7
+ AnnotationsDmField,
8
+ AnnotationsDmFieldLastAction,
7
9
  AzureBlobExportStorage,
8
10
  AzureBlobExportStorageStatus,
9
11
  AzureBlobImportStorage,
@@ -12,6 +14,9 @@ from .types import (
12
14
  BaseUser,
13
15
  ConvertedFormat,
14
16
  ConvertedFormatStatus,
17
+ DataManagerTaskSerializer,
18
+ DataManagerTaskSerializerDraftsItem,
19
+ DataManagerTaskSerializerPredictionsItem,
15
20
  Export,
16
21
  ExportConvert,
17
22
  ExportCreate,
@@ -73,6 +78,19 @@ from . import (
73
78
  webhooks,
74
79
  )
75
80
  from ._legacy import Client
81
+ from .actions import (
82
+ ActionsCreateRequestFilters,
83
+ ActionsCreateRequestFiltersConjunction,
84
+ ActionsCreateRequestFiltersItemsItem,
85
+ ActionsCreateRequestFiltersItemsItemFilter,
86
+ ActionsCreateRequestFiltersItemsItemOperator,
87
+ ActionsCreateRequestFiltersItemsItemValue,
88
+ ActionsCreateRequestId,
89
+ ActionsCreateRequestOrderingItem,
90
+ ActionsCreateRequestSelectedItems,
91
+ ActionsCreateRequestSelectedItemsExcluded,
92
+ ActionsCreateRequestSelectedItemsIncluded,
93
+ )
76
94
  from .environment import LabelStudioEnvironment
77
95
  from .export_storage import ExportStorageListTypesResponseItem
78
96
  from .import_storage import ImportStorageListTypesResponseItem
@@ -93,21 +111,38 @@ from .views import (
93
111
  ViewsCreateRequestDataFilters,
94
112
  ViewsCreateRequestDataFiltersConjunction,
95
113
  ViewsCreateRequestDataFiltersItemsItem,
114
+ ViewsCreateRequestDataFiltersItemsItemFilter,
115
+ ViewsCreateRequestDataFiltersItemsItemOperator,
116
+ ViewsCreateRequestDataFiltersItemsItemValue,
96
117
  ViewsCreateRequestDataOrderingItem,
97
- ViewsCreateRequestDataOrderingItemDirection,
98
118
  ViewsUpdateRequestData,
99
119
  ViewsUpdateRequestDataFilters,
100
120
  ViewsUpdateRequestDataFiltersConjunction,
101
121
  ViewsUpdateRequestDataFiltersItemsItem,
122
+ ViewsUpdateRequestDataFiltersItemsItemFilter,
123
+ ViewsUpdateRequestDataFiltersItemsItemOperator,
124
+ ViewsUpdateRequestDataFiltersItemsItemValue,
102
125
  ViewsUpdateRequestDataOrderingItem,
103
- ViewsUpdateRequestDataOrderingItemDirection,
104
126
  )
105
127
  from .webhooks import WebhooksUpdateRequestActionsItem
106
128
 
107
129
  __all__ = [
130
+ "ActionsCreateRequestFilters",
131
+ "ActionsCreateRequestFiltersConjunction",
132
+ "ActionsCreateRequestFiltersItemsItem",
133
+ "ActionsCreateRequestFiltersItemsItemFilter",
134
+ "ActionsCreateRequestFiltersItemsItemOperator",
135
+ "ActionsCreateRequestFiltersItemsItemValue",
136
+ "ActionsCreateRequestId",
137
+ "ActionsCreateRequestOrderingItem",
138
+ "ActionsCreateRequestSelectedItems",
139
+ "ActionsCreateRequestSelectedItemsExcluded",
140
+ "ActionsCreateRequestSelectedItemsIncluded",
108
141
  "Annotation",
109
142
  "AnnotationFilterOptions",
110
143
  "AnnotationLastAction",
144
+ "AnnotationsDmField",
145
+ "AnnotationsDmFieldLastAction",
111
146
  "AzureBlobExportStorage",
112
147
  "AzureBlobExportStorageStatus",
113
148
  "AzureBlobImportStorage",
@@ -118,6 +153,9 @@ __all__ = [
118
153
  "Client",
119
154
  "ConvertedFormat",
120
155
  "ConvertedFormatStatus",
156
+ "DataManagerTaskSerializer",
157
+ "DataManagerTaskSerializerDraftsItem",
158
+ "DataManagerTaskSerializerPredictionsItem",
121
159
  "Export",
122
160
  "ExportConvert",
123
161
  "ExportCreate",
@@ -179,14 +217,18 @@ __all__ = [
179
217
  "ViewsCreateRequestDataFilters",
180
218
  "ViewsCreateRequestDataFiltersConjunction",
181
219
  "ViewsCreateRequestDataFiltersItemsItem",
220
+ "ViewsCreateRequestDataFiltersItemsItemFilter",
221
+ "ViewsCreateRequestDataFiltersItemsItemOperator",
222
+ "ViewsCreateRequestDataFiltersItemsItemValue",
182
223
  "ViewsCreateRequestDataOrderingItem",
183
- "ViewsCreateRequestDataOrderingItemDirection",
184
224
  "ViewsUpdateRequestData",
185
225
  "ViewsUpdateRequestDataFilters",
186
226
  "ViewsUpdateRequestDataFiltersConjunction",
187
227
  "ViewsUpdateRequestDataFiltersItemsItem",
228
+ "ViewsUpdateRequestDataFiltersItemsItemFilter",
229
+ "ViewsUpdateRequestDataFiltersItemsItemOperator",
230
+ "ViewsUpdateRequestDataFiltersItemsItemValue",
188
231
  "ViewsUpdateRequestDataOrderingItem",
189
- "ViewsUpdateRequestDataOrderingItemDirection",
190
232
  "Webhook",
191
233
  "WebhookActionsItem",
192
234
  "WebhookSerializerForUpdate",
@@ -0,0 +1,49 @@
1
+ import typing
2
+ from label_studio_sdk.core.pagination import SyncPager, AsyncPager, T
3
+ from label_studio_sdk.core.api_error import ApiError
4
+
5
+ # This is a custom extension of the autogenerated SyncPager and AsyncPager classes
6
+ # that works with the Label Studio SDK's default pagination behavior
7
+ # that throws 404 errors at the end of the pagination.
8
+
9
+
10
+ class SyncPagerExt(SyncPager, typing.Generic[T]):
11
+
12
+ @classmethod
13
+ def from_sync_pager(cls, sync_pager: SyncPager) -> 'SyncPagerExt':
14
+ return cls(
15
+ get_next=sync_pager.get_next,
16
+ has_next=sync_pager.has_next,
17
+ items=sync_pager.items
18
+ )
19
+
20
+ def __iter__(self) -> typing.Iterator[T]: # type: ignore
21
+ # Extends the iterator to catch 404 errors at the end of the pagination
22
+ try:
23
+ for item in super().__iter__():
24
+ yield item
25
+ except ApiError as exc:
26
+ if exc.status_code == 404:
27
+ return
28
+ raise
29
+
30
+
31
+ class AsyncPagerExt(AsyncPager, typing.Generic[T]):
32
+
33
+ @classmethod
34
+ async def from_async_pager(cls, async_pager: AsyncPager) -> 'AsyncPagerExt':
35
+ return cls(
36
+ get_next=async_pager.get_next,
37
+ has_next=async_pager.has_next,
38
+ items=async_pager.items
39
+ )
40
+
41
+ async def __aiter__(self) -> typing.AsyncIterator[T]: # type: ignore
42
+ # Extends the iterator to catch 404 errors at the end of the pagination
43
+ try:
44
+ async for item in super().__aiter__():
45
+ yield item
46
+ except ApiError as exc:
47
+ if exc.status_code == 404:
48
+ return
49
+ raise
@@ -37,19 +37,19 @@
37
37
  },
38
38
  "tag_with_value_required_name": {
39
39
  "type": "object",
40
- "oneOf": [
41
- {
42
- "required": [
43
- "@name",
44
- "@value"
45
- ]
46
- },
47
- {
48
- "required": [
49
- "@name",
50
- "@valueList"
51
- ]
52
- }
40
+ "anyOf": [
41
+ {
42
+ "required": [
43
+ "@name",
44
+ "@valueList"
45
+ ]
46
+ },
47
+ {
48
+ "required": [
49
+ "@name",
50
+ "@value"
51
+ ]
52
+ }
53
53
  ],
54
54
  "properties": {
55
55
  "@value": {
@@ -223,4 +223,4 @@
223
223
  }
224
224
  }
225
225
  }
226
- }
226
+ }
@@ -1,2 +1,29 @@
1
1
  # This file was auto-generated by Fern from our API Definition.
2
2
 
3
+ from .types import (
4
+ ActionsCreateRequestFilters,
5
+ ActionsCreateRequestFiltersConjunction,
6
+ ActionsCreateRequestFiltersItemsItem,
7
+ ActionsCreateRequestFiltersItemsItemFilter,
8
+ ActionsCreateRequestFiltersItemsItemOperator,
9
+ ActionsCreateRequestFiltersItemsItemValue,
10
+ ActionsCreateRequestId,
11
+ ActionsCreateRequestOrderingItem,
12
+ ActionsCreateRequestSelectedItems,
13
+ ActionsCreateRequestSelectedItemsExcluded,
14
+ ActionsCreateRequestSelectedItemsIncluded,
15
+ )
16
+
17
+ __all__ = [
18
+ "ActionsCreateRequestFilters",
19
+ "ActionsCreateRequestFiltersConjunction",
20
+ "ActionsCreateRequestFiltersItemsItem",
21
+ "ActionsCreateRequestFiltersItemsItemFilter",
22
+ "ActionsCreateRequestFiltersItemsItemOperator",
23
+ "ActionsCreateRequestFiltersItemsItemValue",
24
+ "ActionsCreateRequestId",
25
+ "ActionsCreateRequestOrderingItem",
26
+ "ActionsCreateRequestSelectedItems",
27
+ "ActionsCreateRequestSelectedItemsExcluded",
28
+ "ActionsCreateRequestSelectedItemsIncluded",
29
+ ]
@@ -6,6 +6,13 @@ from json.decoder import JSONDecodeError
6
6
  from ..core.api_error import ApiError
7
7
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
8
  from ..core.request_options import RequestOptions
9
+ from .types.actions_create_request_filters import ActionsCreateRequestFilters
10
+ from .types.actions_create_request_id import ActionsCreateRequestId
11
+ from .types.actions_create_request_ordering_item import ActionsCreateRequestOrderingItem
12
+ from .types.actions_create_request_selected_items import ActionsCreateRequestSelectedItems
13
+
14
+ # this is used as the default value for optional parameters
15
+ OMIT = typing.cast(typing.Any, ...)
9
16
 
10
17
 
11
18
  class ActionsClient:
@@ -45,12 +52,40 @@ class ActionsClient:
45
52
  raise ApiError(status_code=_response.status_code, body=_response.text)
46
53
  raise ApiError(status_code=_response.status_code, body=_response_json)
47
54
 
48
- def create(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
55
+ def create(
56
+ self,
57
+ *,
58
+ id: ActionsCreateRequestId,
59
+ project: int,
60
+ view: typing.Optional[int] = None,
61
+ filters: typing.Optional[ActionsCreateRequestFilters] = OMIT,
62
+ selected_items: typing.Optional[ActionsCreateRequestSelectedItems] = OMIT,
63
+ ordering: typing.Optional[typing.Sequence[ActionsCreateRequestOrderingItem]] = OMIT,
64
+ request_options: typing.Optional[RequestOptions] = None
65
+ ) -> None:
49
66
  """
50
- Perform an action with the selected items from a specific view.
67
+ Perform a Data Manager action with the selected tasks and filters. Note: More complex actions require additional parameters in the request body. Call `GET api/actions?project=<id>` to explore them. <br>Example: `GET api/actions?id=delete_tasks&project=1`
51
68
 
52
69
  Parameters
53
70
  ----------
71
+ id : ActionsCreateRequestId
72
+ Action name ID, see the full list of actions in the `GET api/actions` request
73
+
74
+ project : int
75
+ Project ID
76
+
77
+ view : typing.Optional[int]
78
+ View ID (optional, it has higher priority than filters, selectedItems and ordering from the request body payload)
79
+
80
+ filters : typing.Optional[ActionsCreateRequestFilters]
81
+ Filters to apply on tasks. You can use [the helper class `Filters` from this page](https://labelstud.io/sdk/data_manager.html) to create Data Manager Filters.<br>Example: `{"conjunction": "or", "items": [{"filter": "filter:tasks:completed_at", "operator": "greater", "type": "Datetime", "value": "2021-01-01T00:00:00.000Z"}]}`
82
+
83
+ selected_items : typing.Optional[ActionsCreateRequestSelectedItems]
84
+ Task selection by IDs. If filters are applied, the selection will be applied to the filtered tasks.If "all" is `false`, `"included"` must be used. If "all" is `true`, `"excluded"` must be used.<br>Examples: `{"all": false, "included": [1, 2, 3]}` or `{"all": true, "excluded": [4, 5]}`
85
+
86
+ ordering : typing.Optional[typing.Sequence[ActionsCreateRequestOrderingItem]]
87
+ List of fields to order by. Fields are similar to filters but without the `filter:` prefix. To reverse the order, add a minus sign before the field name, e.g. `-tasks:created_at`.
88
+
54
89
  request_options : typing.Optional[RequestOptions]
55
90
  Request-specific configuration.
56
91
 
@@ -60,15 +95,44 @@ class ActionsClient:
60
95
 
61
96
  Examples
62
97
  --------
98
+ from label_studio_sdk import (
99
+ ActionsCreateRequestFilters,
100
+ ActionsCreateRequestFiltersItemsItem,
101
+ ActionsCreateRequestSelectedItemsExcluded,
102
+ )
63
103
  from label_studio_sdk.client import LabelStudio
64
104
 
65
105
  client = LabelStudio(
66
106
  api_key="YOUR_API_KEY",
67
107
  )
68
- client.actions.create()
108
+ client.actions.create(
109
+ id="retrieve_tasks_predictions",
110
+ project=1,
111
+ filters=ActionsCreateRequestFilters(
112
+ conjunction="or",
113
+ items=[
114
+ ActionsCreateRequestFiltersItemsItem(
115
+ filter="filter:tasks:id",
116
+ operator="greater",
117
+ type="Number",
118
+ value=123,
119
+ )
120
+ ],
121
+ ),
122
+ selected_items=ActionsCreateRequestSelectedItemsExcluded(
123
+ all_=True,
124
+ excluded=[124, 125, 126],
125
+ ),
126
+ ordering=["tasks:total_annotations"],
127
+ )
69
128
  """
70
129
  _response = self._client_wrapper.httpx_client.request(
71
- "api/dm/actions/", method="POST", request_options=request_options
130
+ "api/dm/actions/",
131
+ method="POST",
132
+ params={"id": id, "project": project, "view": view},
133
+ json={"filters": filters, "selectedItems": selected_items, "ordering": ordering},
134
+ request_options=request_options,
135
+ omit=OMIT,
72
136
  )
73
137
  if 200 <= _response.status_code < 300:
74
138
  return
@@ -116,12 +180,40 @@ class AsyncActionsClient:
116
180
  raise ApiError(status_code=_response.status_code, body=_response.text)
117
181
  raise ApiError(status_code=_response.status_code, body=_response_json)
118
182
 
119
- async def create(self, *, request_options: typing.Optional[RequestOptions] = None) -> None:
183
+ async def create(
184
+ self,
185
+ *,
186
+ id: ActionsCreateRequestId,
187
+ project: int,
188
+ view: typing.Optional[int] = None,
189
+ filters: typing.Optional[ActionsCreateRequestFilters] = OMIT,
190
+ selected_items: typing.Optional[ActionsCreateRequestSelectedItems] = OMIT,
191
+ ordering: typing.Optional[typing.Sequence[ActionsCreateRequestOrderingItem]] = OMIT,
192
+ request_options: typing.Optional[RequestOptions] = None
193
+ ) -> None:
120
194
  """
121
- Perform an action with the selected items from a specific view.
195
+ Perform a Data Manager action with the selected tasks and filters. Note: More complex actions require additional parameters in the request body. Call `GET api/actions?project=<id>` to explore them. <br>Example: `GET api/actions?id=delete_tasks&project=1`
122
196
 
123
197
  Parameters
124
198
  ----------
199
+ id : ActionsCreateRequestId
200
+ Action name ID, see the full list of actions in the `GET api/actions` request
201
+
202
+ project : int
203
+ Project ID
204
+
205
+ view : typing.Optional[int]
206
+ View ID (optional, it has higher priority than filters, selectedItems and ordering from the request body payload)
207
+
208
+ filters : typing.Optional[ActionsCreateRequestFilters]
209
+ Filters to apply on tasks. You can use [the helper class `Filters` from this page](https://labelstud.io/sdk/data_manager.html) to create Data Manager Filters.<br>Example: `{"conjunction": "or", "items": [{"filter": "filter:tasks:completed_at", "operator": "greater", "type": "Datetime", "value": "2021-01-01T00:00:00.000Z"}]}`
210
+
211
+ selected_items : typing.Optional[ActionsCreateRequestSelectedItems]
212
+ Task selection by IDs. If filters are applied, the selection will be applied to the filtered tasks.If "all" is `false`, `"included"` must be used. If "all" is `true`, `"excluded"` must be used.<br>Examples: `{"all": false, "included": [1, 2, 3]}` or `{"all": true, "excluded": [4, 5]}`
213
+
214
+ ordering : typing.Optional[typing.Sequence[ActionsCreateRequestOrderingItem]]
215
+ List of fields to order by. Fields are similar to filters but without the `filter:` prefix. To reverse the order, add a minus sign before the field name, e.g. `-tasks:created_at`.
216
+
125
217
  request_options : typing.Optional[RequestOptions]
126
218
  Request-specific configuration.
127
219
 
@@ -131,15 +223,44 @@ class AsyncActionsClient:
131
223
 
132
224
  Examples
133
225
  --------
226
+ from label_studio_sdk import (
227
+ ActionsCreateRequestFilters,
228
+ ActionsCreateRequestFiltersItemsItem,
229
+ ActionsCreateRequestSelectedItemsExcluded,
230
+ )
134
231
  from label_studio_sdk.client import AsyncLabelStudio
135
232
 
136
233
  client = AsyncLabelStudio(
137
234
  api_key="YOUR_API_KEY",
138
235
  )
139
- await client.actions.create()
236
+ await client.actions.create(
237
+ id="retrieve_tasks_predictions",
238
+ project=1,
239
+ filters=ActionsCreateRequestFilters(
240
+ conjunction="or",
241
+ items=[
242
+ ActionsCreateRequestFiltersItemsItem(
243
+ filter="filter:tasks:id",
244
+ operator="greater",
245
+ type="Number",
246
+ value=123,
247
+ )
248
+ ],
249
+ ),
250
+ selected_items=ActionsCreateRequestSelectedItemsExcluded(
251
+ all_=True,
252
+ excluded=[124, 125, 126],
253
+ ),
254
+ ordering=["tasks:total_annotations"],
255
+ )
140
256
  """
141
257
  _response = await self._client_wrapper.httpx_client.request(
142
- "api/dm/actions/", method="POST", request_options=request_options
258
+ "api/dm/actions/",
259
+ method="POST",
260
+ params={"id": id, "project": project, "view": view},
261
+ json={"filters": filters, "selectedItems": selected_items, "ordering": ordering},
262
+ request_options=request_options,
263
+ omit=OMIT,
143
264
  )
144
265
  if 200 <= _response.status_code < 300:
145
266
  return
@@ -0,0 +1,27 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from .actions_create_request_filters import ActionsCreateRequestFilters
4
+ from .actions_create_request_filters_conjunction import ActionsCreateRequestFiltersConjunction
5
+ from .actions_create_request_filters_items_item import ActionsCreateRequestFiltersItemsItem
6
+ from .actions_create_request_filters_items_item_filter import ActionsCreateRequestFiltersItemsItemFilter
7
+ from .actions_create_request_filters_items_item_operator import ActionsCreateRequestFiltersItemsItemOperator
8
+ from .actions_create_request_filters_items_item_value import ActionsCreateRequestFiltersItemsItemValue
9
+ from .actions_create_request_id import ActionsCreateRequestId
10
+ from .actions_create_request_ordering_item import ActionsCreateRequestOrderingItem
11
+ from .actions_create_request_selected_items import ActionsCreateRequestSelectedItems
12
+ from .actions_create_request_selected_items_excluded import ActionsCreateRequestSelectedItemsExcluded
13
+ from .actions_create_request_selected_items_included import ActionsCreateRequestSelectedItemsIncluded
14
+
15
+ __all__ = [
16
+ "ActionsCreateRequestFilters",
17
+ "ActionsCreateRequestFiltersConjunction",
18
+ "ActionsCreateRequestFiltersItemsItem",
19
+ "ActionsCreateRequestFiltersItemsItemFilter",
20
+ "ActionsCreateRequestFiltersItemsItemOperator",
21
+ "ActionsCreateRequestFiltersItemsItemValue",
22
+ "ActionsCreateRequestId",
23
+ "ActionsCreateRequestOrderingItem",
24
+ "ActionsCreateRequestSelectedItems",
25
+ "ActionsCreateRequestSelectedItemsExcluded",
26
+ "ActionsCreateRequestSelectedItemsIncluded",
27
+ ]
@@ -0,0 +1,43 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ...core.datetime_utils import serialize_datetime
7
+ from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
8
+ from .actions_create_request_filters_conjunction import ActionsCreateRequestFiltersConjunction
9
+ from .actions_create_request_filters_items_item import ActionsCreateRequestFiltersItemsItem
10
+
11
+
12
+ class ActionsCreateRequestFilters(pydantic_v1.BaseModel):
13
+ """
14
+ Filters to apply on tasks. You can use [the helper class `Filters` from this page](https://labelstud.io/sdk/data_manager.html) to create Data Manager Filters.<br>Example: `{"conjunction": "or", "items": [{"filter": "filter:tasks:completed_at", "operator": "greater", "type": "Datetime", "value": "2021-01-01T00:00:00.000Z"}]}`
15
+ """
16
+
17
+ conjunction: ActionsCreateRequestFiltersConjunction = pydantic_v1.Field()
18
+ """
19
+ Logical conjunction for the filters. This conjunction (either "or" or "and") will be applied to all items in the filters list. It is not possible to combine "or" and "and" within one list of filters. All filters will be either combined with "or" or with "and", but not a mix of both.
20
+ """
21
+
22
+ items: typing.List[ActionsCreateRequestFiltersItemsItem] = pydantic_v1.Field()
23
+ """
24
+ List of filter items
25
+ """
26
+
27
+ def json(self, **kwargs: typing.Any) -> str:
28
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
29
+ return super().json(**kwargs_with_defaults)
30
+
31
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
32
+ kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
33
+ kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
34
+
35
+ return deep_union_pydantic_dicts(
36
+ super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
37
+ )
38
+
39
+ class Config:
40
+ frozen = True
41
+ smart_union = True
42
+ extra = pydantic_v1.Extra.allow
43
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ ActionsCreateRequestFiltersConjunction = typing.Union[typing.Literal["or", "and"], typing.Any]
@@ -0,0 +1,50 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import datetime as dt
4
+ import typing
5
+
6
+ from ...core.datetime_utils import serialize_datetime
7
+ from ...core.pydantic_utilities import deep_union_pydantic_dicts, pydantic_v1
8
+ from .actions_create_request_filters_items_item_filter import ActionsCreateRequestFiltersItemsItemFilter
9
+ from .actions_create_request_filters_items_item_operator import ActionsCreateRequestFiltersItemsItemOperator
10
+ from .actions_create_request_filters_items_item_value import ActionsCreateRequestFiltersItemsItemValue
11
+
12
+
13
+ class ActionsCreateRequestFiltersItemsItem(pydantic_v1.BaseModel):
14
+ filter: ActionsCreateRequestFiltersItemsItemFilter = pydantic_v1.Field()
15
+ """
16
+ Filter identifier, it should start with `filter:tasks:` prefix, e.g. `filter:tasks:agreement`. For `task.data` fields it may look like `filter:tasks:data.field_name`. If you need more info about columns, check the [Get data manager columns](#tag/Data-Manager/operation/api_dm_columns_list) API endpoint. Possible values:<br><li>`filter:tasks:agreement`<br> (Number) Agreement for annotation results for a specific task (Enterprise only)</li><br><li>`filter:tasks:annotations_results`<br> (String) Annotation results for the tasks</li><br><li>`filter:tasks:annotators`<br> (List) Annotators that completed the task (Community). Can include assigned annotators (Enterprise only). Important note: the filter `type` should be List, but the filter `value` is integer</li><br><li>`filter:tasks:cancelled_annotations`<br> (Number) Number of cancelled or skipped annotations for the task</li><br><li>`filter:tasks:comments`<br> (Number) Number of comments in a task</li><br><li>`filter:tasks:completed_at`<br> (Datetime) Time when a task was fully annotated</li><br><li>`filter:tasks:created_at`<br> (Datetime) Time the task was created at</li><br><li>`filter:tasks:file_upload`<br> (String) Name of the file uploaded to create the tasks</li><br><li>`filter:tasks:ground_truth`<br> (Boolean) Ground truth status of the tasks</li><br><li>`filter:tasks:id`<br> (Number) Task ID</li><br><li>`filter:tasks:inner_id`<br> (Number) Task Inner ID, it starts from 1 for all projects</li><br><li>`filter:tasks:predictions_model_versions`<br> (String) Model version used for the predictions</li><br><li>`filter:tasks:predictions_results`<br> (String) Prediction results for the tasks</li><br><li>`filter:tasks:predictions_score`<br> (Number) Prediction score for the task</li><br><li>`filter:tasks:reviewed`<br> (Boolean) Whether the tasks have been reviewed (Enterprise only)</li><br><li>`filter:tasks:reviewers`<br> (String) Reviewers that reviewed the task, or assigned reviewers (Enterprise only). Important note: the filter `type` should be List, but the filter `value` is integer</li><br><li>`filter:tasks:reviews_accepted`<br> (Number) Number of annotations accepted for a task in review (Enterprise only)</li><br><li>`filter:tasks:reviews_rejected`<br> (Number) Number of annotations rejected for a task in review (Enterprise only)</li><br><li>`filter:tasks:total_annotations`<br> (Number) Total number of annotations on a task</li><br><li>`filter:tasks:total_predictions`<br> (Number) Total number of predictions for the task</li><br><li>`filter:tasks:unresolved_comment_count`<br> (Number) Number of unresolved comments in a task</li><br><li>`filter:tasks:updated_at`<br> (Datetime) Time the task was updated at (e.g. new annotation was created, review added, etc)</li>
17
+ """
18
+
19
+ operator: ActionsCreateRequestFiltersItemsItemOperator = pydantic_v1.Field()
20
+ """
21
+ Filter operator. Possible values:<br><li>`contains`<br> Contains</li><br><li>`ends_with`<br> Ends with</li><br><li>`equal`<br> Equal to</li><br><li>`exists`<br> Exists</li><br><li>`greater`<br> Greater than</li><br><li>`greater_or_equal`<br> Greater than or equal to</li><br><li>`in`<br> Is between min and max values, so the filter `value` should be e.g. `{"min": 1, "max": 7}`</li><br><li>`less`<br> Less than</li><br><li>`less_or_equal`<br> Less than or equal to</li><br><li>`not_contains`<br> Does not contain</li><br><li>`not_equal`<br> Not equal to</li><br><li>`not_exists`<br> Does not exist</li><br><li>`not_in`<br> Is not between min and max values, so the filter `value` should be e.g. `{"min": 1, "max": 7}`</li><br><li>`starts_with`<br> Starts with</li>
22
+ """
23
+
24
+ type: str = pydantic_v1.Field()
25
+ """
26
+ Type of the filter value. Possible values:<br><li>`Boolean`<br> Boolean</li><br><li>`Datetime`<br> Datetime string in `strftime('%Y-%m-%dT%H:%M:%S.%fZ')` format</li><br><li>`List`<br> List of items</li><br><li>`Number`<br> Float or Integer</li><br><li>`String`<br> String</li><br><li>`Unknown`<br> Unknown is explicitly converted to string format</li>
27
+ """
28
+
29
+ value: ActionsCreateRequestFiltersItemsItemValue = pydantic_v1.Field()
30
+ """
31
+ Value to filter by
32
+ """
33
+
34
+ def json(self, **kwargs: typing.Any) -> str:
35
+ kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
36
+ return super().json(**kwargs_with_defaults)
37
+
38
+ def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
39
+ kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
40
+ kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
41
+
42
+ return deep_union_pydantic_dicts(
43
+ super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
44
+ )
45
+
46
+ class Config:
47
+ frozen = True
48
+ smart_union = True
49
+ extra = pydantic_v1.Extra.allow
50
+ json_encoders = {dt.datetime: serialize_datetime}
@@ -0,0 +1,31 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ ActionsCreateRequestFiltersItemsItemFilter = typing.Union[
6
+ typing.Literal[
7
+ "filter:tasks:agreement",
8
+ "filter:tasks:annotations_results",
9
+ "filter:tasks:annotators",
10
+ "filter:tasks:cancelled_annotations",
11
+ "filter:tasks:comments",
12
+ "filter:tasks:completed_at",
13
+ "filter:tasks:created_at",
14
+ "filter:tasks:file_upload",
15
+ "filter:tasks:ground_truth",
16
+ "filter:tasks:id",
17
+ "filter:tasks:inner_id",
18
+ "filter:tasks:predictions_model_versions",
19
+ "filter:tasks:predictions_results",
20
+ "filter:tasks:predictions_score",
21
+ "filter:tasks:reviewed",
22
+ "filter:tasks:reviewers",
23
+ "filter:tasks:reviews_accepted",
24
+ "filter:tasks:reviews_rejected",
25
+ "filter:tasks:total_annotations",
26
+ "filter:tasks:total_predictions",
27
+ "filter:tasks:unresolved_comment_count",
28
+ "filter:tasks:updated_at",
29
+ ],
30
+ typing.Any,
31
+ ]
@@ -0,0 +1,23 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ ActionsCreateRequestFiltersItemsItemOperator = typing.Union[
6
+ typing.Literal[
7
+ "contains",
8
+ "ends_with",
9
+ "equal",
10
+ "exists",
11
+ "greater",
12
+ "greater_or_equal",
13
+ "in",
14
+ "less",
15
+ "less_or_equal",
16
+ "not_contains",
17
+ "not_equal",
18
+ "not_exists",
19
+ "not_in",
20
+ "starts_with",
21
+ ],
22
+ typing.Any,
23
+ ]
@@ -0,0 +1,5 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ ActionsCreateRequestFiltersItemsItemValue = typing.Union[str, int, float, bool, typing.Dict[str, typing.Any]]
@@ -0,0 +1,19 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ import typing
4
+
5
+ ActionsCreateRequestId = typing.Union[
6
+ typing.Literal[
7
+ "retrieve_tasks_predictions",
8
+ "predictions_to_annotations",
9
+ "remove_duplicates",
10
+ "delete_tasks",
11
+ "delete_ground_truths",
12
+ "delete_tasks_annotations",
13
+ "delete_tasks_reviews",
14
+ "delete_tasks_predictions",
15
+ "delete_reviewers",
16
+ "delete_annotators",
17
+ ],
18
+ typing.Any,
19
+ ]