label-studio-sdk 0.0.34__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 +232 -9
- 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/_extensions/pager_ext.py +49 -0
- label_studio_sdk/_legacy/__init__.py +11 -0
- label_studio_sdk/_legacy/client.py +471 -0
- label_studio_sdk/_legacy/objects.py +74 -0
- label_studio_sdk/{project.py → _legacy/project.py} +2 -2
- label_studio_sdk/{schema → _legacy/schema}/label_config_schema.json +14 -14
- label_studio_sdk/actions/__init__.py +27 -0
- label_studio_sdk/actions/client.py +223 -0
- 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/annotations/__init__.py +2 -0
- label_studio_sdk/annotations/client.py +750 -0
- label_studio_sdk/base_client.py +183 -0
- label_studio_sdk/client.py +17 -463
- 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 +447 -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/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 +888 -0
- label_studio_sdk/export_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/export_storage/azure/types/azure_create_response.py +67 -0
- label_studio_sdk/export_storage/azure/types/azure_update_response.py +67 -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 +888 -0
- label_studio_sdk/export_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/export_storage/gcs/types/gcs_create_response.py +67 -0
- label_studio_sdk/export_storage/gcs/types/gcs_update_response.py +67 -0
- label_studio_sdk/export_storage/local/__init__.py +5 -0
- label_studio_sdk/export_storage/local/client.py +834 -0
- label_studio_sdk/export_storage/local/types/__init__.py +6 -0
- label_studio_sdk/export_storage/local/types/local_create_response.py +57 -0
- label_studio_sdk/export_storage/local/types/local_update_response.py +57 -0
- label_studio_sdk/export_storage/redis/__init__.py +5 -0
- label_studio_sdk/export_storage/redis/client.py +918 -0
- label_studio_sdk/export_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/export_storage/redis/types/redis_create_response.py +72 -0
- label_studio_sdk/export_storage/redis/types/redis_update_response.py +72 -0
- label_studio_sdk/export_storage/s3/__init__.py +5 -0
- label_studio_sdk/export_storage/s3/client.py +1008 -0
- label_studio_sdk/export_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/export_storage/s3/types/s3create_response.py +89 -0
- label_studio_sdk/export_storage/s3/types/s3update_response.py +89 -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 +988 -0
- label_studio_sdk/import_storage/azure/types/__init__.py +6 -0
- label_studio_sdk/import_storage/azure/types/azure_create_response.py +82 -0
- label_studio_sdk/import_storage/azure/types/azure_update_response.py +82 -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 +988 -0
- label_studio_sdk/import_storage/gcs/types/__init__.py +6 -0
- label_studio_sdk/import_storage/gcs/types/gcs_create_response.py +82 -0
- label_studio_sdk/import_storage/gcs/types/gcs_update_response.py +82 -0
- label_studio_sdk/import_storage/local/__init__.py +5 -0
- label_studio_sdk/import_storage/local/client.py +836 -0
- label_studio_sdk/import_storage/local/types/__init__.py +6 -0
- label_studio_sdk/import_storage/local/types/local_create_response.py +57 -0
- label_studio_sdk/import_storage/local/types/local_update_response.py +57 -0
- label_studio_sdk/import_storage/redis/__init__.py +5 -0
- label_studio_sdk/import_storage/redis/client.py +924 -0
- label_studio_sdk/import_storage/redis/types/__init__.py +6 -0
- label_studio_sdk/import_storage/redis/types/redis_create_response.py +72 -0
- label_studio_sdk/import_storage/redis/types/redis_update_response.py +72 -0
- label_studio_sdk/import_storage/s3/__init__.py +5 -0
- label_studio_sdk/import_storage/s3/client.py +1138 -0
- label_studio_sdk/import_storage/s3/types/__init__.py +6 -0
- label_studio_sdk/import_storage/s3/types/s3create_response.py +109 -0
- label_studio_sdk/import_storage/s3/types/s3update_response.py +109 -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/label_interface/base.py +10 -0
- label_studio_sdk/label_interface/control_tags.py +109 -71
- label_studio_sdk/label_interface/data_examples.json +96 -0
- label_studio_sdk/label_interface/interface.py +102 -53
- label_studio_sdk/label_interface/object_tags.py +8 -13
- label_studio_sdk/label_interface/region.py +33 -1
- 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 +1055 -0
- label_studio_sdk/projects/client_ext.py +19 -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 +835 -0
- label_studio_sdk/tasks/client_ext.py +18 -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 +35 -0
- label_studio_sdk/views/client.py +564 -0
- label_studio_sdk/views/types/__init__.py +33 -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 +49 -0
- 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 +31 -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 +49 -0
- 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 +31 -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.1.dist-info/METADATA +163 -0
- label_studio_sdk-1.0.1.dist-info/RECORD +256 -0
- {label_studio_sdk-0.0.34.dist-info → label_studio_sdk-1.0.1.dist-info}/WHEEL +1 -2
- label_studio_sdk/objects.py +0 -35
- label_studio_sdk-0.0.34.dist-info/LICENSE +0 -201
- label_studio_sdk-0.0.34.dist-info/METADATA +0 -24
- label_studio_sdk-0.0.34.dist-info/RECORD +0 -37
- label_studio_sdk-0.0.34.dist-info/top_level.txt +0 -2
- tests/test_client.py +0 -37
- tests/test_export.py +0 -105
- tests/test_interface/__init__.py +0 -1
- tests/test_interface/configs.py +0 -137
- tests/test_interface/mockups.py +0 -22
- tests/test_interface/test_compat.py +0 -64
- tests/test_interface/test_control_tags.py +0 -55
- tests/test_interface/test_data_generation.py +0 -45
- tests/test_interface/test_lpi.py +0 -15
- tests/test_interface/test_main.py +0 -196
- tests/test_interface/test_object_tags.py +0 -36
- tests/test_interface/test_region.py +0 -36
- tests/test_interface/test_validate_summary.py +0 -35
- tests/test_interface/test_validation.py +0 -59
- {tests → label_studio_sdk/_extensions}/__init__.py +0 -0
- /label_studio_sdk/{exceptions.py → _legacy/exceptions.py} +0 -0
- /label_studio_sdk/{users.py → _legacy/users.py} +0 -0
- /label_studio_sdk/{utils.py → _legacy/utils.py} +0 -0
- /label_studio_sdk/{workspaces.py → _legacy/workspaces.py} +0 -0
|
@@ -0,0 +1,918 @@
|
|
|
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.redis_export_storage import RedisExportStorage
|
|
12
|
+
from .types.redis_create_response import RedisCreateResponse
|
|
13
|
+
from .types.redis_update_response import RedisUpdateResponse
|
|
14
|
+
|
|
15
|
+
# this is used as the default value for optional parameters
|
|
16
|
+
OMIT = typing.cast(typing.Any, ...)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class RedisClient:
|
|
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[RedisExportStorage]:
|
|
26
|
+
"""
|
|
27
|
+
You can connect your Redis database to Label Studio as a source storage or target storage. Use this API request to get a list of all Redis export (target) 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[RedisExportStorage]
|
|
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.export_storage.redis.list()
|
|
54
|
+
"""
|
|
55
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
56
|
+
"api/storages/export/redis", 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[RedisExportStorage], _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
|
+
db: typing.Optional[int] = OMIT,
|
|
70
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
71
|
+
title: typing.Optional[str] = OMIT,
|
|
72
|
+
description: typing.Optional[str] = OMIT,
|
|
73
|
+
project: typing.Optional[int] = OMIT,
|
|
74
|
+
path: typing.Optional[str] = OMIT,
|
|
75
|
+
host: typing.Optional[str] = OMIT,
|
|
76
|
+
port: typing.Optional[str] = OMIT,
|
|
77
|
+
password: typing.Optional[str] = OMIT,
|
|
78
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
79
|
+
) -> RedisCreateResponse:
|
|
80
|
+
"""
|
|
81
|
+
Create a new target storage connection to Redis.
|
|
82
|
+
|
|
83
|
+
For information about the required fields and prerequisites, see [Redis database](https://labelstud.io/guide/storage#Redis-database) in the Label Studio documentation.
|
|
84
|
+
|
|
85
|
+
<Tip>After you add the storage, you should validate the connection before attempting to sync your data. Your data will not be exported until you [sync your connection](sync).</Tip>
|
|
86
|
+
|
|
87
|
+
Parameters
|
|
88
|
+
----------
|
|
89
|
+
db : typing.Optional[int]
|
|
90
|
+
Database ID of database to use
|
|
91
|
+
|
|
92
|
+
can_delete_objects : typing.Optional[bool]
|
|
93
|
+
Deletion from storage enabled.
|
|
94
|
+
|
|
95
|
+
title : typing.Optional[str]
|
|
96
|
+
Storage title
|
|
97
|
+
|
|
98
|
+
description : typing.Optional[str]
|
|
99
|
+
Storage description
|
|
100
|
+
|
|
101
|
+
project : typing.Optional[int]
|
|
102
|
+
Project ID
|
|
103
|
+
|
|
104
|
+
path : typing.Optional[str]
|
|
105
|
+
Storage prefix (optional)
|
|
106
|
+
|
|
107
|
+
host : typing.Optional[str]
|
|
108
|
+
Server Host IP (optional)
|
|
109
|
+
|
|
110
|
+
port : typing.Optional[str]
|
|
111
|
+
Server Port (optional)
|
|
112
|
+
|
|
113
|
+
password : typing.Optional[str]
|
|
114
|
+
Server Password (optional)
|
|
115
|
+
|
|
116
|
+
request_options : typing.Optional[RequestOptions]
|
|
117
|
+
Request-specific configuration.
|
|
118
|
+
|
|
119
|
+
Returns
|
|
120
|
+
-------
|
|
121
|
+
RedisCreateResponse
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
Examples
|
|
125
|
+
--------
|
|
126
|
+
from label_studio_sdk.client import LabelStudio
|
|
127
|
+
|
|
128
|
+
client = LabelStudio(
|
|
129
|
+
api_key="YOUR_API_KEY",
|
|
130
|
+
)
|
|
131
|
+
client.export_storage.redis.create()
|
|
132
|
+
"""
|
|
133
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
134
|
+
"api/storages/export/redis",
|
|
135
|
+
method="POST",
|
|
136
|
+
json={
|
|
137
|
+
"db": db,
|
|
138
|
+
"can_delete_objects": can_delete_objects,
|
|
139
|
+
"title": title,
|
|
140
|
+
"description": description,
|
|
141
|
+
"project": project,
|
|
142
|
+
"path": path,
|
|
143
|
+
"host": host,
|
|
144
|
+
"port": port,
|
|
145
|
+
"password": password,
|
|
146
|
+
},
|
|
147
|
+
request_options=request_options,
|
|
148
|
+
omit=OMIT,
|
|
149
|
+
)
|
|
150
|
+
if 200 <= _response.status_code < 300:
|
|
151
|
+
return pydantic_v1.parse_obj_as(RedisCreateResponse, _response.json()) # type: ignore
|
|
152
|
+
try:
|
|
153
|
+
_response_json = _response.json()
|
|
154
|
+
except JSONDecodeError:
|
|
155
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
156
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
157
|
+
|
|
158
|
+
def validate(
|
|
159
|
+
self,
|
|
160
|
+
*,
|
|
161
|
+
id: typing.Optional[int] = OMIT,
|
|
162
|
+
db: typing.Optional[int] = OMIT,
|
|
163
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
164
|
+
title: typing.Optional[str] = OMIT,
|
|
165
|
+
description: typing.Optional[str] = OMIT,
|
|
166
|
+
project: typing.Optional[int] = OMIT,
|
|
167
|
+
path: typing.Optional[str] = OMIT,
|
|
168
|
+
host: typing.Optional[str] = OMIT,
|
|
169
|
+
port: typing.Optional[str] = OMIT,
|
|
170
|
+
password: typing.Optional[str] = OMIT,
|
|
171
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
172
|
+
) -> None:
|
|
173
|
+
"""
|
|
174
|
+
Validate a specific Redis export storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to export data.
|
|
175
|
+
|
|
176
|
+
Parameters
|
|
177
|
+
----------
|
|
178
|
+
id : typing.Optional[int]
|
|
179
|
+
Storage ID. If set, storage with specified ID will be updated
|
|
180
|
+
|
|
181
|
+
db : typing.Optional[int]
|
|
182
|
+
Database ID of database to use
|
|
183
|
+
|
|
184
|
+
can_delete_objects : typing.Optional[bool]
|
|
185
|
+
Deletion from storage enabled.
|
|
186
|
+
|
|
187
|
+
title : typing.Optional[str]
|
|
188
|
+
Storage title
|
|
189
|
+
|
|
190
|
+
description : typing.Optional[str]
|
|
191
|
+
Storage description
|
|
192
|
+
|
|
193
|
+
project : typing.Optional[int]
|
|
194
|
+
Project ID
|
|
195
|
+
|
|
196
|
+
path : typing.Optional[str]
|
|
197
|
+
Storage prefix (optional)
|
|
198
|
+
|
|
199
|
+
host : typing.Optional[str]
|
|
200
|
+
Server Host IP (optional)
|
|
201
|
+
|
|
202
|
+
port : typing.Optional[str]
|
|
203
|
+
Server Port (optional)
|
|
204
|
+
|
|
205
|
+
password : typing.Optional[str]
|
|
206
|
+
Server Password (optional)
|
|
207
|
+
|
|
208
|
+
request_options : typing.Optional[RequestOptions]
|
|
209
|
+
Request-specific configuration.
|
|
210
|
+
|
|
211
|
+
Returns
|
|
212
|
+
-------
|
|
213
|
+
None
|
|
214
|
+
|
|
215
|
+
Examples
|
|
216
|
+
--------
|
|
217
|
+
from label_studio_sdk.client import LabelStudio
|
|
218
|
+
|
|
219
|
+
client = LabelStudio(
|
|
220
|
+
api_key="YOUR_API_KEY",
|
|
221
|
+
)
|
|
222
|
+
client.export_storage.redis.validate()
|
|
223
|
+
"""
|
|
224
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
225
|
+
"api/storages/export/redis/validate",
|
|
226
|
+
method="POST",
|
|
227
|
+
json={
|
|
228
|
+
"id": id,
|
|
229
|
+
"db": db,
|
|
230
|
+
"can_delete_objects": can_delete_objects,
|
|
231
|
+
"title": title,
|
|
232
|
+
"description": description,
|
|
233
|
+
"project": project,
|
|
234
|
+
"path": path,
|
|
235
|
+
"host": host,
|
|
236
|
+
"port": port,
|
|
237
|
+
"password": password,
|
|
238
|
+
},
|
|
239
|
+
request_options=request_options,
|
|
240
|
+
omit=OMIT,
|
|
241
|
+
)
|
|
242
|
+
if 200 <= _response.status_code < 300:
|
|
243
|
+
return
|
|
244
|
+
try:
|
|
245
|
+
_response_json = _response.json()
|
|
246
|
+
except JSONDecodeError:
|
|
247
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
248
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
249
|
+
|
|
250
|
+
def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
|
|
251
|
+
"""
|
|
252
|
+
Get a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
253
|
+
|
|
254
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
255
|
+
|
|
256
|
+
Parameters
|
|
257
|
+
----------
|
|
258
|
+
id : int
|
|
259
|
+
A unique integer value identifying this redis export storage.
|
|
260
|
+
|
|
261
|
+
request_options : typing.Optional[RequestOptions]
|
|
262
|
+
Request-specific configuration.
|
|
263
|
+
|
|
264
|
+
Returns
|
|
265
|
+
-------
|
|
266
|
+
RedisExportStorage
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
Examples
|
|
270
|
+
--------
|
|
271
|
+
from label_studio_sdk.client import LabelStudio
|
|
272
|
+
|
|
273
|
+
client = LabelStudio(
|
|
274
|
+
api_key="YOUR_API_KEY",
|
|
275
|
+
)
|
|
276
|
+
client.export_storage.redis.get(
|
|
277
|
+
id=1,
|
|
278
|
+
)
|
|
279
|
+
"""
|
|
280
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
281
|
+
f"api/storages/export/redis/{jsonable_encoder(id)}", method="GET", request_options=request_options
|
|
282
|
+
)
|
|
283
|
+
if 200 <= _response.status_code < 300:
|
|
284
|
+
return pydantic_v1.parse_obj_as(RedisExportStorage, _response.json()) # type: ignore
|
|
285
|
+
try:
|
|
286
|
+
_response_json = _response.json()
|
|
287
|
+
except JSONDecodeError:
|
|
288
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
289
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
290
|
+
|
|
291
|
+
def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
292
|
+
"""
|
|
293
|
+
Delete a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
294
|
+
|
|
295
|
+
Deleting an export/target storage connection does not affect tasks with synced data in Label Studio. 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.
|
|
296
|
+
|
|
297
|
+
Parameters
|
|
298
|
+
----------
|
|
299
|
+
id : int
|
|
300
|
+
A unique integer value identifying this redis export storage.
|
|
301
|
+
|
|
302
|
+
request_options : typing.Optional[RequestOptions]
|
|
303
|
+
Request-specific configuration.
|
|
304
|
+
|
|
305
|
+
Returns
|
|
306
|
+
-------
|
|
307
|
+
None
|
|
308
|
+
|
|
309
|
+
Examples
|
|
310
|
+
--------
|
|
311
|
+
from label_studio_sdk.client import LabelStudio
|
|
312
|
+
|
|
313
|
+
client = LabelStudio(
|
|
314
|
+
api_key="YOUR_API_KEY",
|
|
315
|
+
)
|
|
316
|
+
client.export_storage.redis.delete(
|
|
317
|
+
id=1,
|
|
318
|
+
)
|
|
319
|
+
"""
|
|
320
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
321
|
+
f"api/storages/export/redis/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
|
|
322
|
+
)
|
|
323
|
+
if 200 <= _response.status_code < 300:
|
|
324
|
+
return
|
|
325
|
+
try:
|
|
326
|
+
_response_json = _response.json()
|
|
327
|
+
except JSONDecodeError:
|
|
328
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
329
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
330
|
+
|
|
331
|
+
def update(
|
|
332
|
+
self,
|
|
333
|
+
id: int,
|
|
334
|
+
*,
|
|
335
|
+
db: typing.Optional[int] = OMIT,
|
|
336
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
337
|
+
title: typing.Optional[str] = OMIT,
|
|
338
|
+
description: typing.Optional[str] = OMIT,
|
|
339
|
+
project: typing.Optional[int] = OMIT,
|
|
340
|
+
path: typing.Optional[str] = OMIT,
|
|
341
|
+
host: typing.Optional[str] = OMIT,
|
|
342
|
+
port: typing.Optional[str] = OMIT,
|
|
343
|
+
password: typing.Optional[str] = OMIT,
|
|
344
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
345
|
+
) -> RedisUpdateResponse:
|
|
346
|
+
"""
|
|
347
|
+
Update a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
348
|
+
|
|
349
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
350
|
+
|
|
351
|
+
Parameters
|
|
352
|
+
----------
|
|
353
|
+
id : int
|
|
354
|
+
A unique integer value identifying this redis export storage.
|
|
355
|
+
|
|
356
|
+
db : typing.Optional[int]
|
|
357
|
+
Database ID of database to use
|
|
358
|
+
|
|
359
|
+
can_delete_objects : typing.Optional[bool]
|
|
360
|
+
Deletion from storage enabled.
|
|
361
|
+
|
|
362
|
+
title : typing.Optional[str]
|
|
363
|
+
Storage title
|
|
364
|
+
|
|
365
|
+
description : typing.Optional[str]
|
|
366
|
+
Storage description
|
|
367
|
+
|
|
368
|
+
project : typing.Optional[int]
|
|
369
|
+
Project ID
|
|
370
|
+
|
|
371
|
+
path : typing.Optional[str]
|
|
372
|
+
Storage prefix (optional)
|
|
373
|
+
|
|
374
|
+
host : typing.Optional[str]
|
|
375
|
+
Server Host IP (optional)
|
|
376
|
+
|
|
377
|
+
port : typing.Optional[str]
|
|
378
|
+
Server Port (optional)
|
|
379
|
+
|
|
380
|
+
password : typing.Optional[str]
|
|
381
|
+
Server Password (optional)
|
|
382
|
+
|
|
383
|
+
request_options : typing.Optional[RequestOptions]
|
|
384
|
+
Request-specific configuration.
|
|
385
|
+
|
|
386
|
+
Returns
|
|
387
|
+
-------
|
|
388
|
+
RedisUpdateResponse
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
Examples
|
|
392
|
+
--------
|
|
393
|
+
from label_studio_sdk.client import LabelStudio
|
|
394
|
+
|
|
395
|
+
client = LabelStudio(
|
|
396
|
+
api_key="YOUR_API_KEY",
|
|
397
|
+
)
|
|
398
|
+
client.export_storage.redis.update(
|
|
399
|
+
id=1,
|
|
400
|
+
)
|
|
401
|
+
"""
|
|
402
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
403
|
+
f"api/storages/export/redis/{jsonable_encoder(id)}",
|
|
404
|
+
method="PATCH",
|
|
405
|
+
json={
|
|
406
|
+
"db": db,
|
|
407
|
+
"can_delete_objects": can_delete_objects,
|
|
408
|
+
"title": title,
|
|
409
|
+
"description": description,
|
|
410
|
+
"project": project,
|
|
411
|
+
"path": path,
|
|
412
|
+
"host": host,
|
|
413
|
+
"port": port,
|
|
414
|
+
"password": password,
|
|
415
|
+
},
|
|
416
|
+
request_options=request_options,
|
|
417
|
+
omit=OMIT,
|
|
418
|
+
)
|
|
419
|
+
if 200 <= _response.status_code < 300:
|
|
420
|
+
return pydantic_v1.parse_obj_as(RedisUpdateResponse, _response.json()) # type: ignore
|
|
421
|
+
try:
|
|
422
|
+
_response_json = _response.json()
|
|
423
|
+
except JSONDecodeError:
|
|
424
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
425
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
426
|
+
|
|
427
|
+
def sync(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
|
|
428
|
+
"""
|
|
429
|
+
Sync tasks to an Redis export/target storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
430
|
+
|
|
431
|
+
Sync operations with external databases only go one way. They either create tasks from objects in the database (source/import storage) or push annotations to the output database (export/target storage). Changing something on the database side doesn’t guarantee consistency in results.
|
|
432
|
+
|
|
433
|
+
<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>
|
|
434
|
+
|
|
435
|
+
Parameters
|
|
436
|
+
----------
|
|
437
|
+
id : str
|
|
438
|
+
|
|
439
|
+
request_options : typing.Optional[RequestOptions]
|
|
440
|
+
Request-specific configuration.
|
|
441
|
+
|
|
442
|
+
Returns
|
|
443
|
+
-------
|
|
444
|
+
RedisExportStorage
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
Examples
|
|
448
|
+
--------
|
|
449
|
+
from label_studio_sdk.client import LabelStudio
|
|
450
|
+
|
|
451
|
+
client = LabelStudio(
|
|
452
|
+
api_key="YOUR_API_KEY",
|
|
453
|
+
)
|
|
454
|
+
client.export_storage.redis.sync(
|
|
455
|
+
id="id",
|
|
456
|
+
)
|
|
457
|
+
"""
|
|
458
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
459
|
+
f"api/storages/export/redis/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
|
|
460
|
+
)
|
|
461
|
+
if 200 <= _response.status_code < 300:
|
|
462
|
+
return pydantic_v1.parse_obj_as(RedisExportStorage, _response.json()) # type: ignore
|
|
463
|
+
try:
|
|
464
|
+
_response_json = _response.json()
|
|
465
|
+
except JSONDecodeError:
|
|
466
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
467
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
class AsyncRedisClient:
|
|
471
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
472
|
+
self._client_wrapper = client_wrapper
|
|
473
|
+
|
|
474
|
+
async def list(
|
|
475
|
+
self, *, project: typing.Optional[int] = None, request_options: typing.Optional[RequestOptions] = None
|
|
476
|
+
) -> typing.List[RedisExportStorage]:
|
|
477
|
+
"""
|
|
478
|
+
You can connect your Redis database to Label Studio as a source storage or target storage. Use this API request to get a list of all Redis export (target) storage connections for a specific project.
|
|
479
|
+
|
|
480
|
+
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).
|
|
481
|
+
|
|
482
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
483
|
+
|
|
484
|
+
Parameters
|
|
485
|
+
----------
|
|
486
|
+
project : typing.Optional[int]
|
|
487
|
+
Project ID
|
|
488
|
+
|
|
489
|
+
request_options : typing.Optional[RequestOptions]
|
|
490
|
+
Request-specific configuration.
|
|
491
|
+
|
|
492
|
+
Returns
|
|
493
|
+
-------
|
|
494
|
+
typing.List[RedisExportStorage]
|
|
495
|
+
|
|
496
|
+
|
|
497
|
+
Examples
|
|
498
|
+
--------
|
|
499
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
500
|
+
|
|
501
|
+
client = AsyncLabelStudio(
|
|
502
|
+
api_key="YOUR_API_KEY",
|
|
503
|
+
)
|
|
504
|
+
await client.export_storage.redis.list()
|
|
505
|
+
"""
|
|
506
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
507
|
+
"api/storages/export/redis", method="GET", params={"project": project}, request_options=request_options
|
|
508
|
+
)
|
|
509
|
+
if 200 <= _response.status_code < 300:
|
|
510
|
+
return pydantic_v1.parse_obj_as(typing.List[RedisExportStorage], _response.json()) # type: ignore
|
|
511
|
+
try:
|
|
512
|
+
_response_json = _response.json()
|
|
513
|
+
except JSONDecodeError:
|
|
514
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
515
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
516
|
+
|
|
517
|
+
async def create(
|
|
518
|
+
self,
|
|
519
|
+
*,
|
|
520
|
+
db: typing.Optional[int] = OMIT,
|
|
521
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
522
|
+
title: typing.Optional[str] = OMIT,
|
|
523
|
+
description: typing.Optional[str] = OMIT,
|
|
524
|
+
project: typing.Optional[int] = OMIT,
|
|
525
|
+
path: typing.Optional[str] = OMIT,
|
|
526
|
+
host: typing.Optional[str] = OMIT,
|
|
527
|
+
port: typing.Optional[str] = OMIT,
|
|
528
|
+
password: typing.Optional[str] = OMIT,
|
|
529
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
530
|
+
) -> RedisCreateResponse:
|
|
531
|
+
"""
|
|
532
|
+
Create a new target storage connection to Redis.
|
|
533
|
+
|
|
534
|
+
For information about the required fields and prerequisites, see [Redis database](https://labelstud.io/guide/storage#Redis-database) in the Label Studio documentation.
|
|
535
|
+
|
|
536
|
+
<Tip>After you add the storage, you should validate the connection before attempting to sync your data. Your data will not be exported until you [sync your connection](sync).</Tip>
|
|
537
|
+
|
|
538
|
+
Parameters
|
|
539
|
+
----------
|
|
540
|
+
db : typing.Optional[int]
|
|
541
|
+
Database ID of database to use
|
|
542
|
+
|
|
543
|
+
can_delete_objects : typing.Optional[bool]
|
|
544
|
+
Deletion from storage enabled.
|
|
545
|
+
|
|
546
|
+
title : typing.Optional[str]
|
|
547
|
+
Storage title
|
|
548
|
+
|
|
549
|
+
description : typing.Optional[str]
|
|
550
|
+
Storage description
|
|
551
|
+
|
|
552
|
+
project : typing.Optional[int]
|
|
553
|
+
Project ID
|
|
554
|
+
|
|
555
|
+
path : typing.Optional[str]
|
|
556
|
+
Storage prefix (optional)
|
|
557
|
+
|
|
558
|
+
host : typing.Optional[str]
|
|
559
|
+
Server Host IP (optional)
|
|
560
|
+
|
|
561
|
+
port : typing.Optional[str]
|
|
562
|
+
Server Port (optional)
|
|
563
|
+
|
|
564
|
+
password : typing.Optional[str]
|
|
565
|
+
Server Password (optional)
|
|
566
|
+
|
|
567
|
+
request_options : typing.Optional[RequestOptions]
|
|
568
|
+
Request-specific configuration.
|
|
569
|
+
|
|
570
|
+
Returns
|
|
571
|
+
-------
|
|
572
|
+
RedisCreateResponse
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
Examples
|
|
576
|
+
--------
|
|
577
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
578
|
+
|
|
579
|
+
client = AsyncLabelStudio(
|
|
580
|
+
api_key="YOUR_API_KEY",
|
|
581
|
+
)
|
|
582
|
+
await client.export_storage.redis.create()
|
|
583
|
+
"""
|
|
584
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
585
|
+
"api/storages/export/redis",
|
|
586
|
+
method="POST",
|
|
587
|
+
json={
|
|
588
|
+
"db": db,
|
|
589
|
+
"can_delete_objects": can_delete_objects,
|
|
590
|
+
"title": title,
|
|
591
|
+
"description": description,
|
|
592
|
+
"project": project,
|
|
593
|
+
"path": path,
|
|
594
|
+
"host": host,
|
|
595
|
+
"port": port,
|
|
596
|
+
"password": password,
|
|
597
|
+
},
|
|
598
|
+
request_options=request_options,
|
|
599
|
+
omit=OMIT,
|
|
600
|
+
)
|
|
601
|
+
if 200 <= _response.status_code < 300:
|
|
602
|
+
return pydantic_v1.parse_obj_as(RedisCreateResponse, _response.json()) # type: ignore
|
|
603
|
+
try:
|
|
604
|
+
_response_json = _response.json()
|
|
605
|
+
except JSONDecodeError:
|
|
606
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
607
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
608
|
+
|
|
609
|
+
async def validate(
|
|
610
|
+
self,
|
|
611
|
+
*,
|
|
612
|
+
id: typing.Optional[int] = OMIT,
|
|
613
|
+
db: typing.Optional[int] = OMIT,
|
|
614
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
615
|
+
title: typing.Optional[str] = OMIT,
|
|
616
|
+
description: typing.Optional[str] = OMIT,
|
|
617
|
+
project: typing.Optional[int] = OMIT,
|
|
618
|
+
path: typing.Optional[str] = OMIT,
|
|
619
|
+
host: typing.Optional[str] = OMIT,
|
|
620
|
+
port: typing.Optional[str] = OMIT,
|
|
621
|
+
password: typing.Optional[str] = OMIT,
|
|
622
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
623
|
+
) -> None:
|
|
624
|
+
"""
|
|
625
|
+
Validate a specific Redis export storage connection. This is useful to ensure that the storage configuration settings are correct and operational before attempting to export data.
|
|
626
|
+
|
|
627
|
+
Parameters
|
|
628
|
+
----------
|
|
629
|
+
id : typing.Optional[int]
|
|
630
|
+
Storage ID. If set, storage with specified ID will be updated
|
|
631
|
+
|
|
632
|
+
db : typing.Optional[int]
|
|
633
|
+
Database ID of database to use
|
|
634
|
+
|
|
635
|
+
can_delete_objects : typing.Optional[bool]
|
|
636
|
+
Deletion from storage enabled.
|
|
637
|
+
|
|
638
|
+
title : typing.Optional[str]
|
|
639
|
+
Storage title
|
|
640
|
+
|
|
641
|
+
description : typing.Optional[str]
|
|
642
|
+
Storage description
|
|
643
|
+
|
|
644
|
+
project : typing.Optional[int]
|
|
645
|
+
Project ID
|
|
646
|
+
|
|
647
|
+
path : typing.Optional[str]
|
|
648
|
+
Storage prefix (optional)
|
|
649
|
+
|
|
650
|
+
host : typing.Optional[str]
|
|
651
|
+
Server Host IP (optional)
|
|
652
|
+
|
|
653
|
+
port : typing.Optional[str]
|
|
654
|
+
Server Port (optional)
|
|
655
|
+
|
|
656
|
+
password : typing.Optional[str]
|
|
657
|
+
Server Password (optional)
|
|
658
|
+
|
|
659
|
+
request_options : typing.Optional[RequestOptions]
|
|
660
|
+
Request-specific configuration.
|
|
661
|
+
|
|
662
|
+
Returns
|
|
663
|
+
-------
|
|
664
|
+
None
|
|
665
|
+
|
|
666
|
+
Examples
|
|
667
|
+
--------
|
|
668
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
669
|
+
|
|
670
|
+
client = AsyncLabelStudio(
|
|
671
|
+
api_key="YOUR_API_KEY",
|
|
672
|
+
)
|
|
673
|
+
await client.export_storage.redis.validate()
|
|
674
|
+
"""
|
|
675
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
676
|
+
"api/storages/export/redis/validate",
|
|
677
|
+
method="POST",
|
|
678
|
+
json={
|
|
679
|
+
"id": id,
|
|
680
|
+
"db": db,
|
|
681
|
+
"can_delete_objects": can_delete_objects,
|
|
682
|
+
"title": title,
|
|
683
|
+
"description": description,
|
|
684
|
+
"project": project,
|
|
685
|
+
"path": path,
|
|
686
|
+
"host": host,
|
|
687
|
+
"port": port,
|
|
688
|
+
"password": password,
|
|
689
|
+
},
|
|
690
|
+
request_options=request_options,
|
|
691
|
+
omit=OMIT,
|
|
692
|
+
)
|
|
693
|
+
if 200 <= _response.status_code < 300:
|
|
694
|
+
return
|
|
695
|
+
try:
|
|
696
|
+
_response_json = _response.json()
|
|
697
|
+
except JSONDecodeError:
|
|
698
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
699
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
700
|
+
|
|
701
|
+
async def get(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
|
|
702
|
+
"""
|
|
703
|
+
Get a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
704
|
+
|
|
705
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
706
|
+
|
|
707
|
+
Parameters
|
|
708
|
+
----------
|
|
709
|
+
id : int
|
|
710
|
+
A unique integer value identifying this redis export storage.
|
|
711
|
+
|
|
712
|
+
request_options : typing.Optional[RequestOptions]
|
|
713
|
+
Request-specific configuration.
|
|
714
|
+
|
|
715
|
+
Returns
|
|
716
|
+
-------
|
|
717
|
+
RedisExportStorage
|
|
718
|
+
|
|
719
|
+
|
|
720
|
+
Examples
|
|
721
|
+
--------
|
|
722
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
723
|
+
|
|
724
|
+
client = AsyncLabelStudio(
|
|
725
|
+
api_key="YOUR_API_KEY",
|
|
726
|
+
)
|
|
727
|
+
await client.export_storage.redis.get(
|
|
728
|
+
id=1,
|
|
729
|
+
)
|
|
730
|
+
"""
|
|
731
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
732
|
+
f"api/storages/export/redis/{jsonable_encoder(id)}", method="GET", request_options=request_options
|
|
733
|
+
)
|
|
734
|
+
if 200 <= _response.status_code < 300:
|
|
735
|
+
return pydantic_v1.parse_obj_as(RedisExportStorage, _response.json()) # type: ignore
|
|
736
|
+
try:
|
|
737
|
+
_response_json = _response.json()
|
|
738
|
+
except JSONDecodeError:
|
|
739
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
740
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
741
|
+
|
|
742
|
+
async def delete(self, id: int, *, request_options: typing.Optional[RequestOptions] = None) -> None:
|
|
743
|
+
"""
|
|
744
|
+
Delete a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
745
|
+
|
|
746
|
+
Deleting an export/target storage connection does not affect tasks with synced data in Label Studio. 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.
|
|
747
|
+
|
|
748
|
+
Parameters
|
|
749
|
+
----------
|
|
750
|
+
id : int
|
|
751
|
+
A unique integer value identifying this redis export storage.
|
|
752
|
+
|
|
753
|
+
request_options : typing.Optional[RequestOptions]
|
|
754
|
+
Request-specific configuration.
|
|
755
|
+
|
|
756
|
+
Returns
|
|
757
|
+
-------
|
|
758
|
+
None
|
|
759
|
+
|
|
760
|
+
Examples
|
|
761
|
+
--------
|
|
762
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
763
|
+
|
|
764
|
+
client = AsyncLabelStudio(
|
|
765
|
+
api_key="YOUR_API_KEY",
|
|
766
|
+
)
|
|
767
|
+
await client.export_storage.redis.delete(
|
|
768
|
+
id=1,
|
|
769
|
+
)
|
|
770
|
+
"""
|
|
771
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
772
|
+
f"api/storages/export/redis/{jsonable_encoder(id)}", method="DELETE", request_options=request_options
|
|
773
|
+
)
|
|
774
|
+
if 200 <= _response.status_code < 300:
|
|
775
|
+
return
|
|
776
|
+
try:
|
|
777
|
+
_response_json = _response.json()
|
|
778
|
+
except JSONDecodeError:
|
|
779
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
780
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
781
|
+
|
|
782
|
+
async def update(
|
|
783
|
+
self,
|
|
784
|
+
id: int,
|
|
785
|
+
*,
|
|
786
|
+
db: typing.Optional[int] = OMIT,
|
|
787
|
+
can_delete_objects: typing.Optional[bool] = OMIT,
|
|
788
|
+
title: typing.Optional[str] = OMIT,
|
|
789
|
+
description: typing.Optional[str] = OMIT,
|
|
790
|
+
project: typing.Optional[int] = OMIT,
|
|
791
|
+
path: typing.Optional[str] = OMIT,
|
|
792
|
+
host: typing.Optional[str] = OMIT,
|
|
793
|
+
port: typing.Optional[str] = OMIT,
|
|
794
|
+
password: typing.Optional[str] = OMIT,
|
|
795
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
796
|
+
) -> RedisUpdateResponse:
|
|
797
|
+
"""
|
|
798
|
+
Update a specific Redis export storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
799
|
+
|
|
800
|
+
For more information about working with external storage, see [Sync data from external storage](https://labelstud.io/guide/storage).
|
|
801
|
+
|
|
802
|
+
Parameters
|
|
803
|
+
----------
|
|
804
|
+
id : int
|
|
805
|
+
A unique integer value identifying this redis export storage.
|
|
806
|
+
|
|
807
|
+
db : typing.Optional[int]
|
|
808
|
+
Database ID of database to use
|
|
809
|
+
|
|
810
|
+
can_delete_objects : typing.Optional[bool]
|
|
811
|
+
Deletion from storage enabled.
|
|
812
|
+
|
|
813
|
+
title : typing.Optional[str]
|
|
814
|
+
Storage title
|
|
815
|
+
|
|
816
|
+
description : typing.Optional[str]
|
|
817
|
+
Storage description
|
|
818
|
+
|
|
819
|
+
project : typing.Optional[int]
|
|
820
|
+
Project ID
|
|
821
|
+
|
|
822
|
+
path : typing.Optional[str]
|
|
823
|
+
Storage prefix (optional)
|
|
824
|
+
|
|
825
|
+
host : typing.Optional[str]
|
|
826
|
+
Server Host IP (optional)
|
|
827
|
+
|
|
828
|
+
port : typing.Optional[str]
|
|
829
|
+
Server Port (optional)
|
|
830
|
+
|
|
831
|
+
password : typing.Optional[str]
|
|
832
|
+
Server Password (optional)
|
|
833
|
+
|
|
834
|
+
request_options : typing.Optional[RequestOptions]
|
|
835
|
+
Request-specific configuration.
|
|
836
|
+
|
|
837
|
+
Returns
|
|
838
|
+
-------
|
|
839
|
+
RedisUpdateResponse
|
|
840
|
+
|
|
841
|
+
|
|
842
|
+
Examples
|
|
843
|
+
--------
|
|
844
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
845
|
+
|
|
846
|
+
client = AsyncLabelStudio(
|
|
847
|
+
api_key="YOUR_API_KEY",
|
|
848
|
+
)
|
|
849
|
+
await client.export_storage.redis.update(
|
|
850
|
+
id=1,
|
|
851
|
+
)
|
|
852
|
+
"""
|
|
853
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
854
|
+
f"api/storages/export/redis/{jsonable_encoder(id)}",
|
|
855
|
+
method="PATCH",
|
|
856
|
+
json={
|
|
857
|
+
"db": db,
|
|
858
|
+
"can_delete_objects": can_delete_objects,
|
|
859
|
+
"title": title,
|
|
860
|
+
"description": description,
|
|
861
|
+
"project": project,
|
|
862
|
+
"path": path,
|
|
863
|
+
"host": host,
|
|
864
|
+
"port": port,
|
|
865
|
+
"password": password,
|
|
866
|
+
},
|
|
867
|
+
request_options=request_options,
|
|
868
|
+
omit=OMIT,
|
|
869
|
+
)
|
|
870
|
+
if 200 <= _response.status_code < 300:
|
|
871
|
+
return pydantic_v1.parse_obj_as(RedisUpdateResponse, _response.json()) # type: ignore
|
|
872
|
+
try:
|
|
873
|
+
_response_json = _response.json()
|
|
874
|
+
except JSONDecodeError:
|
|
875
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
876
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|
|
877
|
+
|
|
878
|
+
async def sync(self, id: str, *, request_options: typing.Optional[RequestOptions] = None) -> RedisExportStorage:
|
|
879
|
+
"""
|
|
880
|
+
Sync tasks to an Redis export/target storage connection. You will need to provide the export storage ID. You can find this using [List export storages](list).
|
|
881
|
+
|
|
882
|
+
Sync operations with external databases only go one way. They either create tasks from objects in the database (source/import storage) or push annotations to the output database (export/target storage). Changing something on the database side doesn’t guarantee consistency in results.
|
|
883
|
+
|
|
884
|
+
<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>
|
|
885
|
+
|
|
886
|
+
Parameters
|
|
887
|
+
----------
|
|
888
|
+
id : str
|
|
889
|
+
|
|
890
|
+
request_options : typing.Optional[RequestOptions]
|
|
891
|
+
Request-specific configuration.
|
|
892
|
+
|
|
893
|
+
Returns
|
|
894
|
+
-------
|
|
895
|
+
RedisExportStorage
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
Examples
|
|
899
|
+
--------
|
|
900
|
+
from label_studio_sdk.client import AsyncLabelStudio
|
|
901
|
+
|
|
902
|
+
client = AsyncLabelStudio(
|
|
903
|
+
api_key="YOUR_API_KEY",
|
|
904
|
+
)
|
|
905
|
+
await client.export_storage.redis.sync(
|
|
906
|
+
id="id",
|
|
907
|
+
)
|
|
908
|
+
"""
|
|
909
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
910
|
+
f"api/storages/export/redis/{jsonable_encoder(id)}/sync", method="POST", request_options=request_options
|
|
911
|
+
)
|
|
912
|
+
if 200 <= _response.status_code < 300:
|
|
913
|
+
return pydantic_v1.parse_obj_as(RedisExportStorage, _response.json()) # type: ignore
|
|
914
|
+
try:
|
|
915
|
+
_response_json = _response.json()
|
|
916
|
+
except JSONDecodeError:
|
|
917
|
+
raise ApiError(status_code=_response.status_code, body=_response.text)
|
|
918
|
+
raise ApiError(status_code=_response.status_code, body=_response_json)
|