superb-ai-onprem 0.1.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.
Potentially problematic release.
This version of superb-ai-onprem might be problematic. Click here for more details.
- spb_onprem/__init__.py +74 -0
- spb_onprem/_version.py +21 -0
- spb_onprem/base_model.py +6 -0
- spb_onprem/base_service.py +164 -0
- spb_onprem/base_types.py +11 -0
- spb_onprem/contents/__init__.py +6 -0
- spb_onprem/contents/entities/__init__.py +8 -0
- spb_onprem/contents/entities/base_content.py +13 -0
- spb_onprem/contents/entities/content.py +17 -0
- spb_onprem/contents/queries.py +39 -0
- spb_onprem/contents/service.py +132 -0
- spb_onprem/data/__init__.py +6 -0
- spb_onprem/data/entities/__init__.py +15 -0
- spb_onprem/data/entities/annotation.py +25 -0
- spb_onprem/data/entities/data.py +28 -0
- spb_onprem/data/entities/data_meta.py +31 -0
- spb_onprem/data/entities/prediction.py +13 -0
- spb_onprem/data/entities/scene.py +14 -0
- spb_onprem/data/enums/__init__.py +10 -0
- spb_onprem/data/enums/data_meta_type.py +15 -0
- spb_onprem/data/enums/data_type.py +9 -0
- spb_onprem/data/enums/scene_type.py +10 -0
- spb_onprem/data/params/__init__.py +59 -0
- spb_onprem/data/params/create_data.py +68 -0
- spb_onprem/data/params/data.py +24 -0
- spb_onprem/data/params/data_list.py +96 -0
- spb_onprem/data/params/delete_annotation_version.py +20 -0
- spb_onprem/data/params/delete_data.py +17 -0
- spb_onprem/data/params/delete_prediction.py +22 -0
- spb_onprem/data/params/delete_scene.py +22 -0
- spb_onprem/data/params/insert_annotation_version.py +29 -0
- spb_onprem/data/params/insert_data_to_slice.py +22 -0
- spb_onprem/data/params/insert_prediction.py +25 -0
- spb_onprem/data/params/insert_scene.py +32 -0
- spb_onprem/data/params/remove_data_from_slice.py +22 -0
- spb_onprem/data/params/remove_data_meta.py +64 -0
- spb_onprem/data/params/update_annotation.py +30 -0
- spb_onprem/data/params/update_data.py +72 -0
- spb_onprem/data/params/update_scene.py +37 -0
- spb_onprem/data/params/upsert_data_meta.py +48 -0
- spb_onprem/data/queries.py +360 -0
- spb_onprem/data/service.py +524 -0
- spb_onprem/datasets/__init__.py +6 -0
- spb_onprem/datasets/entities/__init__.py +6 -0
- spb_onprem/datasets/entities/dataset.py +14 -0
- spb_onprem/datasets/params/__init__.py +11 -0
- spb_onprem/datasets/params/create_dataset.py +32 -0
- spb_onprem/datasets/params/dataset.py +26 -0
- spb_onprem/datasets/params/datasets.py +53 -0
- spb_onprem/datasets/params/update_dataset.py +39 -0
- spb_onprem/datasets/queries.py +79 -0
- spb_onprem/datasets/service.py +132 -0
- spb_onprem/exceptions.py +40 -0
- spb_onprem/slices/__init__.py +6 -0
- spb_onprem/slices/entities/__init__.py +5 -0
- spb_onprem/slices/entities/slice.py +17 -0
- spb_onprem/slices/params/__init__.py +23 -0
- spb_onprem/slices/params/create_slice.py +36 -0
- spb_onprem/slices/params/delete_slice.py +0 -0
- spb_onprem/slices/params/slice.py +42 -0
- spb_onprem/slices/params/slices.py +62 -0
- spb_onprem/slices/params/update_slice.py +45 -0
- spb_onprem/slices/queries.py +121 -0
- spb_onprem/slices/service.py +173 -0
- spb_onprem/users/__init__.py +0 -0
- spb_onprem/users/entities/__init__.py +5 -0
- spb_onprem/users/entities/auth.py +86 -0
- superb_ai_onprem-0.1.0.dist-info/METADATA +246 -0
- superb_ai_onprem-0.1.0.dist-info/RECORD +72 -0
- superb_ai_onprem-0.1.0.dist-info/WHEEL +5 -0
- superb_ai_onprem-0.1.0.dist-info/licenses/LICENSE +21 -0
- superb_ai_onprem-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
from typing import Optional, Union
|
|
2
|
+
|
|
3
|
+
from spb_onprem.base_service import BaseService
|
|
4
|
+
from spb_onprem.base_types import (
|
|
5
|
+
Undefined,
|
|
6
|
+
UndefinedType,
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
from .entities import (
|
|
10
|
+
Slice
|
|
11
|
+
)
|
|
12
|
+
from .params import (
|
|
13
|
+
SlicesFilter
|
|
14
|
+
)
|
|
15
|
+
from .queries import (
|
|
16
|
+
Queries,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class SliceService(BaseService):
|
|
21
|
+
"""Service class for handling slice-related operations."""
|
|
22
|
+
|
|
23
|
+
def create_slice(
|
|
24
|
+
self,
|
|
25
|
+
dataset_id: str,
|
|
26
|
+
name: str,
|
|
27
|
+
description: Union[
|
|
28
|
+
UndefinedType,
|
|
29
|
+
str
|
|
30
|
+
] = Undefined,
|
|
31
|
+
):
|
|
32
|
+
"""Create a slice.
|
|
33
|
+
|
|
34
|
+
Args:
|
|
35
|
+
dataset_id (str): The ID of the dataset to create the slice for.
|
|
36
|
+
name (str): The name of the slice to create.
|
|
37
|
+
description (Optional[str]): The description of the slice to create.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
Slice: The created slice object.
|
|
41
|
+
"""
|
|
42
|
+
response = self.request_gql(
|
|
43
|
+
Queries.CREATE_SLICE,
|
|
44
|
+
Queries.CREATE_SLICE["variables"](
|
|
45
|
+
dataset_id=dataset_id,
|
|
46
|
+
slice_name=name,
|
|
47
|
+
slice_description=description
|
|
48
|
+
)
|
|
49
|
+
)
|
|
50
|
+
slice_dict = response.get("createSlice", {})
|
|
51
|
+
return Slice.model_validate(slice_dict)
|
|
52
|
+
|
|
53
|
+
def get_slices(
|
|
54
|
+
self,
|
|
55
|
+
dataset_id: str,
|
|
56
|
+
slice_filter: Optional[SlicesFilter] = None,
|
|
57
|
+
cursor: Optional[str] = None,
|
|
58
|
+
length: int = 10
|
|
59
|
+
):
|
|
60
|
+
"""Get slices of a dataset.
|
|
61
|
+
|
|
62
|
+
Args:
|
|
63
|
+
dataset_id (str): The ID of the dataset to get the slices for.
|
|
64
|
+
slice_filter (Optional[SlicesFilter]): The filter to apply to the slices.
|
|
65
|
+
cursor (Optional[str]): The cursor to use for pagination.
|
|
66
|
+
length (int): The number of slices to get.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
tuple: A tuple containing the slices, the next cursor, and the total count of slices.
|
|
70
|
+
"""
|
|
71
|
+
if length > 50:
|
|
72
|
+
raise ValueError("Length must be less than or equal to 50.")
|
|
73
|
+
|
|
74
|
+
response = self.request_gql(
|
|
75
|
+
Queries.GET_SLICES,
|
|
76
|
+
Queries.GET_SLICES["variables"](
|
|
77
|
+
dataset_id=dataset_id,
|
|
78
|
+
slices_filter=slice_filter,
|
|
79
|
+
cursor=cursor,
|
|
80
|
+
length=length
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
slices_dict = response.get("slices", [])
|
|
84
|
+
slices = [Slice.model_validate(slice_dict) for slice_dict in slices_dict]
|
|
85
|
+
return (
|
|
86
|
+
slices,
|
|
87
|
+
response.get("next", None),
|
|
88
|
+
response.get("totalCount", False)
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
def get_slice(
|
|
92
|
+
self,
|
|
93
|
+
dataset_id: str,
|
|
94
|
+
slice_id: Optional[str] = None,
|
|
95
|
+
):
|
|
96
|
+
"""Get a slice by ID.
|
|
97
|
+
|
|
98
|
+
Args:
|
|
99
|
+
dataset_id (str): The ID of the dataset to get the slice for.
|
|
100
|
+
slice_id (Optional[str]): The ID of the slice to get.
|
|
101
|
+
|
|
102
|
+
Returns:
|
|
103
|
+
Slice: The slice object.
|
|
104
|
+
"""
|
|
105
|
+
response = self.request_gql(
|
|
106
|
+
Queries.GET_SLICE,
|
|
107
|
+
Queries.GET_SLICE["variables"](
|
|
108
|
+
dataset_id=dataset_id,
|
|
109
|
+
slice_id=slice_id
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
slice_dict = response.get("slice", {})
|
|
113
|
+
return Slice.model_validate(slice_dict)
|
|
114
|
+
|
|
115
|
+
def get_slice_by_name(
|
|
116
|
+
self,
|
|
117
|
+
dataset_id: str,
|
|
118
|
+
name: str,
|
|
119
|
+
):
|
|
120
|
+
"""Get a slice by name.
|
|
121
|
+
|
|
122
|
+
Args:
|
|
123
|
+
dataset_id (str): The ID of the dataset to get the slice for.
|
|
124
|
+
name (str): The name of the slice to get.
|
|
125
|
+
|
|
126
|
+
Returns:
|
|
127
|
+
Slice: The slice object.
|
|
128
|
+
"""
|
|
129
|
+
response = self.request_gql(
|
|
130
|
+
Queries.GET_SLICE,
|
|
131
|
+
Queries.GET_SLICE["variables"](
|
|
132
|
+
dataset_id=dataset_id,
|
|
133
|
+
name=name
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
slice_dict = response.get("slice", {})
|
|
137
|
+
return Slice.model_validate(slice_dict)
|
|
138
|
+
|
|
139
|
+
def update_slice(
|
|
140
|
+
self,
|
|
141
|
+
dataset_id: str,
|
|
142
|
+
slice_id: str,
|
|
143
|
+
name: Union[
|
|
144
|
+
UndefinedType,
|
|
145
|
+
str
|
|
146
|
+
] = Undefined,
|
|
147
|
+
description: Union[
|
|
148
|
+
UndefinedType,
|
|
149
|
+
str
|
|
150
|
+
] = Undefined,
|
|
151
|
+
):
|
|
152
|
+
"""Update a slice.
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
dataset_id (str): The ID of the dataset to update the slice for.
|
|
156
|
+
slice_id (str): The ID of the slice to update.
|
|
157
|
+
name (Optional[str]): The name of the slice to update.
|
|
158
|
+
description (Optional[str]): The description of the slice to update.
|
|
159
|
+
|
|
160
|
+
Returns:
|
|
161
|
+
Slice: The updated slice object.
|
|
162
|
+
"""
|
|
163
|
+
response = self.request_gql(
|
|
164
|
+
Queries.UPDATE_SLICE,
|
|
165
|
+
Queries.UPDATE_SLICE["variables"](
|
|
166
|
+
dataset_id=dataset_id,
|
|
167
|
+
slice_id=slice_id,
|
|
168
|
+
slice_name=name,
|
|
169
|
+
slice_description=description
|
|
170
|
+
)
|
|
171
|
+
)
|
|
172
|
+
slice_dict = response.get("updateSlice", {})
|
|
173
|
+
return Slice.model_validate(slice_dict)
|
|
File without changes
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import os
|
|
3
|
+
import configparser
|
|
4
|
+
from typing import Optional, ClassVar
|
|
5
|
+
|
|
6
|
+
from spb_onprem.base_model import CustomBaseModel, Field
|
|
7
|
+
from spb_onprem.exceptions import SDKConfigError
|
|
8
|
+
|
|
9
|
+
class AuthUser(CustomBaseModel):
|
|
10
|
+
host: str = Field(alias="host")
|
|
11
|
+
access_key: str = Field(alias="accessKey")
|
|
12
|
+
access_key_secret: str = Field(alias="accessKeySecret")
|
|
13
|
+
is_system_sdk: bool = Field(alias="isSystemSdk")
|
|
14
|
+
system_sdk_user_email: Optional[str] = Field(None, alias="systemSdkUserEmail")
|
|
15
|
+
|
|
16
|
+
_access_token: Optional[str] = None
|
|
17
|
+
_instance: ClassVar[Optional["AuthUser"]] = None
|
|
18
|
+
|
|
19
|
+
@classmethod
|
|
20
|
+
def get_instance(
|
|
21
|
+
cls,
|
|
22
|
+
config_file: str = "~/.spb/onprem-config"
|
|
23
|
+
) -> "AuthUser":
|
|
24
|
+
if cls._instance is None:
|
|
25
|
+
if os.environ.get("SUPERB_SYSTEM_SDK") == "true":
|
|
26
|
+
if not os.environ.get("SUNRISE_SERVER_URL") and not os.environ.get("SUPERB_SYSTEM_SDK_HOST"):
|
|
27
|
+
raise SDKConfigError("Superb Platform SDK is not configured. Please set the environment variable SUPERB_SYSTEM_SDK_URL.")
|
|
28
|
+
|
|
29
|
+
if os.environ.get("SUNRISE_SERVER_URL"):
|
|
30
|
+
system_sdk_host = os.environ.get("SUNRISE_SERVER_URL")
|
|
31
|
+
else:
|
|
32
|
+
system_sdk_host = os.environ.get("SUPERB_SYSTEM_SDK_HOST")
|
|
33
|
+
|
|
34
|
+
# Skip reading config file when SUPERB_SYSTEM_SDK is true
|
|
35
|
+
cls._instance = cls(
|
|
36
|
+
host=system_sdk_host,
|
|
37
|
+
access_key="",
|
|
38
|
+
access_key_secret="",
|
|
39
|
+
is_system_sdk=True,
|
|
40
|
+
system_sdk_user_email=os.environ.get("SUPERB_SYSTEM_SDK_USER_EMAIL", "")
|
|
41
|
+
)
|
|
42
|
+
else:
|
|
43
|
+
config_file_path = os.path.expanduser(config_file)
|
|
44
|
+
config = configparser.ConfigParser()
|
|
45
|
+
try:
|
|
46
|
+
if not config.read(config_file_path):
|
|
47
|
+
raise SDKConfigError(f"Failed to read config file: {config_file_path}")
|
|
48
|
+
|
|
49
|
+
if "default" not in config:
|
|
50
|
+
raise SDKConfigError(f"Missing 'default' section in config file: {config_file_path}")
|
|
51
|
+
|
|
52
|
+
required_keys = ["host", "access_key", "access_key_secret"]
|
|
53
|
+
for key in required_keys:
|
|
54
|
+
if key not in config["default"]:
|
|
55
|
+
raise SDKConfigError(f"Missing required key '{key}' in config file: {config_file_path}")
|
|
56
|
+
|
|
57
|
+
cls._instance = cls(
|
|
58
|
+
host=config["default"]["host"],
|
|
59
|
+
access_key=config["default"]["access_key"],
|
|
60
|
+
access_key_secret=config["default"]["access_key_secret"],
|
|
61
|
+
is_system_sdk=False,
|
|
62
|
+
system_sdk_user_email=None # Not required in normal mode
|
|
63
|
+
)
|
|
64
|
+
except configparser.Error as e:
|
|
65
|
+
raise SDKConfigError(f"Error parsing config file: {str(e)}") from e
|
|
66
|
+
return cls._instance
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def access_token(self):
|
|
70
|
+
if self._access_token:
|
|
71
|
+
return self._access_token
|
|
72
|
+
decoded_token = f"{self.access_key}:{self.access_key_secret}"
|
|
73
|
+
decoded_token_bytes = decoded_token.encode("utf-8")
|
|
74
|
+
encoded_token = base64.b64encode(decoded_token_bytes).decode("utf-8")
|
|
75
|
+
self._access_token = f"Basic {encoded_token}"
|
|
76
|
+
return self._access_token
|
|
77
|
+
|
|
78
|
+
@property
|
|
79
|
+
def auth_headers(self):
|
|
80
|
+
if self.is_system_sdk:
|
|
81
|
+
return {
|
|
82
|
+
"x-user-email": self.system_sdk_user_email
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
"Authorization": self.access_token
|
|
86
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: superb-ai-onprem
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for Superb AI On-premise
|
|
5
|
+
Home-page: https://github.com/Superb-AI-Suite/superb-ai-onprem-python
|
|
6
|
+
Author: Superb AI
|
|
7
|
+
Author-email: support@superb-ai.com
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: requests>=2.22.0
|
|
15
|
+
Requires-Dist: urllib3>=1.21.1
|
|
16
|
+
Requires-Dist: pydantic>=1.8.0
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: author-email
|
|
19
|
+
Dynamic: classifier
|
|
20
|
+
Dynamic: description
|
|
21
|
+
Dynamic: description-content-type
|
|
22
|
+
Dynamic: home-page
|
|
23
|
+
Dynamic: license-file
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: requires-python
|
|
26
|
+
Dynamic: summary
|
|
27
|
+
|
|
28
|
+
# Superb AI On-premise SDK
|
|
29
|
+
|
|
30
|
+
Python SDK for Superb AI's On-premise solution. This SDK provides a simple interface to interact with your on-premise Superb AI installation.
|
|
31
|
+
|
|
32
|
+
## Installation
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install superb-ai-onprem
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Quick Start
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from spb_onprem import DatasetService, DataService
|
|
42
|
+
from spb_onprem.data.enums import DataType
|
|
43
|
+
|
|
44
|
+
# Initialize services
|
|
45
|
+
dataset_service = DatasetService()
|
|
46
|
+
data_service = DataService()
|
|
47
|
+
|
|
48
|
+
# Create a dataset
|
|
49
|
+
dataset = dataset_service.create_dataset(
|
|
50
|
+
name="my-dataset",
|
|
51
|
+
description="My first dataset"
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
# Upload an image with annotation
|
|
55
|
+
with open("image.jpg", "rb") as f:
|
|
56
|
+
image_data = BytesIO(f.read())
|
|
57
|
+
|
|
58
|
+
data = data_service.create_image_data(
|
|
59
|
+
dataset_id=dataset.id,
|
|
60
|
+
key="image_1",
|
|
61
|
+
image_content=image_data,
|
|
62
|
+
annotation={
|
|
63
|
+
"labels": ["car", "person"],
|
|
64
|
+
"boxes": [
|
|
65
|
+
{"x": 100, "y": 100, "width": 200, "height": 200}
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Features
|
|
72
|
+
|
|
73
|
+
- Dataset Management
|
|
74
|
+
- Create, update, and delete datasets
|
|
75
|
+
- List and filter datasets
|
|
76
|
+
- Data Management
|
|
77
|
+
- Upload images with annotations
|
|
78
|
+
- Update annotations
|
|
79
|
+
- Add/remove data from slices
|
|
80
|
+
- Manage metadata
|
|
81
|
+
- Slice Management
|
|
82
|
+
- Create and manage data slices
|
|
83
|
+
- Filter and organize your data
|
|
84
|
+
|
|
85
|
+
## Usage Examples
|
|
86
|
+
|
|
87
|
+
### Dataset Operations
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from spb_onprem import DatasetService
|
|
91
|
+
from spb_onprem import DatasetsFilter, DatasetsFilterOptions
|
|
92
|
+
|
|
93
|
+
# Initialize service
|
|
94
|
+
dataset_service = DatasetService()
|
|
95
|
+
|
|
96
|
+
# Create a dataset
|
|
97
|
+
dataset = dataset_service.create_dataset(
|
|
98
|
+
name="my-dataset",
|
|
99
|
+
description="Dataset description"
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
# List datasets with filtering
|
|
103
|
+
filter = DatasetsFilter(
|
|
104
|
+
must_filter=DatasetsFilterOptions(
|
|
105
|
+
name_contains="test"
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
datasets = dataset_service.get_datasets(filter=filter)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Data Operations
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
from spb_onprem import DataService
|
|
115
|
+
from spb_onprem import DataListFilter, DataFilterOptions
|
|
116
|
+
|
|
117
|
+
# Initialize service
|
|
118
|
+
data_service = DataService()
|
|
119
|
+
|
|
120
|
+
# List data with filtering
|
|
121
|
+
filter = DataListFilter(
|
|
122
|
+
must_filter=DataFilterOptions(
|
|
123
|
+
key_contains="image_",
|
|
124
|
+
annotation_exists=True
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
data_list = data_service.get_data_list(
|
|
128
|
+
dataset_id="your-dataset-id",
|
|
129
|
+
filter=filter
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
# Update annotation
|
|
133
|
+
data_service.update_annotation(
|
|
134
|
+
dataset_id="your-dataset-id",
|
|
135
|
+
data_id="your-data-id",
|
|
136
|
+
annotation={
|
|
137
|
+
"labels": ["updated_label"],
|
|
138
|
+
"boxes": [...]
|
|
139
|
+
}
|
|
140
|
+
)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Slice Operations
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from spb_onprem import SliceService
|
|
147
|
+
|
|
148
|
+
# Initialize service
|
|
149
|
+
slice_service = SliceService()
|
|
150
|
+
|
|
151
|
+
# Create a slice
|
|
152
|
+
slice = slice_service.create_slice(
|
|
153
|
+
dataset_id="your-dataset-id",
|
|
154
|
+
name="validation-set",
|
|
155
|
+
description="Validation data slice"
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
# Add data to slice
|
|
159
|
+
data_service.add_data_to_slice(
|
|
160
|
+
dataset_id="your-dataset-id",
|
|
161
|
+
data_id="your-data-id",
|
|
162
|
+
slice_id=slice.id
|
|
163
|
+
)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Error Handling
|
|
167
|
+
|
|
168
|
+
The SDK provides specific error types for different scenarios:
|
|
169
|
+
|
|
170
|
+
```python
|
|
171
|
+
from spb_onprem.exceptions import (
|
|
172
|
+
BadParameterError,
|
|
173
|
+
NotFoundError,
|
|
174
|
+
UnknownError
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
try:
|
|
178
|
+
dataset = dataset_service.get_dataset(dataset_id="non-existent-id")
|
|
179
|
+
except NotFoundError:
|
|
180
|
+
print("Dataset not found")
|
|
181
|
+
except BadParameterError as e:
|
|
182
|
+
print(f"Invalid parameter: {e}")
|
|
183
|
+
except UnknownError as e:
|
|
184
|
+
print(f"An unexpected error occurred: {e}")
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Configuration
|
|
188
|
+
|
|
189
|
+
The SDK supports two authentication methods:
|
|
190
|
+
|
|
191
|
+
### 1. Config File Authentication (Default)
|
|
192
|
+
|
|
193
|
+
Create a config file at `~/.spb/onprem-config`:
|
|
194
|
+
|
|
195
|
+
```ini
|
|
196
|
+
[default]
|
|
197
|
+
host=https://your-onprem-host
|
|
198
|
+
access_key=your-access-key
|
|
199
|
+
access_key_secret=your-access-key-secret
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
This is the default authentication method when `SUPERB_SYSTEM_SDK=false` or not set.
|
|
203
|
+
|
|
204
|
+
### 2. Environment Variables (for Airflow DAGs)
|
|
205
|
+
|
|
206
|
+
When running in an Airflow DAG or other system environments, you can use environment variables for authentication. This method is activated by setting `SUPERB_SYSTEM_SDK=true`.
|
|
207
|
+
|
|
208
|
+
Required environment variables:
|
|
209
|
+
```bash
|
|
210
|
+
# Enable system SDK mode
|
|
211
|
+
export SUPERB_SYSTEM_SDK=true
|
|
212
|
+
|
|
213
|
+
# Set the host URL (either one is required)
|
|
214
|
+
export SUPERB_SYSTEM_SDK_HOST=https://your-superb-ai-host
|
|
215
|
+
# or
|
|
216
|
+
export SUNRISE_SERVER_URL=https://your-superb-ai-host
|
|
217
|
+
|
|
218
|
+
# Set the user email
|
|
219
|
+
export SUPERB_SYSTEM_SDK_USER_EMAIL=user@example.com
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
You can set these environment variables:
|
|
223
|
+
- Directly in your shell
|
|
224
|
+
- In your Airflow DAG configuration
|
|
225
|
+
- Through your deployment environment
|
|
226
|
+
- Using a `.env` file with your preferred method of loading environment variables
|
|
227
|
+
|
|
228
|
+
Note:
|
|
229
|
+
- When `SUPERB_SYSTEM_SDK=true`, the SDK will ignore the config file (`~/.spb/onprem-config`) and use environment variables exclusively.
|
|
230
|
+
- When `SUPERB_SYSTEM_SDK=false` or not set, the SDK will look for authentication credentials in `~/.spb/onprem-config`.
|
|
231
|
+
|
|
232
|
+
## Requirements
|
|
233
|
+
|
|
234
|
+
- Python >= 3.7
|
|
235
|
+
- requests >= 2.22.0
|
|
236
|
+
- urllib3 >= 1.21.1
|
|
237
|
+
- pydantic >= 1.8.0
|
|
238
|
+
|
|
239
|
+
## License
|
|
240
|
+
|
|
241
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
242
|
+
|
|
243
|
+
## Support
|
|
244
|
+
|
|
245
|
+
For support or feature requests, please contact the Superb AI team or create an issue in this repository.
|
|
246
|
+
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
spb_onprem/__init__.py,sha256=fUHnDGYMnuyRT4DmsjuUDiTujP_uWn0nHGknPzGtvCo,1330
|
|
2
|
+
spb_onprem/_version.py,sha256=-LyU5F1uZDjn6Q8_Z6-_FJt_8RE4Kq9zcKdg1abSSps,511
|
|
3
|
+
spb_onprem/base_model.py,sha256=f2l5lgu7NYGOpVbE4_gAhMq1jBBRhaLwPf4fwJVrOHM,124
|
|
4
|
+
spb_onprem/base_service.py,sha256=zaZ1rOhSAzi0bNc-y-WpUUYpM_cQl3hLFXpbmmCg73k,5607
|
|
5
|
+
spb_onprem/base_types.py,sha256=5HO6uy6qf08b4KSElwIaGy7UkoQG2KqVO6gcHbsqqSo,269
|
|
6
|
+
spb_onprem/exceptions.py,sha256=jx5rTGsVZ5shOdbgQzk8GcSyMWFtb_3xhPq6Sylwc5o,478
|
|
7
|
+
spb_onprem/contents/__init__.py,sha256=9EfIMQxbJuUZVUqsTa3Ji-yDidFPQQB5gnJI4R01YWI,74
|
|
8
|
+
spb_onprem/contents/queries.py,sha256=tGMVH8ixv0CW5bJTWICCjWDM_oAN7jkfEQXdAJUVn4Q,851
|
|
9
|
+
spb_onprem/contents/service.py,sha256=KoPUffr_DEGOMIOwkue0rkidHMPfmAJG0KgJyXN6N_Y,3602
|
|
10
|
+
spb_onprem/contents/entities/__init__.py,sha256=HsQ9J8UDxCx4xYTdMKQto7HCVUQilNozQCkIsceWezk,117
|
|
11
|
+
spb_onprem/contents/entities/base_content.py,sha256=nM7NALpeRjtUKPv7eU0-hlqT1rPtD2mwB6Bvv_2Zc1E,346
|
|
12
|
+
spb_onprem/contents/entities/content.py,sha256=YhTGHE9ykiOgFjvxbnLzSLg2665jPYrDATteB9PbGPE,534
|
|
13
|
+
spb_onprem/data/__init__.py,sha256=5XKxNm2BlKufrX5uRQreUEzJ-nerTrozKpG1RJL5wt8,68
|
|
14
|
+
spb_onprem/data/queries.py,sha256=iAs-RpVP1sLAwOCQdQQh2FAOJ_PJES7ZIhIWq2mU55M,8886
|
|
15
|
+
spb_onprem/data/service.py,sha256=K9ssHxQ9MMsiQFyzbFSQvx3m5Mguwqf3dgV5G2a_cxQ,15448
|
|
16
|
+
spb_onprem/data/entities/__init__.py,sha256=xqhb0FqYC-n6JF0v10YoaENpz10c2DReG5S2SIY681M,287
|
|
17
|
+
spb_onprem/data/entities/annotation.py,sha256=WbKRkNao60xTwRKchmcWfw4zRDwu-VBuo-Zgu2ArtN4,676
|
|
18
|
+
spb_onprem/data/entities/data.py,sha256=bi8EsfPirMR0d5SV_KrYGh0BmoMdbt38x6DArxDz2gU,1148
|
|
19
|
+
spb_onprem/data/entities/data_meta.py,sha256=88Y8HQ14UEmL2RkrYAGIxVJVkOcxjIQfo6WaDxRo-3E,1052
|
|
20
|
+
spb_onprem/data/entities/prediction.py,sha256=Eb2ldNSezeYDnaLQOfC65XWoDGJ0snlvlcyM_mH34w8,400
|
|
21
|
+
spb_onprem/data/entities/scene.py,sha256=SJgr5UnGxktyaKjU8FYDaIQmsu7xSJftJOiCgq9uSmo,446
|
|
22
|
+
spb_onprem/data/enums/__init__.py,sha256=IJWaapwesyIiIjuAykZc5fXdMXK2_IiOBa7qNY5cCNk,213
|
|
23
|
+
spb_onprem/data/enums/data_meta_type.py,sha256=9rd12-7C1udbbIGvnuGURKmd5-lndtW7oWQAQwKSf_Q,335
|
|
24
|
+
spb_onprem/data/enums/data_type.py,sha256=S7sbKHtJC_pvhNxLt8xtSFO3edo0Q9c7pZ3UyEeCeVA,178
|
|
25
|
+
spb_onprem/data/enums/scene_type.py,sha256=ed8fAKfDk9PNG8YgYv3jI59IR9oCr_gkooexAe0448I,187
|
|
26
|
+
spb_onprem/data/params/__init__.py,sha256=IApFFU6t3lHclvbivLSFdUxhrj1BjO50c3OMG6zP2iY,1311
|
|
27
|
+
spb_onprem/data/params/create_data.py,sha256=8DOfbEchf9GSybiYY1cZoNzNYwILokoAkxXRFybJUAU,2038
|
|
28
|
+
spb_onprem/data/params/data.py,sha256=HXf1a7Peq-WMYGc-R60aJOBGq0nKAK20cZJdgcUim-A,662
|
|
29
|
+
spb_onprem/data/params/data_list.py,sha256=ggh3qzyC5cNufW8xTIMMpg1N2U3FINHMtiem-HMnTqo,3320
|
|
30
|
+
spb_onprem/data/params/delete_annotation_version.py,sha256=R_jBVujor-09VS1Aa8yGP14R8nJ2Aa9OmmKezC4gz4c,457
|
|
31
|
+
spb_onprem/data/params/delete_data.py,sha256=HN4xXW9o4ZFOSjlzRZJ-F0wwtd_RzgI30gVWoULo1p8,319
|
|
32
|
+
spb_onprem/data/params/delete_prediction.py,sha256=X3sV2mrSUqg8FOlZYRtb0o1hAwFos48ydFK2Il8UCp4,479
|
|
33
|
+
spb_onprem/data/params/delete_scene.py,sha256=pD8TtS5Jm2uQC3F2EQ6-nAbQuQbJLG2pAwFqmsgucyM,478
|
|
34
|
+
spb_onprem/data/params/insert_annotation_version.py,sha256=vfu9_pES8wEoRWBbqktRWpp0VxZzAbtIdYLQOR5kwAA,738
|
|
35
|
+
spb_onprem/data/params/insert_data_to_slice.py,sha256=_hLNC80wJbxGSouOpjwTY19mAf-itfRR4sxHnlLiiqk,478
|
|
36
|
+
spb_onprem/data/params/insert_prediction.py,sha256=68q5ZSSq4arAsozy1i52phkUoBfUSzNVVxCuygRYDfI,621
|
|
37
|
+
spb_onprem/data/params/insert_scene.py,sha256=n36XVbOlPc8MrFusOtXaXDHmG2Wa13ZnQX-0300b12E,774
|
|
38
|
+
spb_onprem/data/params/remove_data_from_slice.py,sha256=UjoQH0gTdm1nE1DafUmq3CP1nzHiCwDUnytQ6oBcZAA,478
|
|
39
|
+
spb_onprem/data/params/remove_data_meta.py,sha256=nlj2Ln9CtdS4Si8TmETZlQoAU62nCTCLbZR2_yE3yB8,1847
|
|
40
|
+
spb_onprem/data/params/update_annotation.py,sha256=zEmXYlBBYeC8A9eNyGidSw2XbgLd-pgvRZK5eui2plA,787
|
|
41
|
+
spb_onprem/data/params/update_data.py,sha256=zlIqvUzMrEh-6eRUZ35lKmG2Ep6pYCPEl9dWvXz2rdM,1861
|
|
42
|
+
spb_onprem/data/params/update_scene.py,sha256=zMJFUHF3vz_hVSkkVEwHwdZBjWRbRxgTQFtsBowAg-k,930
|
|
43
|
+
spb_onprem/data/params/upsert_data_meta.py,sha256=gVj-IY4V8DDbQQI9kEIwnwz7Pg4ObwUzyBhFoDNE-v4,1507
|
|
44
|
+
spb_onprem/datasets/__init__.py,sha256=Sjrb1tewB3CoODtHjRYOe-w2HpZi9UgbCyE2p8MzHfw,74
|
|
45
|
+
spb_onprem/datasets/queries.py,sha256=PSj-3tOJfWUw8YXsv682LbcZoGbGHGgSQbWQGXjLePY,1912
|
|
46
|
+
spb_onprem/datasets/service.py,sha256=ehc3IMYCN72pWZXvSs-j5jeYWQ6CxkU-0AA1-OwmtIk,3872
|
|
47
|
+
spb_onprem/datasets/entities/__init__.py,sha256=yx5tsyX4GLYrjqx6-ZEoceJ7jxQzIh15OgyFFCs7vow,59
|
|
48
|
+
spb_onprem/datasets/entities/dataset.py,sha256=HO7EU5vwSBnILCI9xXhgZb36akIi6AC0ApamQlQczhU,538
|
|
49
|
+
spb_onprem/datasets/params/__init__.py,sha256=7wmc4xQi3GOSeREelqfAveI0buYJWn7huX1Q9_jl_50,291
|
|
50
|
+
spb_onprem/datasets/params/create_dataset.py,sha256=YGhLvY4arthjZwKQ28HLv7ch0Gd2lJ-vyGHBZnMuy4E,719
|
|
51
|
+
spb_onprem/datasets/params/dataset.py,sha256=WTOUl5M5cc6rtTwhLw_z31Cs209LkBq8Ja4LJGzrmGE,668
|
|
52
|
+
spb_onprem/datasets/params/datasets.py,sha256=Hx4YlLxfb-Qwi4Y5AFl5pyyjupvuoVcCtxLPGjIV7UY,1580
|
|
53
|
+
spb_onprem/datasets/params/update_dataset.py,sha256=1oaj2qB9hvnypl4-WtcTNCa4iSuEkJjEalq2JsTm5Ro,924
|
|
54
|
+
spb_onprem/slices/__init__.py,sha256=xgpNGYzqgwQ8C-Bgw9AZWMAgBW38UU-U4Wube8hkodI,69
|
|
55
|
+
spb_onprem/slices/queries.py,sha256=dl_q6Uc2_oeuItgSD6gUL7a3H5VrOW9Ig5Epte7sl78,2732
|
|
56
|
+
spb_onprem/slices/service.py,sha256=byhB9CdxNKV7uLIiL9yI674UVSlgaAwLaYoGQGBCawE,4988
|
|
57
|
+
spb_onprem/slices/entities/__init__.py,sha256=fXBFWw9NI0DkTORkHczs_oFPqE9MVISOsAqnN4-euh0,52
|
|
58
|
+
spb_onprem/slices/entities/slice.py,sha256=Kcn3G8NLQhpRID9xkwe6_CvS5kaJOMDPUStHM-BYkhY,623
|
|
59
|
+
spb_onprem/slices/params/__init__.py,sha256=dEUDlOK-iw3Sx7gpkDMnwMqTFE16-856ZdbYuwppeqs,394
|
|
60
|
+
spb_onprem/slices/params/create_slice.py,sha256=qUpX60A72Uht0SzN7b2-QSKvd_MSEV5T9kYIVk_td8A,1009
|
|
61
|
+
spb_onprem/slices/params/delete_slice.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
62
|
+
spb_onprem/slices/params/slice.py,sha256=R8U_RadZLWPeQu6ZWGIvXH6Dxi4ikzoHyDKWGewmUjw,1035
|
|
63
|
+
spb_onprem/slices/params/slices.py,sha256=rz3epZE6k6uNk4Gepob1byUYpZhAaHK6Vh_lh3TdqXo,1893
|
|
64
|
+
spb_onprem/slices/params/update_slice.py,sha256=kryOmCnRTQ_OU0qDKgugppLrpeUpuLwmn_87M5zKqIA,1209
|
|
65
|
+
spb_onprem/users/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
66
|
+
spb_onprem/users/entities/__init__.py,sha256=X8HZsCTlQnuPszok3AwI-i7bsQi0Ehul5L_2jZaol5E,57
|
|
67
|
+
spb_onprem/users/entities/auth.py,sha256=UWy1dKOeUCTsXvIIqUHgPpU_RAtM82HC4X2S9ShOr98,3765
|
|
68
|
+
superb_ai_onprem-0.1.0.dist-info/licenses/LICENSE,sha256=CdinbFiHKGkGl6cPde6WgXhMuzyUXEG6tzy2-7udZ8o,1066
|
|
69
|
+
superb_ai_onprem-0.1.0.dist-info/METADATA,sha256=JtHf2G_-Q_u0pZOI0Sj8KWwvQBE3kxvqbxmrM2EkdEQ,5817
|
|
70
|
+
superb_ai_onprem-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
71
|
+
superb_ai_onprem-0.1.0.dist-info/top_level.txt,sha256=AZIJi8aIRJ8vxBL6vvODXVPadF4oetwn0ji2NiAndpM,11
|
|
72
|
+
superb_ai_onprem-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Superb AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
spb_onprem
|