label-studio-sdk 0.0.32__py3-none-any.whl → 1.0.0__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.
- label_studio_sdk/__init__.py +206 -6
- label_studio_sdk/_extensions/label_studio_tools/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/label_config.py +163 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/exceptions.py +2 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/io.py +228 -0
- label_studio_sdk/_extensions/label_studio_tools/core/utils/params.py +45 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/__init__.py +1 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/beam.py +34 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/example.py +17 -0
- label_studio_sdk/_extensions/label_studio_tools/etl/registry.py +67 -0
- label_studio_sdk/_extensions/label_studio_tools/postprocessing/__init__.py +0 -0
- label_studio_sdk/_extensions/label_studio_tools/postprocessing/video.py +97 -0
- label_studio_sdk/_legacy/__init__.py +11 -0
- label_studio_sdk/_legacy/client.py +471 -0
- label_studio_sdk/_legacy/exceptions.py +10 -0
- label_studio_sdk/_legacy/label_interface/__init__.py +1 -0
- label_studio_sdk/_legacy/label_interface/base.py +77 -0
- label_studio_sdk/_legacy/label_interface/control_tags.py +756 -0
- label_studio_sdk/_legacy/label_interface/data_examples.json +96 -0
- label_studio_sdk/_legacy/label_interface/interface.py +925 -0
- label_studio_sdk/_legacy/label_interface/label_tags.py +72 -0
- label_studio_sdk/_legacy/label_interface/object_tags.py +292 -0
- label_studio_sdk/_legacy/label_interface/region.py +43 -0
- label_studio_sdk/_legacy/objects.py +35 -0
- label_studio_sdk/{project.py → _legacy/project.py} +711 -258
- label_studio_sdk/_legacy/schema/label_config_schema.json +226 -0
- label_studio_sdk/{users.py → _legacy/users.py} +15 -13
- label_studio_sdk/{utils.py → _legacy/utils.py} +31 -30
- label_studio_sdk/{workspaces.py → _legacy/workspaces.py} +13 -11
- label_studio_sdk/actions/__init__.py +2 -0
- label_studio_sdk/actions/client.py +150 -0
- label_studio_sdk/annotations/__init__.py +2 -0
- label_studio_sdk/annotations/client.py +750 -0
- label_studio_sdk/client.py +164 -436
- label_studio_sdk/converter/__init__.py +7 -0
- label_studio_sdk/converter/audio.py +56 -0
- label_studio_sdk/converter/brush.py +452 -0
- label_studio_sdk/converter/converter.py +1175 -0
- label_studio_sdk/converter/exports/__init__.py +0 -0
- label_studio_sdk/converter/exports/csv.py +82 -0
- label_studio_sdk/converter/exports/csv2.py +103 -0
- label_studio_sdk/converter/funsd.py +85 -0
- label_studio_sdk/converter/imports/__init__.py +0 -0
- label_studio_sdk/converter/imports/coco.py +314 -0
- label_studio_sdk/converter/imports/colors.py +198 -0
- label_studio_sdk/converter/imports/label_config.py +45 -0
- label_studio_sdk/converter/imports/pathtrack.py +269 -0
- label_studio_sdk/converter/imports/yolo.py +236 -0
- label_studio_sdk/converter/main.py +202 -0
- label_studio_sdk/converter/utils.py +473 -0
- label_studio_sdk/core/__init__.py +33 -0
- label_studio_sdk/core/api_error.py +15 -0
- label_studio_sdk/core/client_wrapper.py +55 -0
- label_studio_sdk/core/datetime_utils.py +28 -0
- label_studio_sdk/core/file.py +38 -0
- label_studio_sdk/core/http_client.py +443 -0
- label_studio_sdk/core/jsonable_encoder.py +99 -0
- label_studio_sdk/core/pagination.py +87 -0
- label_studio_sdk/core/pydantic_utilities.py +28 -0
- label_studio_sdk/core/query_encoder.py +33 -0
- label_studio_sdk/core/remove_none_from_dict.py +11 -0
- label_studio_sdk/core/request_options.py +32 -0
- label_studio_sdk/data_manager.py +32 -23
- label_studio_sdk/environment.py +7 -0
- label_studio_sdk/errors/__init__.py +6 -0
- label_studio_sdk/errors/bad_request_error.py +8 -0
- label_studio_sdk/errors/internal_server_error.py +8 -0
- label_studio_sdk/export_storage/__init__.py +28 -0
- label_studio_sdk/export_storage/azure/__init__.py +5 -0
- label_studio_sdk/export_storage/azure/client.py +722 -0
- label_studio_sdk/export_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/export_storage/azure/types/azure_create_response.py +52 -0
- label_studio_sdk/export_storage/azure/types/azure_update_response.py +52 -0
- label_studio_sdk/export_storage/client.py +107 -0
- label_studio_sdk/export_storage/gcs/__init__.py +5 -0
- label_studio_sdk/export_storage/gcs/client.py +722 -0
- label_studio_sdk/export_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +52 -0
- label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +52 -0
- label_studio_sdk/export_storage/local/__init__.py +5 -0
- label_studio_sdk/export_storage/local/client.py +688 -0
- label_studio_sdk/export_storage/local/types/__init__.py +6 -0
- label_studio_sdk/export_storage/local/types/local_create_response.py +47 -0
- label_studio_sdk/export_storage/local/types/local_update_response.py +47 -0
- label_studio_sdk/export_storage/redis/__init__.py +5 -0
- label_studio_sdk/export_storage/redis/client.py +714 -0
- label_studio_sdk/export_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/export_storage/redis/types/redis_create_response.py +57 -0
- label_studio_sdk/export_storage/redis/types/redis_update_response.py +57 -0
- label_studio_sdk/export_storage/s3/__init__.py +5 -0
- label_studio_sdk/export_storage/s3/client.py +820 -0
- label_studio_sdk/export_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/export_storage/s3/types/s3create_response.py +74 -0
- label_studio_sdk/export_storage/s3/types/s3update_response.py +74 -0
- label_studio_sdk/export_storage/types/__init__.py +5 -0
- label_studio_sdk/export_storage/types/export_storage_list_types_response_item.py +30 -0
- label_studio_sdk/files/__init__.py +2 -0
- label_studio_sdk/files/client.py +556 -0
- label_studio_sdk/import_storage/__init__.py +28 -0
- label_studio_sdk/import_storage/azure/__init__.py +5 -0
- label_studio_sdk/import_storage/azure/client.py +812 -0
- label_studio_sdk/import_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/import_storage/azure/types/azure_create_response.py +72 -0
- label_studio_sdk/import_storage/azure/types/azure_update_response.py +72 -0
- label_studio_sdk/import_storage/client.py +107 -0
- label_studio_sdk/import_storage/gcs/__init__.py +5 -0
- label_studio_sdk/import_storage/gcs/client.py +812 -0
- label_studio_sdk/import_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +72 -0
- label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +72 -0
- label_studio_sdk/import_storage/local/__init__.py +5 -0
- label_studio_sdk/import_storage/local/client.py +690 -0
- label_studio_sdk/import_storage/local/types/__init__.py +6 -0
- label_studio_sdk/import_storage/local/types/local_create_response.py +47 -0
- label_studio_sdk/import_storage/local/types/local_update_response.py +47 -0
- label_studio_sdk/import_storage/redis/__init__.py +5 -0
- label_studio_sdk/import_storage/redis/client.py +768 -0
- label_studio_sdk/import_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/import_storage/redis/types/redis_create_response.py +62 -0
- label_studio_sdk/import_storage/redis/types/redis_update_response.py +62 -0
- label_studio_sdk/import_storage/s3/__init__.py +5 -0
- label_studio_sdk/import_storage/s3/client.py +912 -0
- label_studio_sdk/import_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/import_storage/s3/types/s3create_response.py +99 -0
- label_studio_sdk/import_storage/s3/types/s3update_response.py +99 -0
- label_studio_sdk/import_storage/types/__init__.py +5 -0
- label_studio_sdk/import_storage/types/import_storage_list_types_response_item.py +30 -0
- label_studio_sdk/ml/__init__.py +19 -0
- label_studio_sdk/ml/client.py +981 -0
- label_studio_sdk/ml/types/__init__.py +17 -0
- label_studio_sdk/ml/types/ml_create_request_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_create_response.py +78 -0
- label_studio_sdk/ml/types/ml_create_response_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_update_request_auth_method.py +5 -0
- label_studio_sdk/ml/types/ml_update_response.py +78 -0
- label_studio_sdk/ml/types/ml_update_response_auth_method.py +5 -0
- label_studio_sdk/predictions/__init__.py +2 -0
- label_studio_sdk/predictions/client.py +638 -0
- label_studio_sdk/projects/__init__.py +6 -0
- label_studio_sdk/projects/client.py +1053 -0
- label_studio_sdk/projects/exports/__init__.py +2 -0
- label_studio_sdk/projects/exports/client.py +930 -0
- label_studio_sdk/projects/types/__init__.py +7 -0
- label_studio_sdk/projects/types/projects_create_response.py +96 -0
- label_studio_sdk/projects/types/projects_import_tasks_response.py +71 -0
- label_studio_sdk/projects/types/projects_list_response.py +33 -0
- label_studio_sdk/py.typed +0 -0
- label_studio_sdk/tasks/__init__.py +5 -0
- label_studio_sdk/tasks/client.py +811 -0
- label_studio_sdk/tasks/types/__init__.py +6 -0
- label_studio_sdk/tasks/types/tasks_list_request_fields.py +5 -0
- label_studio_sdk/tasks/types/tasks_list_response.py +48 -0
- label_studio_sdk/types/__init__.py +115 -0
- label_studio_sdk/types/annotation.py +116 -0
- label_studio_sdk/types/annotation_filter_options.py +42 -0
- label_studio_sdk/types/annotation_last_action.py +19 -0
- label_studio_sdk/types/azure_blob_export_storage.py +112 -0
- label_studio_sdk/types/azure_blob_export_storage_status.py +7 -0
- label_studio_sdk/types/azure_blob_import_storage.py +113 -0
- label_studio_sdk/types/azure_blob_import_storage_status.py +7 -0
- label_studio_sdk/types/base_task.py +113 -0
- label_studio_sdk/types/base_user.py +42 -0
- label_studio_sdk/types/converted_format.py +36 -0
- label_studio_sdk/types/converted_format_status.py +5 -0
- label_studio_sdk/types/export.py +48 -0
- label_studio_sdk/types/export_convert.py +32 -0
- label_studio_sdk/types/export_create.py +54 -0
- label_studio_sdk/types/export_create_status.py +5 -0
- label_studio_sdk/types/export_status.py +5 -0
- label_studio_sdk/types/file_upload.py +30 -0
- label_studio_sdk/types/filter.py +53 -0
- label_studio_sdk/types/filter_group.py +35 -0
- label_studio_sdk/types/gcs_export_storage.py +112 -0
- label_studio_sdk/types/gcs_export_storage_status.py +7 -0
- label_studio_sdk/types/gcs_import_storage.py +113 -0
- label_studio_sdk/types/gcs_import_storage_status.py +7 -0
- label_studio_sdk/types/local_files_export_storage.py +97 -0
- label_studio_sdk/types/local_files_export_storage_status.py +7 -0
- label_studio_sdk/types/local_files_import_storage.py +92 -0
- label_studio_sdk/types/local_files_import_storage_status.py +7 -0
- label_studio_sdk/types/ml_backend.py +89 -0
- label_studio_sdk/types/ml_backend_auth_method.py +5 -0
- label_studio_sdk/types/ml_backend_state.py +5 -0
- label_studio_sdk/types/prediction.py +78 -0
- label_studio_sdk/types/project.py +198 -0
- label_studio_sdk/types/project_import.py +63 -0
- label_studio_sdk/types/project_import_status.py +5 -0
- label_studio_sdk/types/project_label_config.py +32 -0
- label_studio_sdk/types/project_sampling.py +7 -0
- label_studio_sdk/types/project_skip_queue.py +5 -0
- label_studio_sdk/types/redis_export_storage.py +117 -0
- label_studio_sdk/types/redis_export_storage_status.py +7 -0
- label_studio_sdk/types/redis_import_storage.py +112 -0
- label_studio_sdk/types/redis_import_storage_status.py +7 -0
- label_studio_sdk/types/s3export_storage.py +134 -0
- label_studio_sdk/types/s3export_storage_status.py +7 -0
- label_studio_sdk/types/s3import_storage.py +140 -0
- label_studio_sdk/types/s3import_storage_status.py +7 -0
- label_studio_sdk/types/serialization_option.py +36 -0
- label_studio_sdk/types/serialization_options.py +45 -0
- label_studio_sdk/types/task.py +157 -0
- label_studio_sdk/types/task_filter_options.py +49 -0
- label_studio_sdk/types/user_simple.py +37 -0
- label_studio_sdk/types/view.py +55 -0
- label_studio_sdk/types/webhook.py +67 -0
- label_studio_sdk/types/webhook_actions_item.py +21 -0
- label_studio_sdk/types/webhook_serializer_for_update.py +67 -0
- label_studio_sdk/types/webhook_serializer_for_update_actions_item.py +21 -0
- label_studio_sdk/users/__init__.py +5 -0
- label_studio_sdk/users/client.py +830 -0
- label_studio_sdk/users/types/__init__.py +6 -0
- label_studio_sdk/users/types/users_get_token_response.py +36 -0
- label_studio_sdk/users/types/users_reset_token_response.py +36 -0
- label_studio_sdk/version.py +4 -0
- label_studio_sdk/views/__init__.py +31 -0
- label_studio_sdk/views/client.py +564 -0
- label_studio_sdk/views/types/__init__.py +29 -0
- label_studio_sdk/views/types/views_create_request_data.py +43 -0
- label_studio_sdk/views/types/views_create_request_data_filters.py +43 -0
- label_studio_sdk/views/types/views_create_request_data_filters_conjunction.py +5 -0
- label_studio_sdk/views/types/views_create_request_data_filters_items_item.py +47 -0
- label_studio_sdk/views/types/views_create_request_data_ordering_item.py +38 -0
- label_studio_sdk/views/types/views_create_request_data_ordering_item_direction.py +5 -0
- label_studio_sdk/views/types/views_update_request_data.py +43 -0
- label_studio_sdk/views/types/views_update_request_data_filters.py +43 -0
- label_studio_sdk/views/types/views_update_request_data_filters_conjunction.py +5 -0
- label_studio_sdk/views/types/views_update_request_data_filters_items_item.py +47 -0
- label_studio_sdk/views/types/views_update_request_data_ordering_item.py +38 -0
- label_studio_sdk/views/types/views_update_request_data_ordering_item_direction.py +5 -0
- label_studio_sdk/webhooks/__init__.py +5 -0
- label_studio_sdk/webhooks/client.py +636 -0
- label_studio_sdk/webhooks/types/__init__.py +5 -0
- label_studio_sdk/webhooks/types/webhooks_update_request_actions_item.py +21 -0
- label_studio_sdk-1.0.0.dist-info/METADATA +307 -0
- label_studio_sdk-1.0.0.dist-info/RECORD +239 -0
- {label_studio_sdk-0.0.32.dist-info → label_studio_sdk-1.0.0.dist-info}/WHEEL +1 -2
- docs/__init__.py +0 -3
- label_studio_sdk-0.0.32.dist-info/LICENSE +0 -201
- label_studio_sdk-0.0.32.dist-info/METADATA +0 -22
- label_studio_sdk-0.0.32.dist-info/RECORD +0 -15
- label_studio_sdk-0.0.32.dist-info/top_level.txt +0 -3
- tests/test_client.py +0 -26
- {tests → label_studio_sdk/_extensions}/__init__.py +0 -0
|
@@ -0,0 +1,912 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ...core.api_error import ApiError
|
|
7
|
+
from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ...core.jsonable_encoder import jsonable_encoder
|
|
9
|
+
from ...core.pydantic_utilities import pydantic_v1
|
|
10
|
+
from ...core.request_options import RequestOptions
|
|
11
|
+
from ...types.s3import_storage import S3ImportStorage
|
|
12
|
+
from .types.s3create_response import S3CreateResponse
|
|
13
|
+
from .types.s3update_response import S3UpdateResponse
|
|
14
|
+
|
|
15
|
+
# this is used as the default value for optional parameters
|
|
16
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class S3Client:
|
|
20
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
21
|
+
self._client_wrapper = client_wrapper
|
|
22
|
+
|
|
23
|
+
def list(
|
|
24
|
+
self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
|
|
25
|
+
) -> typing.List[S3ImportStorage]:
|
|
26
|
+
"""
|
|
27
|
+
You can connect your S3 bucket to Label Studio as a source storage or target storage. Use this API request to get a list of all Google import (source) storage connections for a specific project.
|
|
28
|
+
|
|
29
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
30
|
+
|
|
31
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
32
|
+
|
|
33
|
+
Parameters
|
|
34
|
+
----------
|
|
35
|
+
project : typing.Optional[int]
|
|
36
|
+
Project ID
|
|
37
|
+
|
|
38
|
+
request_options : typing.Optional[RequestOptions]
|
|
39
|
+
Request-specific configuration.
|
|
40
|
+
|
|
41
|
+
Returns
|
|
42
|
+
-------
|
|
43
|
+
typing.List[S3ImportStorage]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
Examples
|
|
47
|
+
--------
|
|
48
|
+
from label_studio_sdk.client import LabelStudio
|
|
49
|
+
|
|
50
|
+
client = LabelStudio(
|
|
51
|
+
api_key="YOUR_API_KEY",
|
|
52
|
+
)
|
|
53
|
+
client.import_storage.s3.list()
|
|
54
|
+
"""
|
|
55
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
56
|
+
"api/storages/s3/", method="GET", params={"project": project}, request_options=request_options
|
|
57
|
+
)
|
|
58
|
+
if 200 <= _response.status_code < 300:
|
|
59
|
+
return pydantic_v1.parse_obj_as(typing.List[S3ImportStorage], _response.json()) # type: ignore
|
|
60
|
+
try:
|
|
61
|
+
_response_json = _response.json()
|
|
62
|
+
except JSONDecodeError:
|
|
63
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
64
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
65
|
+
|
|
66
|
+
def create(
|
|
67
|
+
self,
|
|
68
|
+
*,
|
|
69
|
+
project: typing.Optional[int] = OMIT,
|
|
70
|
+
bucket: typing.Optional[str] = OMIT,
|
|
71
|
+
prefix: typing.Optional[str] = OMIT,
|
|
72
|
+
regex_filter: typing.Optional[str] = OMIT,
|
|
73
|
+
use_blob_urls: typing.Optional[bool] = OMIT,
|
|
74
|
+
aws_access_key_id: typing.Optional[str] = OMIT,
|
|
75
|
+
aws_secret_access_key: typing.Optional[str] = OMIT,
|
|
76
|
+
aws_session_token: typing.Optional[str] = OMIT,
|
|
77
|
+
aws_sse_kms_key_id: typing.Optional[str] = OMIT,
|
|
78
|
+
region_name: typing.Optional[str] = OMIT,
|
|
79
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
80
|
+
presign: typing.Optional[bool] = OMIT,
|
|
81
|
+
presign_ttl: typing.Optional[int] = OMIT,
|
|
82
|
+
recursive_scan: typing.Optional[bool] = OMIT,
|
|
83
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
84
|
+
) -> S3CreateResponse:
|
|
85
|
+
"""
|
|
86
|
+
Create a new source storage connection to a S3 bucket.
|
|
87
|
+
|
|
88
|
+
For information about the required fields and prerequisites, see [Amazon S3](https://labelstud.io/guide/storage#Amazon-S3) in the Label Studio documentation.
|
|
89
|
+
|
|
90
|
+
<Info>Ensure you configure CORS before adding cloud storage. This ensures you will be able to see the content of the data rather than just a link.</Info>
|
|
91
|
+
|
|
92
|
+
<Tip>After you add the storage, you should validate the connection before attempting to sync your data. Your data will not be imported until you [sync your connection](sync).</Tip>
|
|
93
|
+
|
|
94
|
+
Parameters
|
|
95
|
+
----------
|
|
96
|
+
project : typing.Optional[int]
|
|
97
|
+
Project ID
|
|
98
|
+
|
|
99
|
+
bucket : typing.Optional[str]
|
|
100
|
+
S3 bucket name
|
|
101
|
+
|
|
102
|
+
prefix : typing.Optional[str]
|
|
103
|
+
S3 bucket prefix
|
|
104
|
+
|
|
105
|
+
regex_filter : typing.Optional[str]
|
|
106
|
+
Cloud storage regex for filtering objects
|
|
107
|
+
|
|
108
|
+
use_blob_urls : typing.Optional[bool]
|
|
109
|
+
Interpret objects as BLOBs and generate URLs
|
|
110
|
+
|
|
111
|
+
aws_access_key_id : typing.Optional[str]
|
|
112
|
+
AWS_ACCESS_KEY_ID
|
|
113
|
+
|
|
114
|
+
aws_secret_access_key : typing.Optional[str]
|
|
115
|
+
AWS_SECRET_ACCESS_KEY
|
|
116
|
+
|
|
117
|
+
aws_session_token : typing.Optional[str]
|
|
118
|
+
AWS_SESSION_TOKEN
|
|
119
|
+
|
|
120
|
+
aws_sse_kms_key_id : typing.Optional[str]
|
|
121
|
+
AWS SSE KMS Key ID
|
|
122
|
+
|
|
123
|
+
region_name : typing.Optional[str]
|
|
124
|
+
AWS Region
|
|
125
|
+
|
|
126
|
+
s3endpoint : typing.Optional[str]
|
|
127
|
+
S3 Endpoint
|
|
128
|
+
|
|
129
|
+
presign : typing.Optional[bool]
|
|
130
|
+
Presign URLs for download
|
|
131
|
+
|
|
132
|
+
presign_ttl : typing.Optional[int]
|
|
133
|
+
Presign TTL in seconds
|
|
134
|
+
|
|
135
|
+
recursive_scan : typing.Optional[bool]
|
|
136
|
+
Scan recursively
|
|
137
|
+
|
|
138
|
+
request_options : typing.Optional[RequestOptions]
|
|
139
|
+
Request-specific configuration.
|
|
140
|
+
|
|
141
|
+
Returns
|
|
142
|
+
-------
|
|
143
|
+
S3CreateResponse
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
Examples
|
|
147
|
+
--------
|
|
148
|
+
from label_studio_sdk.client import LabelStudio
|
|
149
|
+
|
|
150
|
+
client = LabelStudio(
|
|
151
|
+
api_key="YOUR_API_KEY",
|
|
152
|
+
)
|
|
153
|
+
client.import_storage.s3.create()
|
|
154
|
+
"""
|
|
155
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
156
|
+
"api/storages/s3/",
|
|
157
|
+
method="POST",
|
|
158
|
+
json={
|
|
159
|
+
"project": project,
|
|
160
|
+
"bucket": bucket,
|
|
161
|
+
"prefix": prefix,
|
|
162
|
+
"regex_filter": regex_filter,
|
|
163
|
+
"use_blob_urls": use_blob_urls,
|
|
164
|
+
"aws_access_key_id": aws_access_key_id,
|
|
165
|
+
"aws_secret_access_key": aws_secret_access_key,
|
|
166
|
+
"aws_session_token": aws_session_token,
|
|
167
|
+
"aws_sse_kms_key_id": aws_sse_kms_key_id,
|
|
168
|
+
"region_name": region_name,
|
|
169
|
+
"s3_endpoint": s3endpoint,
|
|
170
|
+
"presign": presign,
|
|
171
|
+
"presign_ttl": presign_ttl,
|
|
172
|
+
"recursive_scan": recursive_scan,
|
|
173
|
+
},
|
|
174
|
+
request_options=request_options,
|
|
175
|
+
omit=OMIT,
|
|
176
|
+
)
|
|
177
|
+
if 200 <= _response.status_code < 300:
|
|
178
|
+
return pydantic_v1.parse_obj_as(S3CreateResponse, _response.json()) # type: ignore
|
|
179
|
+
try:
|
|
180
|
+
_response_json = _response.json()
|
|
181
|
+
except JSONDecodeError:
|
|
182
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
183
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
184
|
+
|
|
185
|
+
def validate(self, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
|
|
186
|
+
"""
|
|
187
|
+
Validate a specific S3 import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import data.
|
|
188
|
+
|
|
189
|
+
Parameters
|
|
190
|
+
----------
|
|
191
|
+
request_options : typing.Optional[RequestOptions]
|
|
192
|
+
Request-specific configuration.
|
|
193
|
+
|
|
194
|
+
Returns
|
|
195
|
+
-------
|
|
196
|
+
S3ImportStorage
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
Examples
|
|
200
|
+
--------
|
|
201
|
+
from label_studio_sdk.client import LabelStudio
|
|
202
|
+
|
|
203
|
+
client = LabelStudio(
|
|
204
|
+
api_key="YOUR_API_KEY",
|
|
205
|
+
)
|
|
206
|
+
client.import_storage.s3.validate()
|
|
207
|
+
"""
|
|
208
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
209
|
+
"api/storages/s3/validate", method="POST", request_options=request_options
|
|
210
|
+
)
|
|
211
|
+
if 200 <= _response.status_code < 300:
|
|
212
|
+
return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
|
|
213
|
+
try:
|
|
214
|
+
_response_json = _response.json()
|
|
215
|
+
except JSONDecodeError:
|
|
216
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
217
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
218
|
+
|
|
219
|
+
def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
|
|
220
|
+
"""
|
|
221
|
+
Get a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
|
|
222
|
+
|
|
223
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
224
|
+
|
|
225
|
+
Parameters
|
|
226
|
+
----------
|
|
227
|
+
id : int
|
|
228
|
+
A unique integer value identifying this s3 import storage.
|
|
229
|
+
|
|
230
|
+
request_options : typing.Optional[RequestOptions]
|
|
231
|
+
Request-specific configuration.
|
|
232
|
+
|
|
233
|
+
Returns
|
|
234
|
+
-------
|
|
235
|
+
S3ImportStorage
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
Examples
|
|
239
|
+
--------
|
|
240
|
+
from label_studio_sdk.client import LabelStudio
|
|
241
|
+
|
|
242
|
+
client = LabelStudio(
|
|
243
|
+
api_key="YOUR_API_KEY",
|
|
244
|
+
)
|
|
245
|
+
client.import_storage.s3.get(
|
|
246
|
+
id=1,
|
|
247
|
+
)
|
|
248
|
+
"""
|
|
249
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
250
|
+
f"api/storages/s3/{jsonable_encoder(id)}", method="GET", request_options=request_options
|
|
251
|
+
)
|
|
252
|
+
if 200 <= _response.status_code < 300:
|
|
253
|
+
return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
|
|
254
|
+
try:
|
|
255
|
+
_response_json = _response.json()
|
|
256
|
+
except JSONDecodeError:
|
|
257
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
258
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
259
|
+
|
|
260
|
+
def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
261
|
+
"""
|
|
262
|
+
Delete a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
|
|
263
|
+
|
|
264
|
+
Deleting a source storage connection does not affect tasks with synced data in Label Studio. The sync process is designed to import new or updated tasks from the connected storage into the project, but it does not track deletions of files from the storage. Therefore, if you remove the external storage connection, the tasks that were created from that storage will remain in the project.
|
|
265
|
+
|
|
266
|
+
If you want to remove the tasks that were synced from the external storage, you will need to delete them manually from within the Label Studio UI or use the [Delete tasks](../../tasks/delete-all-tasks) API.
|
|
267
|
+
|
|
268
|
+
Parameters
|
|
269
|
+
----------
|
|
270
|
+
id : int
|
|
271
|
+
A unique integer value identifying this s3 import storage.
|
|
272
|
+
|
|
273
|
+
request_options : typing.Optional[RequestOptions]
|
|
274
|
+
Request-specific configuration.
|
|
275
|
+
|
|
276
|
+
Returns
|
|
277
|
+
-------
|
|
278
|
+
None
|
|
279
|
+
|
|
280
|
+
Examples
|
|
281
|
+
--------
|
|
282
|
+
from label_studio_sdk.client import LabelStudio
|
|
283
|
+
|
|
284
|
+
client = LabelStudio(
|
|
285
|
+
api_key="YOUR_API_KEY",
|
|
286
|
+
)
|
|
287
|
+
client.import_storage.s3.delete(
|
|
288
|
+
id=1,
|
|
289
|
+
)
|
|
290
|
+
"""
|
|
291
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
292
|
+
f"api/storages/s3/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
|
|
293
|
+
)
|
|
294
|
+
if 200 <= _response.status_code < 300:
|
|
295
|
+
return
|
|
296
|
+
try:
|
|
297
|
+
_response_json = _response.json()
|
|
298
|
+
except JSONDecodeError:
|
|
299
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
300
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
301
|
+
|
|
302
|
+
def update(
|
|
303
|
+
self,
|
|
304
|
+
id: int,
|
|
305
|
+
*,
|
|
306
|
+
project: typing.Optional[int] = OMIT,
|
|
307
|
+
bucket: typing.Optional[str] = OMIT,
|
|
308
|
+
prefix: typing.Optional[str] = OMIT,
|
|
309
|
+
regex_filter: typing.Optional[str] = OMIT,
|
|
310
|
+
use_blob_urls: typing.Optional[bool] = OMIT,
|
|
311
|
+
aws_access_key_id: typing.Optional[str] = OMIT,
|
|
312
|
+
aws_secret_access_key: typing.Optional[str] = OMIT,
|
|
313
|
+
aws_session_token: typing.Optional[str] = OMIT,
|
|
314
|
+
aws_sse_kms_key_id: typing.Optional[str] = OMIT,
|
|
315
|
+
region_name: typing.Optional[str] = OMIT,
|
|
316
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
317
|
+
presign: typing.Optional[bool] = OMIT,
|
|
318
|
+
presign_ttl: typing.Optional[int] = OMIT,
|
|
319
|
+
recursive_scan: typing.Optional[bool] = OMIT,
|
|
320
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
321
|
+
) -> S3UpdateResponse:
|
|
322
|
+
"""
|
|
323
|
+
Update a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
|
|
324
|
+
|
|
325
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
326
|
+
|
|
327
|
+
Parameters
|
|
328
|
+
----------
|
|
329
|
+
id : int
|
|
330
|
+
A unique integer value identifying this s3 import storage.
|
|
331
|
+
|
|
332
|
+
project : typing.Optional[int]
|
|
333
|
+
Project ID
|
|
334
|
+
|
|
335
|
+
bucket : typing.Optional[str]
|
|
336
|
+
S3 bucket name
|
|
337
|
+
|
|
338
|
+
prefix : typing.Optional[str]
|
|
339
|
+
S3 bucket prefix
|
|
340
|
+
|
|
341
|
+
regex_filter : typing.Optional[str]
|
|
342
|
+
Cloud storage regex for filtering objects
|
|
343
|
+
|
|
344
|
+
use_blob_urls : typing.Optional[bool]
|
|
345
|
+
Interpret objects as BLOBs and generate URLs
|
|
346
|
+
|
|
347
|
+
aws_access_key_id : typing.Optional[str]
|
|
348
|
+
AWS_ACCESS_KEY_ID
|
|
349
|
+
|
|
350
|
+
aws_secret_access_key : typing.Optional[str]
|
|
351
|
+
AWS_SECRET_ACCESS_KEY
|
|
352
|
+
|
|
353
|
+
aws_session_token : typing.Optional[str]
|
|
354
|
+
AWS_SESSION_TOKEN
|
|
355
|
+
|
|
356
|
+
aws_sse_kms_key_id : typing.Optional[str]
|
|
357
|
+
AWS SSE KMS Key ID
|
|
358
|
+
|
|
359
|
+
region_name : typing.Optional[str]
|
|
360
|
+
AWS Region
|
|
361
|
+
|
|
362
|
+
s3endpoint : typing.Optional[str]
|
|
363
|
+
S3 Endpoint
|
|
364
|
+
|
|
365
|
+
presign : typing.Optional[bool]
|
|
366
|
+
Presign URLs for download
|
|
367
|
+
|
|
368
|
+
presign_ttl : typing.Optional[int]
|
|
369
|
+
Presign TTL in seconds
|
|
370
|
+
|
|
371
|
+
recursive_scan : typing.Optional[bool]
|
|
372
|
+
Scan recursively
|
|
373
|
+
|
|
374
|
+
request_options : typing.Optional[RequestOptions]
|
|
375
|
+
Request-specific configuration.
|
|
376
|
+
|
|
377
|
+
Returns
|
|
378
|
+
-------
|
|
379
|
+
S3UpdateResponse
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
Examples
|
|
383
|
+
--------
|
|
384
|
+
from label_studio_sdk.client import LabelStudio
|
|
385
|
+
|
|
386
|
+
client = LabelStudio(
|
|
387
|
+
api_key="YOUR_API_KEY",
|
|
388
|
+
)
|
|
389
|
+
client.import_storage.s3.update(
|
|
390
|
+
id=1,
|
|
391
|
+
)
|
|
392
|
+
"""
|
|
393
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
394
|
+
f"api/storages/s3/{jsonable_encoder(id)}",
|
|
395
|
+
method="PATCH",
|
|
396
|
+
json={
|
|
397
|
+
"project": project,
|
|
398
|
+
"bucket": bucket,
|
|
399
|
+
"prefix": prefix,
|
|
400
|
+
"regex_filter": regex_filter,
|
|
401
|
+
"use_blob_urls": use_blob_urls,
|
|
402
|
+
"aws_access_key_id": aws_access_key_id,
|
|
403
|
+
"aws_secret_access_key": aws_secret_access_key,
|
|
404
|
+
"aws_session_token": aws_session_token,
|
|
405
|
+
"aws_sse_kms_key_id": aws_sse_kms_key_id,
|
|
406
|
+
"region_name": region_name,
|
|
407
|
+
"s3_endpoint": s3endpoint,
|
|
408
|
+
"presign": presign,
|
|
409
|
+
"presign_ttl": presign_ttl,
|
|
410
|
+
"recursive_scan": recursive_scan,
|
|
411
|
+
},
|
|
412
|
+
request_options=request_options,
|
|
413
|
+
omit=OMIT,
|
|
414
|
+
)
|
|
415
|
+
if 200 <= _response.status_code < 300:
|
|
416
|
+
return pydantic_v1.parse_obj_as(S3UpdateResponse, _response.json()) # type: ignore
|
|
417
|
+
try:
|
|
418
|
+
_response_json = _response.json()
|
|
419
|
+
except JSONDecodeError:
|
|
420
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
421
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
422
|
+
|
|
423
|
+
def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
|
|
424
|
+
"""
|
|
425
|
+
Sync tasks from an S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
|
|
426
|
+
|
|
427
|
+
Sync operations with external buckets only go one way. They either create tasks from objects in the bucket (source/import storage) or push annotations to the output bucket (export/target storage). Changing something on the bucket side doesn’t guarantee consistency in results.
|
|
428
|
+
|
|
429
|
+
<Note>Before proceeding, you should review [How sync operations work - Source storage](https://labelstud.io/guide/storage#Source-storage) to ensure that your data remains secure and private.</Note>
|
|
430
|
+
|
|
431
|
+
Parameters
|
|
432
|
+
----------
|
|
433
|
+
id : int
|
|
434
|
+
Storage ID
|
|
435
|
+
|
|
436
|
+
request_options : typing.Optional[RequestOptions]
|
|
437
|
+
Request-specific configuration.
|
|
438
|
+
|
|
439
|
+
Returns
|
|
440
|
+
-------
|
|
441
|
+
S3ImportStorage
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
Examples
|
|
445
|
+
--------
|
|
446
|
+
from label_studio_sdk.client import LabelStudio
|
|
447
|
+
|
|
448
|
+
client = LabelStudio(
|
|
449
|
+
api_key="YOUR_API_KEY",
|
|
450
|
+
)
|
|
451
|
+
client.import_storage.s3.sync(
|
|
452
|
+
id=1,
|
|
453
|
+
)
|
|
454
|
+
"""
|
|
455
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
456
|
+
f"api/storages/s3/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
|
|
457
|
+
)
|
|
458
|
+
if 200 <= _response.status_code < 300:
|
|
459
|
+
return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
|
|
460
|
+
try:
|
|
461
|
+
_response_json = _response.json()
|
|
462
|
+
except JSONDecodeError:
|
|
463
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
464
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
class AsyncS3Client:
|
|
468
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
469
|
+
self._client_wrapper = client_wrapper
|
|
470
|
+
|
|
471
|
+
async def list(
|
|
472
|
+
self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
|
|
473
|
+
) -> typing.List[S3ImportStorage]:
|
|
474
|
+
"""
|
|
475
|
+
You can connect your S3 bucket to Label Studio as a source storage or target storage. Use this API request to get a list of all Google import (source) storage connections for a specific project.
|
|
476
|
+
|
|
477
|
+
The project ID can be found in the URL when viewing the project in Label Studio, or you can retrieve all project IDs using [List all projects](../projects/list).
|
|
478
|
+
|
|
479
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
480
|
+
|
|
481
|
+
Parameters
|
|
482
|
+
----------
|
|
483
|
+
project : typing.Optional[int]
|
|
484
|
+
Project ID
|
|
485
|
+
|
|
486
|
+
request_options : typing.Optional[RequestOptions]
|
|
487
|
+
Request-specific configuration.
|
|
488
|
+
|
|
489
|
+
Returns
|
|
490
|
+
-------
|
|
491
|
+
typing.List[S3ImportStorage]
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
Examples
|
|
495
|
+
--------
|
|
496
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
497
|
+
|
|
498
|
+
client = AsyncLabelStudio(
|
|
499
|
+
api_key="YOUR_API_KEY",
|
|
500
|
+
)
|
|
501
|
+
await client.import_storage.s3.list()
|
|
502
|
+
"""
|
|
503
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
504
|
+
"api/storages/s3/", method="GET", params={"project": project}, request_options=request_options
|
|
505
|
+
)
|
|
506
|
+
if 200 <= _response.status_code < 300:
|
|
507
|
+
return pydantic_v1.parse_obj_as(typing.List[S3ImportStorage], _response.json()) # type: ignore
|
|
508
|
+
try:
|
|
509
|
+
_response_json = _response.json()
|
|
510
|
+
except JSONDecodeError:
|
|
511
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
512
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
513
|
+
|
|
514
|
+
async def create(
|
|
515
|
+
self,
|
|
516
|
+
*,
|
|
517
|
+
project: typing.Optional[int] = OMIT,
|
|
518
|
+
bucket: typing.Optional[str] = OMIT,
|
|
519
|
+
prefix: typing.Optional[str] = OMIT,
|
|
520
|
+
regex_filter: typing.Optional[str] = OMIT,
|
|
521
|
+
use_blob_urls: typing.Optional[bool] = OMIT,
|
|
522
|
+
aws_access_key_id: typing.Optional[str] = OMIT,
|
|
523
|
+
aws_secret_access_key: typing.Optional[str] = OMIT,
|
|
524
|
+
aws_session_token: typing.Optional[str] = OMIT,
|
|
525
|
+
aws_sse_kms_key_id: typing.Optional[str] = OMIT,
|
|
526
|
+
region_name: typing.Optional[str] = OMIT,
|
|
527
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
528
|
+
presign: typing.Optional[bool] = OMIT,
|
|
529
|
+
presign_ttl: typing.Optional[int] = OMIT,
|
|
530
|
+
recursive_scan: typing.Optional[bool] = OMIT,
|
|
531
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
532
|
+
) -> S3CreateResponse:
|
|
533
|
+
"""
|
|
534
|
+
Create a new source storage connection to a S3 bucket.
|
|
535
|
+
|
|
536
|
+
For information about the required fields and prerequisites, see [Amazon S3](https://labelstud.io/guide/storage#Amazon-S3) in the Label Studio documentation.
|
|
537
|
+
|
|
538
|
+
<Info>Ensure you configure CORS before adding cloud storage. This ensures you will be able to see the content of the data rather than just a link.</Info>
|
|
539
|
+
|
|
540
|
+
<Tip>After you add the storage, you should validate the connection before attempting to sync your data. Your data will not be imported until you [sync your connection](sync).</Tip>
|
|
541
|
+
|
|
542
|
+
Parameters
|
|
543
|
+
----------
|
|
544
|
+
project : typing.Optional[int]
|
|
545
|
+
Project ID
|
|
546
|
+
|
|
547
|
+
bucket : typing.Optional[str]
|
|
548
|
+
S3 bucket name
|
|
549
|
+
|
|
550
|
+
prefix : typing.Optional[str]
|
|
551
|
+
S3 bucket prefix
|
|
552
|
+
|
|
553
|
+
regex_filter : typing.Optional[str]
|
|
554
|
+
Cloud storage regex for filtering objects
|
|
555
|
+
|
|
556
|
+
use_blob_urls : typing.Optional[bool]
|
|
557
|
+
Interpret objects as BLOBs and generate URLs
|
|
558
|
+
|
|
559
|
+
aws_access_key_id : typing.Optional[str]
|
|
560
|
+
AWS_ACCESS_KEY_ID
|
|
561
|
+
|
|
562
|
+
aws_secret_access_key : typing.Optional[str]
|
|
563
|
+
AWS_SECRET_ACCESS_KEY
|
|
564
|
+
|
|
565
|
+
aws_session_token : typing.Optional[str]
|
|
566
|
+
AWS_SESSION_TOKEN
|
|
567
|
+
|
|
568
|
+
aws_sse_kms_key_id : typing.Optional[str]
|
|
569
|
+
AWS SSE KMS Key ID
|
|
570
|
+
|
|
571
|
+
region_name : typing.Optional[str]
|
|
572
|
+
AWS Region
|
|
573
|
+
|
|
574
|
+
s3endpoint : typing.Optional[str]
|
|
575
|
+
S3 Endpoint
|
|
576
|
+
|
|
577
|
+
presign : typing.Optional[bool]
|
|
578
|
+
Presign URLs for download
|
|
579
|
+
|
|
580
|
+
presign_ttl : typing.Optional[int]
|
|
581
|
+
Presign TTL in seconds
|
|
582
|
+
|
|
583
|
+
recursive_scan : typing.Optional[bool]
|
|
584
|
+
Scan recursively
|
|
585
|
+
|
|
586
|
+
request_options : typing.Optional[RequestOptions]
|
|
587
|
+
Request-specific configuration.
|
|
588
|
+
|
|
589
|
+
Returns
|
|
590
|
+
-------
|
|
591
|
+
S3CreateResponse
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
Examples
|
|
595
|
+
--------
|
|
596
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
597
|
+
|
|
598
|
+
client = AsyncLabelStudio(
|
|
599
|
+
api_key="YOUR_API_KEY",
|
|
600
|
+
)
|
|
601
|
+
await client.import_storage.s3.create()
|
|
602
|
+
"""
|
|
603
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
604
|
+
"api/storages/s3/",
|
|
605
|
+
method="POST",
|
|
606
|
+
json={
|
|
607
|
+
"project": project,
|
|
608
|
+
"bucket": bucket,
|
|
609
|
+
"prefix": prefix,
|
|
610
|
+
"regex_filter": regex_filter,
|
|
611
|
+
"use_blob_urls": use_blob_urls,
|
|
612
|
+
"aws_access_key_id": aws_access_key_id,
|
|
613
|
+
"aws_secret_access_key": aws_secret_access_key,
|
|
614
|
+
"aws_session_token": aws_session_token,
|
|
615
|
+
"aws_sse_kms_key_id": aws_sse_kms_key_id,
|
|
616
|
+
"region_name": region_name,
|
|
617
|
+
"s3_endpoint": s3endpoint,
|
|
618
|
+
"presign": presign,
|
|
619
|
+
"presign_ttl": presign_ttl,
|
|
620
|
+
"recursive_scan": recursive_scan,
|
|
621
|
+
},
|
|
622
|
+
request_options=request_options,
|
|
623
|
+
omit=OMIT,
|
|
624
|
+
)
|
|
625
|
+
if 200 <= _response.status_code < 300:
|
|
626
|
+
return pydantic_v1.parse_obj_as(S3CreateResponse, _response.json()) # type: ignore
|
|
627
|
+
try:
|
|
628
|
+
_response_json = _response.json()
|
|
629
|
+
except JSONDecodeError:
|
|
630
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
631
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
632
|
+
|
|
633
|
+
async def validate(self, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
|
|
634
|
+
"""
|
|
635
|
+
Validate a specific S3 import storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to import data.
|
|
636
|
+
|
|
637
|
+
Parameters
|
|
638
|
+
----------
|
|
639
|
+
request_options : typing.Optional[RequestOptions]
|
|
640
|
+
Request-specific configuration.
|
|
641
|
+
|
|
642
|
+
Returns
|
|
643
|
+
-------
|
|
644
|
+
S3ImportStorage
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
Examples
|
|
648
|
+
--------
|
|
649
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
650
|
+
|
|
651
|
+
client = AsyncLabelStudio(
|
|
652
|
+
api_key="YOUR_API_KEY",
|
|
653
|
+
)
|
|
654
|
+
await client.import_storage.s3.validate()
|
|
655
|
+
"""
|
|
656
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
657
|
+
"api/storages/s3/validate", method="POST", request_options=request_options
|
|
658
|
+
)
|
|
659
|
+
if 200 <= _response.status_code < 300:
|
|
660
|
+
return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
|
|
661
|
+
try:
|
|
662
|
+
_response_json = _response.json()
|
|
663
|
+
except JSONDecodeError:
|
|
664
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
665
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
666
|
+
|
|
667
|
+
async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
|
|
668
|
+
"""
|
|
669
|
+
Get a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
|
|
670
|
+
|
|
671
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
672
|
+
|
|
673
|
+
Parameters
|
|
674
|
+
----------
|
|
675
|
+
id : int
|
|
676
|
+
A unique integer value identifying this s3 import storage.
|
|
677
|
+
|
|
678
|
+
request_options : typing.Optional[RequestOptions]
|
|
679
|
+
Request-specific configuration.
|
|
680
|
+
|
|
681
|
+
Returns
|
|
682
|
+
-------
|
|
683
|
+
S3ImportStorage
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
Examples
|
|
687
|
+
--------
|
|
688
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
689
|
+
|
|
690
|
+
client = AsyncLabelStudio(
|
|
691
|
+
api_key="YOUR_API_KEY",
|
|
692
|
+
)
|
|
693
|
+
await client.import_storage.s3.get(
|
|
694
|
+
id=1,
|
|
695
|
+
)
|
|
696
|
+
"""
|
|
697
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
698
|
+
f"api/storages/s3/{jsonable_encoder(id)}", method="GET", request_options=request_options
|
|
699
|
+
)
|
|
700
|
+
if 200 <= _response.status_code < 300:
|
|
701
|
+
return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
|
|
702
|
+
try:
|
|
703
|
+
_response_json = _response.json()
|
|
704
|
+
except JSONDecodeError:
|
|
705
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
706
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
707
|
+
|
|
708
|
+
async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
709
|
+
"""
|
|
710
|
+
Delete a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
|
|
711
|
+
|
|
712
|
+
Deleting a source storage connection does not affect tasks with synced data in Label Studio. The sync process is designed to import new or updated tasks from the connected storage into the project, but it does not track deletions of files from the storage. Therefore, if you remove the external storage connection, the tasks that were created from that storage will remain in the project.
|
|
713
|
+
|
|
714
|
+
If you want to remove the tasks that were synced from the external storage, you will need to delete them manually from within the Label Studio UI or use the [Delete tasks](../../tasks/delete-all-tasks) API.
|
|
715
|
+
|
|
716
|
+
Parameters
|
|
717
|
+
----------
|
|
718
|
+
id : int
|
|
719
|
+
A unique integer value identifying this s3 import storage.
|
|
720
|
+
|
|
721
|
+
request_options : typing.Optional[RequestOptions]
|
|
722
|
+
Request-specific configuration.
|
|
723
|
+
|
|
724
|
+
Returns
|
|
725
|
+
-------
|
|
726
|
+
None
|
|
727
|
+
|
|
728
|
+
Examples
|
|
729
|
+
--------
|
|
730
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
731
|
+
|
|
732
|
+
client = AsyncLabelStudio(
|
|
733
|
+
api_key="YOUR_API_KEY",
|
|
734
|
+
)
|
|
735
|
+
await client.import_storage.s3.delete(
|
|
736
|
+
id=1,
|
|
737
|
+
)
|
|
738
|
+
"""
|
|
739
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
740
|
+
f"api/storages/s3/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
|
|
741
|
+
)
|
|
742
|
+
if 200 <= _response.status_code < 300:
|
|
743
|
+
return
|
|
744
|
+
try:
|
|
745
|
+
_response_json = _response.json()
|
|
746
|
+
except JSONDecodeError:
|
|
747
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
748
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
749
|
+
|
|
750
|
+
async def update(
|
|
751
|
+
self,
|
|
752
|
+
id: int,
|
|
753
|
+
*,
|
|
754
|
+
project: typing.Optional[int] = OMIT,
|
|
755
|
+
bucket: typing.Optional[str] = OMIT,
|
|
756
|
+
prefix: typing.Optional[str] = OMIT,
|
|
757
|
+
regex_filter: typing.Optional[str] = OMIT,
|
|
758
|
+
use_blob_urls: typing.Optional[bool] = OMIT,
|
|
759
|
+
aws_access_key_id: typing.Optional[str] = OMIT,
|
|
760
|
+
aws_secret_access_key: typing.Optional[str] = OMIT,
|
|
761
|
+
aws_session_token: typing.Optional[str] = OMIT,
|
|
762
|
+
aws_sse_kms_key_id: typing.Optional[str] = OMIT,
|
|
763
|
+
region_name: typing.Optional[str] = OMIT,
|
|
764
|
+
s3endpoint: typing.Optional[str] = OMIT,
|
|
765
|
+
presign: typing.Optional[bool] = OMIT,
|
|
766
|
+
presign_ttl: typing.Optional[int] = OMIT,
|
|
767
|
+
recursive_scan: typing.Optional[bool] = OMIT,
|
|
768
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
769
|
+
) -> S3UpdateResponse:
|
|
770
|
+
"""
|
|
771
|
+
Update a specific S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
|
|
772
|
+
|
|
773
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
774
|
+
|
|
775
|
+
Parameters
|
|
776
|
+
----------
|
|
777
|
+
id : int
|
|
778
|
+
A unique integer value identifying this s3 import storage.
|
|
779
|
+
|
|
780
|
+
project : typing.Optional[int]
|
|
781
|
+
Project ID
|
|
782
|
+
|
|
783
|
+
bucket : typing.Optional[str]
|
|
784
|
+
S3 bucket name
|
|
785
|
+
|
|
786
|
+
prefix : typing.Optional[str]
|
|
787
|
+
S3 bucket prefix
|
|
788
|
+
|
|
789
|
+
regex_filter : typing.Optional[str]
|
|
790
|
+
Cloud storage regex for filtering objects
|
|
791
|
+
|
|
792
|
+
use_blob_urls : typing.Optional[bool]
|
|
793
|
+
Interpret objects as BLOBs and generate URLs
|
|
794
|
+
|
|
795
|
+
aws_access_key_id : typing.Optional[str]
|
|
796
|
+
AWS_ACCESS_KEY_ID
|
|
797
|
+
|
|
798
|
+
aws_secret_access_key : typing.Optional[str]
|
|
799
|
+
AWS_SECRET_ACCESS_KEY
|
|
800
|
+
|
|
801
|
+
aws_session_token : typing.Optional[str]
|
|
802
|
+
AWS_SESSION_TOKEN
|
|
803
|
+
|
|
804
|
+
aws_sse_kms_key_id : typing.Optional[str]
|
|
805
|
+
AWS SSE KMS Key ID
|
|
806
|
+
|
|
807
|
+
region_name : typing.Optional[str]
|
|
808
|
+
AWS Region
|
|
809
|
+
|
|
810
|
+
s3endpoint : typing.Optional[str]
|
|
811
|
+
S3 Endpoint
|
|
812
|
+
|
|
813
|
+
presign : typing.Optional[bool]
|
|
814
|
+
Presign URLs for download
|
|
815
|
+
|
|
816
|
+
presign_ttl : typing.Optional[int]
|
|
817
|
+
Presign TTL in seconds
|
|
818
|
+
|
|
819
|
+
recursive_scan : typing.Optional[bool]
|
|
820
|
+
Scan recursively
|
|
821
|
+
|
|
822
|
+
request_options : typing.Optional[RequestOptions]
|
|
823
|
+
Request-specific configuration.
|
|
824
|
+
|
|
825
|
+
Returns
|
|
826
|
+
-------
|
|
827
|
+
S3UpdateResponse
|
|
828
|
+
|
|
829
|
+
|
|
830
|
+
Examples
|
|
831
|
+
--------
|
|
832
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
833
|
+
|
|
834
|
+
client = AsyncLabelStudio(
|
|
835
|
+
api_key="YOUR_API_KEY",
|
|
836
|
+
)
|
|
837
|
+
await client.import_storage.s3.update(
|
|
838
|
+
id=1,
|
|
839
|
+
)
|
|
840
|
+
"""
|
|
841
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
842
|
+
f"api/storages/s3/{jsonable_encoder(id)}",
|
|
843
|
+
method="PATCH",
|
|
844
|
+
json={
|
|
845
|
+
"project": project,
|
|
846
|
+
"bucket": bucket,
|
|
847
|
+
"prefix": prefix,
|
|
848
|
+
"regex_filter": regex_filter,
|
|
849
|
+
"use_blob_urls": use_blob_urls,
|
|
850
|
+
"aws_access_key_id": aws_access_key_id,
|
|
851
|
+
"aws_secret_access_key": aws_secret_access_key,
|
|
852
|
+
"aws_session_token": aws_session_token,
|
|
853
|
+
"aws_sse_kms_key_id": aws_sse_kms_key_id,
|
|
854
|
+
"region_name": region_name,
|
|
855
|
+
"s3_endpoint": s3endpoint,
|
|
856
|
+
"presign": presign,
|
|
857
|
+
"presign_ttl": presign_ttl,
|
|
858
|
+
"recursive_scan": recursive_scan,
|
|
859
|
+
},
|
|
860
|
+
request_options=request_options,
|
|
861
|
+
omit=OMIT,
|
|
862
|
+
)
|
|
863
|
+
if 200 <= _response.status_code < 300:
|
|
864
|
+
return pydantic_v1.parse_obj_as(S3UpdateResponse, _response.json()) # type: ignore
|
|
865
|
+
try:
|
|
866
|
+
_response_json = _response.json()
|
|
867
|
+
except JSONDecodeError:
|
|
868
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
869
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
870
|
+
|
|
871
|
+
async def sync(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> S3ImportStorage:
|
|
872
|
+
"""
|
|
873
|
+
Sync tasks from an S3 import storage connection. You will need to provide the import storage ID. You can find this using [List import storages](list).
|
|
874
|
+
|
|
875
|
+
Sync operations with external buckets only go one way. They either create tasks from objects in the bucket (source/import storage) or push annotations to the output bucket (export/target storage). Changing something on the bucket side doesn’t guarantee consistency in results.
|
|
876
|
+
|
|
877
|
+
<Note>Before proceeding, you should review [How sync operations work - Source storage](https://labelstud.io/guide/storage#Source-storage) to ensure that your data remains secure and private.</Note>
|
|
878
|
+
|
|
879
|
+
Parameters
|
|
880
|
+
----------
|
|
881
|
+
id : int
|
|
882
|
+
Storage ID
|
|
883
|
+
|
|
884
|
+
request_options : typing.Optional[RequestOptions]
|
|
885
|
+
Request-specific configuration.
|
|
886
|
+
|
|
887
|
+
Returns
|
|
888
|
+
-------
|
|
889
|
+
S3ImportStorage
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
Examples
|
|
893
|
+
--------
|
|
894
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
895
|
+
|
|
896
|
+
client = AsyncLabelStudio(
|
|
897
|
+
api_key="YOUR_API_KEY",
|
|
898
|
+
)
|
|
899
|
+
await client.import_storage.s3.sync(
|
|
900
|
+
id=1,
|
|
901
|
+
)
|
|
902
|
+
"""
|
|
903
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
904
|
+
f"api/storages/s3/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
|
|
905
|
+
)
|
|
906
|
+
if 200 <= _response.status_code < 300:
|
|
907
|
+
return pydantic_v1.parse_obj_as(S3ImportStorage, _response.json()) # type: ignore
|
|
908
|
+
try:
|
|
909
|
+
_response_json = _response.json()
|
|
910
|
+
except JSONDecodeError:
|
|
911
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
912
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|