label-studio-sdk 1.0.0__py3-none-any.whl → 1.0.1__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.
Potentially problematic release.
This version of label-studio-sdk might be problematic. Click here for more details.
- label_studio_sdk/__init__.py +30 -4
- label_studio_sdk/_extensions/pager_ext.py +49 -0
- label_studio_sdk/_legacy/objects.py +46 -7
- label_studio_sdk/_legacy/schema/label_config_schema.json +14 -14
- label_studio_sdk/actions/__init__.py +25 -0
- label_studio_sdk/actions/client.py +79 -6
- label_studio_sdk/actions/types/__init__.py +25 -0
- label_studio_sdk/actions/types/actions_create_request_filters.py +43 -0
- label_studio_sdk/actions/types/actions_create_request_filters_conjunction.py +5 -0
- label_studio_sdk/actions/types/actions_create_request_filters_items_item.py +49 -0
- label_studio_sdk/actions/types/actions_create_request_filters_items_item_filter.py +31 -0
- label_studio_sdk/actions/types/actions_create_request_filters_items_item_operator.py +23 -0
- label_studio_sdk/actions/types/actions_create_request_id.py +19 -0
- label_studio_sdk/actions/types/actions_create_request_ordering_item.py +31 -0
- label_studio_sdk/actions/types/actions_create_request_selected_items.py +10 -0
- label_studio_sdk/actions/types/actions_create_request_selected_items_excluded.py +39 -0
- label_studio_sdk/actions/types/actions_create_request_selected_items_included.py +39 -0
- label_studio_sdk/base_client.py +183 -0
- label_studio_sdk/client.py +17 -175
- label_studio_sdk/core/client_wrapper.py +1 -1
- label_studio_sdk/core/http_client.py +5 -1
- label_studio_sdk/export_storage/azure/client.py +176 -10
- label_studio_sdk/export_storage/azure/types/azure_create_response.py +15 -0
- label_studio_sdk/export_storage/azure/types/azure_update_response.py +15 -0
- label_studio_sdk/export_storage/gcs/client.py +180 -14
- label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +16 -1
- label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +16 -1
- label_studio_sdk/export_storage/local/client.py +168 -22
- label_studio_sdk/export_storage/local/types/local_create_response.py +12 -2
- label_studio_sdk/export_storage/local/types/local_update_response.py +12 -2
- label_studio_sdk/export_storage/redis/client.py +234 -30
- label_studio_sdk/export_storage/redis/types/redis_create_response.py +20 -5
- label_studio_sdk/export_storage/redis/types/redis_update_response.py +20 -5
- label_studio_sdk/export_storage/s3/client.py +214 -26
- label_studio_sdk/export_storage/s3/types/s3create_response.py +15 -0
- label_studio_sdk/export_storage/s3/types/s3update_response.py +15 -0
- label_studio_sdk/import_storage/azure/client.py +266 -90
- label_studio_sdk/import_storage/azure/types/azure_create_response.py +28 -18
- label_studio_sdk/import_storage/azure/types/azure_update_response.py +28 -18
- label_studio_sdk/import_storage/gcs/client.py +270 -94
- label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +28 -18
- label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +28 -18
- label_studio_sdk/import_storage/local/client.py +168 -22
- label_studio_sdk/import_storage/local/types/local_create_response.py +12 -2
- label_studio_sdk/import_storage/local/types/local_update_response.py +12 -2
- label_studio_sdk/import_storage/redis/client.py +206 -50
- label_studio_sdk/import_storage/redis/types/redis_create_response.py +20 -10
- label_studio_sdk/import_storage/redis/types/redis_update_response.py +20 -10
- label_studio_sdk/import_storage/s3/client.py +336 -110
- label_studio_sdk/import_storage/s3/types/s3create_response.py +35 -25
- label_studio_sdk/import_storage/s3/types/s3update_response.py +35 -25
- label_studio_sdk/{_legacy/label_interface → label_interface}/base.py +10 -0
- label_studio_sdk/{_legacy/label_interface → label_interface}/control_tags.py +109 -71
- label_studio_sdk/{_legacy/label_interface → label_interface}/interface.py +96 -50
- label_studio_sdk/{_legacy/label_interface → label_interface}/object_tags.py +8 -13
- label_studio_sdk/label_interface/region.py +75 -0
- label_studio_sdk/projects/client.py +4 -2
- label_studio_sdk/projects/client_ext.py +19 -0
- label_studio_sdk/tasks/client.py +26 -2
- label_studio_sdk/tasks/client_ext.py +18 -0
- label_studio_sdk/types/annotation.py +5 -5
- label_studio_sdk/types/task.py +1 -1
- label_studio_sdk/views/__init__.py +8 -4
- label_studio_sdk/views/types/__init__.py +8 -4
- label_studio_sdk/views/types/views_create_request_data.py +2 -2
- label_studio_sdk/views/types/views_create_request_data_filters.py +5 -5
- label_studio_sdk/views/types/views_create_request_data_filters_conjunction.py +1 -1
- label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +10 -8
- label_studio_sdk/views/types/views_create_request_data_filters_items_item_filter.py +31 -0
- label_studio_sdk/views/types/views_create_request_data_filters_items_item_operator.py +23 -0
- label_studio_sdk/views/types/views_create_request_data_ordering_item.py +27 -34
- label_studio_sdk/views/types/views_update_request_data.py +2 -2
- label_studio_sdk/views/types/views_update_request_data_filters.py +5 -5
- label_studio_sdk/views/types/views_update_request_data_filters_conjunction.py +1 -1
- label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +10 -8
- label_studio_sdk/views/types/views_update_request_data_filters_items_item_filter.py +31 -0
- label_studio_sdk/views/types/views_update_request_data_filters_items_item_operator.py +23 -0
- label_studio_sdk/views/types/views_update_request_data_ordering_item.py +27 -34
- {label_studio_sdk-1.0.0.dist-info → label_studio_sdk-1.0.1.dist-info}/METADATA +17 -161
- {label_studio_sdk-1.0.0.dist-info → label_studio_sdk-1.0.1.dist-info}/RECORD +84 -67
- label_studio_sdk/_legacy/label_interface/region.py +0 -43
- label_studio_sdk/views/types/views_create_request_data_ordering_item_direction.py +0 -5
- label_studio_sdk/views/types/views_update_request_data_ordering_item_direction.py +0 -5
- /label_studio_sdk/{_legacy/label_interface → label_interface}/__init__.py +0 -0
- /label_studio_sdk/{_legacy/label_interface → label_interface}/data_examples.json +0 -0
- /label_studio_sdk/{_legacy/label_interface → label_interface}/label_tags.py +0 -0
- {label_studio_sdk-1.0.0.dist-info → label_studio_sdk-1.0.1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
|
|
9
|
+
|
|
10
|
+
class ActionsCreateRequestSelectedItemsExcluded(pydantic_v1.BaseModel):
|
|
11
|
+
all_: bool = pydantic_v1.Field(alias="all")
|
|
12
|
+
"""
|
|
13
|
+
All tasks are selected
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
excluded: typing.Optional[typing.List[int]] = pydantic_v1.Field(default=None)
|
|
17
|
+
"""
|
|
18
|
+
List of excluded task IDs
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def json(self, **kwargs: typing.Any) -> str:
|
|
22
|
+
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
23
|
+
return super().json(**kwargs_with_defaults)
|
|
24
|
+
|
|
25
|
+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
|
26
|
+
kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
27
|
+
kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
|
|
28
|
+
|
|
29
|
+
return deep_union_pydantic_dicts(
|
|
30
|
+
super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
class Config:
|
|
34
|
+
frozen = True
|
|
35
|
+
smart_union = True
|
|
36
|
+
allow_population_by_field_name = True
|
|
37
|
+
populate_by_name = True
|
|
38
|
+
extra = pydantic_v1.Extra.allow
|
|
39
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
|
|
9
|
+
|
|
10
|
+
class ActionsCreateRequestSelectedItemsIncluded(pydantic_v1.BaseModel):
|
|
11
|
+
all_: bool = pydantic_v1.Field(alias="all")
|
|
12
|
+
"""
|
|
13
|
+
No tasks are selected
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
included: typing.Optional[typing.List[int]] = pydantic_v1.Field(default=None)
|
|
17
|
+
"""
|
|
18
|
+
List of included task IDs
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
def json(self, **kwargs: typing.Any) -> str:
|
|
22
|
+
kwargs_with_defaults: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
23
|
+
return super().json(**kwargs_with_defaults)
|
|
24
|
+
|
|
25
|
+
def dict(self, **kwargs: typing.Any) -> typing.Dict[str, typing.Any]:
|
|
26
|
+
kwargs_with_defaults_exclude_unset: typing.Any = {"by_alias": True, "exclude_unset": True, **kwargs}
|
|
27
|
+
kwargs_with_defaults_exclude_none: typing.Any = {"by_alias": True, "exclude_none": True, **kwargs}
|
|
28
|
+
|
|
29
|
+
return deep_union_pydantic_dicts(
|
|
30
|
+
super().dict(**kwargs_with_defaults_exclude_unset), super().dict(**kwargs_with_defaults_exclude_none)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
class Config:
|
|
34
|
+
frozen = True
|
|
35
|
+
smart_union = True
|
|
36
|
+
allow_population_by_field_name = True
|
|
37
|
+
populate_by_name = True
|
|
38
|
+
extra = pydantic_v1.Extra.allow
|
|
39
|
+
json_encoders = {dt.datetime: serialize_datetime}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import typing
|
|
5
|
+
|
|
6
|
+
import httpx
|
|
7
|
+
|
|
8
|
+
from .actions.client import ActionsClient, AsyncActionsClient
|
|
9
|
+
from .annotations.client import AnnotationsClient, AsyncAnnotationsClient
|
|
10
|
+
from .core.api_error import ApiError
|
|
11
|
+
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
12
|
+
from .environment import LabelStudioEnvironment
|
|
13
|
+
from .export_storage.client import AsyncExportStorageClient, ExportStorageClient
|
|
14
|
+
from .files.client import AsyncFilesClient, FilesClient
|
|
15
|
+
from .import_storage.client import AsyncImportStorageClient, ImportStorageClient
|
|
16
|
+
from .ml.client import AsyncMlClient, MlClient
|
|
17
|
+
from .predictions.client import AsyncPredictionsClient, PredictionsClient
|
|
18
|
+
from .projects.client import AsyncProjectsClient, ProjectsClient
|
|
19
|
+
from .tasks.client import AsyncTasksClient, TasksClient
|
|
20
|
+
from .users.client import AsyncUsersClient, UsersClient
|
|
21
|
+
from .views.client import AsyncViewsClient, ViewsClient
|
|
22
|
+
from .webhooks.client import AsyncWebhooksClient, WebhooksClient
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class LabelStudioBase:
|
|
26
|
+
"""
|
|
27
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
28
|
+
|
|
29
|
+
Parameters
|
|
30
|
+
----------
|
|
31
|
+
base_url : typing.Optional[str]
|
|
32
|
+
The base url to use for requests from the client.
|
|
33
|
+
|
|
34
|
+
environment : LabelStudioEnvironment
|
|
35
|
+
The environment to use for requests from the client. from .environment import LabelStudioEnvironment
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
Defaults to LabelStudioEnvironment.DEFAULT
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
api_key : typing.Optional[str]
|
|
44
|
+
timeout : typing.Optional[float]
|
|
45
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
46
|
+
|
|
47
|
+
follow_redirects : typing.Optional[bool]
|
|
48
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
49
|
+
|
|
50
|
+
httpx_client : typing.Optional[httpx.Client]
|
|
51
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
52
|
+
|
|
53
|
+
Examples
|
|
54
|
+
--------
|
|
55
|
+
from label_studio_sdk.client import LabelStudio
|
|
56
|
+
|
|
57
|
+
client = LabelStudio(
|
|
58
|
+
api_key="YOUR_API_KEY",
|
|
59
|
+
)
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
def __init__(
|
|
63
|
+
self,
|
|
64
|
+
*,
|
|
65
|
+
base_url: typing.Optional[str] = None,
|
|
66
|
+
environment: LabelStudioEnvironment = LabelStudioEnvironment.DEFAULT,
|
|
67
|
+
api_key: typing.Optional[str] = os.getenv("LABEL_STUDIO_API_KEY"),
|
|
68
|
+
timeout: typing.Optional[float] = None,
|
|
69
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
70
|
+
httpx_client: typing.Optional[httpx.Client] = None
|
|
71
|
+
):
|
|
72
|
+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
73
|
+
if api_key is None:
|
|
74
|
+
raise ApiError(
|
|
75
|
+
body="The client must be instantiated be either passing in api_key or setting LABEL_STUDIO_API_KEY"
|
|
76
|
+
)
|
|
77
|
+
self._client_wrapper = SyncClientWrapper(
|
|
78
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
79
|
+
api_key=api_key,
|
|
80
|
+
httpx_client=httpx_client
|
|
81
|
+
if httpx_client is not None
|
|
82
|
+
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
83
|
+
if follow_redirects is not None
|
|
84
|
+
else httpx.Client(timeout=_defaulted_timeout),
|
|
85
|
+
timeout=_defaulted_timeout,
|
|
86
|
+
)
|
|
87
|
+
self.annotations = AnnotationsClient(client_wrapper=self._client_wrapper)
|
|
88
|
+
self.users = UsersClient(client_wrapper=self._client_wrapper)
|
|
89
|
+
self.actions = ActionsClient(client_wrapper=self._client_wrapper)
|
|
90
|
+
self.views = ViewsClient(client_wrapper=self._client_wrapper)
|
|
91
|
+
self.files = FilesClient(client_wrapper=self._client_wrapper)
|
|
92
|
+
self.projects = ProjectsClient(client_wrapper=self._client_wrapper)
|
|
93
|
+
self.ml = MlClient(client_wrapper=self._client_wrapper)
|
|
94
|
+
self.predictions = PredictionsClient(client_wrapper=self._client_wrapper)
|
|
95
|
+
self.tasks = TasksClient(client_wrapper=self._client_wrapper)
|
|
96
|
+
self.import_storage = ImportStorageClient(client_wrapper=self._client_wrapper)
|
|
97
|
+
self.export_storage = ExportStorageClient(client_wrapper=self._client_wrapper)
|
|
98
|
+
self.webhooks = WebhooksClient(client_wrapper=self._client_wrapper)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class AsyncLabelStudioBase:
|
|
102
|
+
"""
|
|
103
|
+
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
base_url : typing.Optional[str]
|
|
108
|
+
The base url to use for requests from the client.
|
|
109
|
+
|
|
110
|
+
environment : LabelStudioEnvironment
|
|
111
|
+
The environment to use for requests from the client. from .environment import LabelStudioEnvironment
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
Defaults to LabelStudioEnvironment.DEFAULT
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
api_key : typing.Optional[str]
|
|
120
|
+
timeout : typing.Optional[float]
|
|
121
|
+
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
122
|
+
|
|
123
|
+
follow_redirects : typing.Optional[bool]
|
|
124
|
+
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
125
|
+
|
|
126
|
+
httpx_client : typing.Optional[httpx.AsyncClient]
|
|
127
|
+
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
128
|
+
|
|
129
|
+
Examples
|
|
130
|
+
--------
|
|
131
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
132
|
+
|
|
133
|
+
client = AsyncLabelStudio(
|
|
134
|
+
api_key="YOUR_API_KEY",
|
|
135
|
+
)
|
|
136
|
+
"""
|
|
137
|
+
|
|
138
|
+
def __init__(
|
|
139
|
+
self,
|
|
140
|
+
*,
|
|
141
|
+
base_url: typing.Optional[str] = None,
|
|
142
|
+
environment: LabelStudioEnvironment = LabelStudioEnvironment.DEFAULT,
|
|
143
|
+
api_key: typing.Optional[str] = os.getenv("LABEL_STUDIO_API_KEY"),
|
|
144
|
+
timeout: typing.Optional[float] = None,
|
|
145
|
+
follow_redirects: typing.Optional[bool] = True,
|
|
146
|
+
httpx_client: typing.Optional[httpx.AsyncClient] = None
|
|
147
|
+
):
|
|
148
|
+
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
149
|
+
if api_key is None:
|
|
150
|
+
raise ApiError(
|
|
151
|
+
body="The client must be instantiated be either passing in api_key or setting LABEL_STUDIO_API_KEY"
|
|
152
|
+
)
|
|
153
|
+
self._client_wrapper = AsyncClientWrapper(
|
|
154
|
+
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
155
|
+
api_key=api_key,
|
|
156
|
+
httpx_client=httpx_client
|
|
157
|
+
if httpx_client is not None
|
|
158
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
159
|
+
if follow_redirects is not None
|
|
160
|
+
else httpx.AsyncClient(timeout=_defaulted_timeout),
|
|
161
|
+
timeout=_defaulted_timeout,
|
|
162
|
+
)
|
|
163
|
+
self.annotations = AsyncAnnotationsClient(client_wrapper=self._client_wrapper)
|
|
164
|
+
self.users = AsyncUsersClient(client_wrapper=self._client_wrapper)
|
|
165
|
+
self.actions = AsyncActionsClient(client_wrapper=self._client_wrapper)
|
|
166
|
+
self.views = AsyncViewsClient(client_wrapper=self._client_wrapper)
|
|
167
|
+
self.files = AsyncFilesClient(client_wrapper=self._client_wrapper)
|
|
168
|
+
self.projects = AsyncProjectsClient(client_wrapper=self._client_wrapper)
|
|
169
|
+
self.ml = AsyncMlClient(client_wrapper=self._client_wrapper)
|
|
170
|
+
self.predictions = AsyncPredictionsClient(client_wrapper=self._client_wrapper)
|
|
171
|
+
self.tasks = AsyncTasksClient(client_wrapper=self._client_wrapper)
|
|
172
|
+
self.import_storage = AsyncImportStorageClient(client_wrapper=self._client_wrapper)
|
|
173
|
+
self.export_storage = AsyncExportStorageClient(client_wrapper=self._client_wrapper)
|
|
174
|
+
self.webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: LabelStudioEnvironment) -> str:
|
|
178
|
+
if base_url is not None:
|
|
179
|
+
return base_url
|
|
180
|
+
elif environment is not None:
|
|
181
|
+
return environment.value
|
|
182
|
+
else:
|
|
183
|
+
raise Exception("Please pass in either base_url or environment to construct the client")
|
label_studio_sdk/client.py
CHANGED
|
@@ -1,183 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
from .base_client import LabelStudioBase, AsyncLabelStudioBase
|
|
2
|
+
from .tasks.client_ext import TasksClientExt, AsyncTasksClientExt
|
|
3
|
+
from .projects.client_ext import ProjectsClientExt, AsyncProjectsClientExt
|
|
2
4
|
|
|
3
|
-
import os
|
|
4
|
-
import typing
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
class LabelStudio(LabelStudioBase):
|
|
7
|
+
""""""
|
|
8
|
+
__doc__ += LabelStudioBase.__doc__
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
from .core.api_error import ApiError
|
|
11
|
-
from .core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
12
|
-
from .environment import LabelStudioEnvironment
|
|
13
|
-
from .export_storage.client import AsyncExportStorageClient, ExportStorageClient
|
|
14
|
-
from .files.client import AsyncFilesClient, FilesClient
|
|
15
|
-
from .import_storage.client import AsyncImportStorageClient, ImportStorageClient
|
|
16
|
-
from .ml.client import AsyncMlClient, MlClient
|
|
17
|
-
from .predictions.client import AsyncPredictionsClient, PredictionsClient
|
|
18
|
-
from .projects.client import AsyncProjectsClient, ProjectsClient
|
|
19
|
-
from .tasks.client import AsyncTasksClient, TasksClient
|
|
20
|
-
from .users.client import AsyncUsersClient, UsersClient
|
|
21
|
-
from .views.client import AsyncViewsClient, ViewsClient
|
|
22
|
-
from .webhooks.client import AsyncWebhooksClient, WebhooksClient
|
|
10
|
+
def __init__(self, *args, **kwargs):
|
|
11
|
+
super().__init__(*args, **kwargs)
|
|
23
12
|
|
|
13
|
+
self.tasks = TasksClientExt(client_wrapper=self._client_wrapper)
|
|
14
|
+
self.projects = ProjectsClientExt(client_wrapper=self._client_wrapper)
|
|
24
15
|
|
|
25
|
-
class LabelStudio:
|
|
26
|
-
"""
|
|
27
|
-
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
28
16
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
The base url to use for requests from the client.
|
|
17
|
+
class AsyncLabelStudio(AsyncLabelStudioBase):
|
|
18
|
+
""""""
|
|
19
|
+
__doc__ += AsyncLabelStudioBase.__doc__
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
def __init__(self, *args, **kwargs):
|
|
22
|
+
super().__init__(*args, **kwargs)
|
|
36
23
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Defaults to LabelStudioEnvironment.DEFAULT
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
api_key : typing.Optional[str]
|
|
44
|
-
timeout : typing.Optional[float]
|
|
45
|
-
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
46
|
-
|
|
47
|
-
follow_redirects : typing.Optional[bool]
|
|
48
|
-
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
49
|
-
|
|
50
|
-
httpx_client : typing.Optional[httpx.Client]
|
|
51
|
-
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
52
|
-
|
|
53
|
-
Examples
|
|
54
|
-
--------
|
|
55
|
-
from label_studio_sdk.client import LabelStudio
|
|
56
|
-
|
|
57
|
-
client = LabelStudio(
|
|
58
|
-
api_key="YOUR_API_KEY",
|
|
59
|
-
)
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
def __init__(
|
|
63
|
-
self,
|
|
64
|
-
*,
|
|
65
|
-
base_url: typing.Optional[str] = None,
|
|
66
|
-
environment: LabelStudioEnvironment = LabelStudioEnvironment.DEFAULT,
|
|
67
|
-
api_key: typing.Optional[str] = os.getenv("LABEL_STUDIO_API_KEY"),
|
|
68
|
-
timeout: typing.Optional[float] = None,
|
|
69
|
-
follow_redirects: typing.Optional[bool] = True,
|
|
70
|
-
httpx_client: typing.Optional[httpx.Client] = None
|
|
71
|
-
):
|
|
72
|
-
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
73
|
-
if api_key is None:
|
|
74
|
-
raise ApiError(
|
|
75
|
-
body="The client must be instantiated be either passing in api_key or setting LABEL_STUDIO_API_KEY"
|
|
76
|
-
)
|
|
77
|
-
self._client_wrapper = SyncClientWrapper(
|
|
78
|
-
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
79
|
-
api_key=api_key,
|
|
80
|
-
httpx_client=httpx_client
|
|
81
|
-
if httpx_client is not None
|
|
82
|
-
else httpx.Client(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
83
|
-
if follow_redirects is not None
|
|
84
|
-
else httpx.Client(timeout=_defaulted_timeout),
|
|
85
|
-
timeout=_defaulted_timeout,
|
|
86
|
-
)
|
|
87
|
-
self.annotations = AnnotationsClient(client_wrapper=self._client_wrapper)
|
|
88
|
-
self.users = UsersClient(client_wrapper=self._client_wrapper)
|
|
89
|
-
self.actions = ActionsClient(client_wrapper=self._client_wrapper)
|
|
90
|
-
self.views = ViewsClient(client_wrapper=self._client_wrapper)
|
|
91
|
-
self.files = FilesClient(client_wrapper=self._client_wrapper)
|
|
92
|
-
self.projects = ProjectsClient(client_wrapper=self._client_wrapper)
|
|
93
|
-
self.ml = MlClient(client_wrapper=self._client_wrapper)
|
|
94
|
-
self.predictions = PredictionsClient(client_wrapper=self._client_wrapper)
|
|
95
|
-
self.tasks = TasksClient(client_wrapper=self._client_wrapper)
|
|
96
|
-
self.import_storage = ImportStorageClient(client_wrapper=self._client_wrapper)
|
|
97
|
-
self.export_storage = ExportStorageClient(client_wrapper=self._client_wrapper)
|
|
98
|
-
self.webhooks = WebhooksClient(client_wrapper=self._client_wrapper)
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
class AsyncLabelStudio:
|
|
102
|
-
"""
|
|
103
|
-
Use this class to access the different functions within the SDK. You can instantiate any number of clients with different configuration that will propagate to these functions.
|
|
104
|
-
|
|
105
|
-
Parameters
|
|
106
|
-
----------
|
|
107
|
-
base_url : typing.Optional[str]
|
|
108
|
-
The base url to use for requests from the client.
|
|
109
|
-
|
|
110
|
-
environment : LabelStudioEnvironment
|
|
111
|
-
The environment to use for requests from the client. from .environment import LabelStudioEnvironment
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
Defaults to LabelStudioEnvironment.DEFAULT
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
api_key : typing.Optional[str]
|
|
120
|
-
timeout : typing.Optional[float]
|
|
121
|
-
The timeout to be used, in seconds, for requests. By default the timeout is 60 seconds, unless a custom httpx client is used, in which case this default is not enforced.
|
|
122
|
-
|
|
123
|
-
follow_redirects : typing.Optional[bool]
|
|
124
|
-
Whether the default httpx client follows redirects or not, this is irrelevant if a custom httpx client is passed in.
|
|
125
|
-
|
|
126
|
-
httpx_client : typing.Optional[httpx.AsyncClient]
|
|
127
|
-
The httpx client to use for making requests, a preconfigured client is used by default, however this is useful should you want to pass in any custom httpx configuration.
|
|
128
|
-
|
|
129
|
-
Examples
|
|
130
|
-
--------
|
|
131
|
-
from label_studio_sdk.client import AsyncLabelStudio
|
|
132
|
-
|
|
133
|
-
client = AsyncLabelStudio(
|
|
134
|
-
api_key="YOUR_API_KEY",
|
|
135
|
-
)
|
|
136
|
-
"""
|
|
137
|
-
|
|
138
|
-
def __init__(
|
|
139
|
-
self,
|
|
140
|
-
*,
|
|
141
|
-
base_url: typing.Optional[str] = None,
|
|
142
|
-
environment: LabelStudioEnvironment = LabelStudioEnvironment.DEFAULT,
|
|
143
|
-
api_key: typing.Optional[str] = os.getenv("LABEL_STUDIO_API_KEY"),
|
|
144
|
-
timeout: typing.Optional[float] = None,
|
|
145
|
-
follow_redirects: typing.Optional[bool] = True,
|
|
146
|
-
httpx_client: typing.Optional[httpx.AsyncClient] = None
|
|
147
|
-
):
|
|
148
|
-
_defaulted_timeout = timeout if timeout is not None else 60 if httpx_client is None else None
|
|
149
|
-
if api_key is None:
|
|
150
|
-
raise ApiError(
|
|
151
|
-
body="The client must be instantiated be either passing in api_key or setting LABEL_STUDIO_API_KEY"
|
|
152
|
-
)
|
|
153
|
-
self._client_wrapper = AsyncClientWrapper(
|
|
154
|
-
base_url=_get_base_url(base_url=base_url, environment=environment),
|
|
155
|
-
api_key=api_key,
|
|
156
|
-
httpx_client=httpx_client
|
|
157
|
-
if httpx_client is not None
|
|
158
|
-
else httpx.AsyncClient(timeout=_defaulted_timeout, follow_redirects=follow_redirects)
|
|
159
|
-
if follow_redirects is not None
|
|
160
|
-
else httpx.AsyncClient(timeout=_defaulted_timeout),
|
|
161
|
-
timeout=_defaulted_timeout,
|
|
162
|
-
)
|
|
163
|
-
self.annotations = AsyncAnnotationsClient(client_wrapper=self._client_wrapper)
|
|
164
|
-
self.users = AsyncUsersClient(client_wrapper=self._client_wrapper)
|
|
165
|
-
self.actions = AsyncActionsClient(client_wrapper=self._client_wrapper)
|
|
166
|
-
self.views = AsyncViewsClient(client_wrapper=self._client_wrapper)
|
|
167
|
-
self.files = AsyncFilesClient(client_wrapper=self._client_wrapper)
|
|
168
|
-
self.projects = AsyncProjectsClient(client_wrapper=self._client_wrapper)
|
|
169
|
-
self.ml = AsyncMlClient(client_wrapper=self._client_wrapper)
|
|
170
|
-
self.predictions = AsyncPredictionsClient(client_wrapper=self._client_wrapper)
|
|
171
|
-
self.tasks = AsyncTasksClient(client_wrapper=self._client_wrapper)
|
|
172
|
-
self.import_storage = AsyncImportStorageClient(client_wrapper=self._client_wrapper)
|
|
173
|
-
self.export_storage = AsyncExportStorageClient(client_wrapper=self._client_wrapper)
|
|
174
|
-
self.webhooks = AsyncWebhooksClient(client_wrapper=self._client_wrapper)
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
def _get_base_url(*, base_url: typing.Optional[str] = None, environment: LabelStudioEnvironment) -> str:
|
|
178
|
-
if base_url is not None:
|
|
179
|
-
return base_url
|
|
180
|
-
elif environment is not None:
|
|
181
|
-
return environment.value
|
|
182
|
-
else:
|
|
183
|
-
raise Exception("Please pass in either base_url or environment to construct the client")
|
|
24
|
+
self.tasks = AsyncTasksClientExt(client_wrapper=self._client_wrapper)
|
|
25
|
+
self.projects = AsyncProjectsClientExt(client_wrapper=self._client_wrapper)
|
|
@@ -17,7 +17,7 @@ class BaseClientWrapper:
|
|
|
17
17
|
headers: typing.Dict[str, str] = {
|
|
18
18
|
"X-Fern-Language": "Python",
|
|
19
19
|
"X-Fern-SDK-Name": "label-studio-sdk",
|
|
20
|
-
"X-Fern-SDK-Version": "0.0.
|
|
20
|
+
"X-Fern-SDK-Version": "0.0.121",
|
|
21
21
|
}
|
|
22
22
|
headers["Authorization"] = f"Token {self.api_key}"
|
|
23
23
|
return headers
|
|
@@ -106,7 +106,11 @@ def maybe_filter_request_body(
|
|
|
106
106
|
omit: typing.Optional[typing.Any],
|
|
107
107
|
) -> typing.Optional[typing.Any]:
|
|
108
108
|
if data is None:
|
|
109
|
-
return
|
|
109
|
+
return (
|
|
110
|
+
jsonable_encoder(request_options.get("additional_body_parameters", {}))
|
|
111
|
+
if request_options is not None
|
|
112
|
+
else None
|
|
113
|
+
)
|
|
110
114
|
elif not isinstance(data, typing.Mapping):
|
|
111
115
|
data_content = jsonable_encoder(data)
|
|
112
116
|
else:
|