superb-ai-onprem 0.1.0__tar.gz

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.

Files changed (81) hide show
  1. superb_ai_onprem-0.1.0/.env.local +10 -0
  2. superb_ai_onprem-0.1.0/.github/workflows/publish.yml +30 -0
  3. superb_ai_onprem-0.1.0/.gitignore +49 -0
  4. superb_ai_onprem-0.1.0/LICENSE +21 -0
  5. superb_ai_onprem-0.1.0/PKG-INFO +246 -0
  6. superb_ai_onprem-0.1.0/README.md +219 -0
  7. superb_ai_onprem-0.1.0/pyproject.toml +6 -0
  8. superb_ai_onprem-0.1.0/setup.cfg +4 -0
  9. superb_ai_onprem-0.1.0/setup.py +28 -0
  10. superb_ai_onprem-0.1.0/spb_onprem/__init__.py +74 -0
  11. superb_ai_onprem-0.1.0/spb_onprem/_version.py +21 -0
  12. superb_ai_onprem-0.1.0/spb_onprem/base_model.py +6 -0
  13. superb_ai_onprem-0.1.0/spb_onprem/base_service.py +164 -0
  14. superb_ai_onprem-0.1.0/spb_onprem/base_types.py +11 -0
  15. superb_ai_onprem-0.1.0/spb_onprem/contents/__init__.py +6 -0
  16. superb_ai_onprem-0.1.0/spb_onprem/contents/entities/__init__.py +8 -0
  17. superb_ai_onprem-0.1.0/spb_onprem/contents/entities/base_content.py +13 -0
  18. superb_ai_onprem-0.1.0/spb_onprem/contents/entities/content.py +17 -0
  19. superb_ai_onprem-0.1.0/spb_onprem/contents/queries.py +39 -0
  20. superb_ai_onprem-0.1.0/spb_onprem/contents/service.py +132 -0
  21. superb_ai_onprem-0.1.0/spb_onprem/data/__init__.py +6 -0
  22. superb_ai_onprem-0.1.0/spb_onprem/data/entities/__init__.py +15 -0
  23. superb_ai_onprem-0.1.0/spb_onprem/data/entities/annotation.py +25 -0
  24. superb_ai_onprem-0.1.0/spb_onprem/data/entities/data.py +28 -0
  25. superb_ai_onprem-0.1.0/spb_onprem/data/entities/data_meta.py +31 -0
  26. superb_ai_onprem-0.1.0/spb_onprem/data/entities/prediction.py +13 -0
  27. superb_ai_onprem-0.1.0/spb_onprem/data/entities/scene.py +14 -0
  28. superb_ai_onprem-0.1.0/spb_onprem/data/enums/__init__.py +10 -0
  29. superb_ai_onprem-0.1.0/spb_onprem/data/enums/data_meta_type.py +15 -0
  30. superb_ai_onprem-0.1.0/spb_onprem/data/enums/data_type.py +9 -0
  31. superb_ai_onprem-0.1.0/spb_onprem/data/enums/scene_type.py +10 -0
  32. superb_ai_onprem-0.1.0/spb_onprem/data/params/__init__.py +59 -0
  33. superb_ai_onprem-0.1.0/spb_onprem/data/params/create_data.py +68 -0
  34. superb_ai_onprem-0.1.0/spb_onprem/data/params/data.py +24 -0
  35. superb_ai_onprem-0.1.0/spb_onprem/data/params/data_list.py +96 -0
  36. superb_ai_onprem-0.1.0/spb_onprem/data/params/delete_annotation_version.py +20 -0
  37. superb_ai_onprem-0.1.0/spb_onprem/data/params/delete_data.py +17 -0
  38. superb_ai_onprem-0.1.0/spb_onprem/data/params/delete_prediction.py +22 -0
  39. superb_ai_onprem-0.1.0/spb_onprem/data/params/delete_scene.py +22 -0
  40. superb_ai_onprem-0.1.0/spb_onprem/data/params/insert_annotation_version.py +29 -0
  41. superb_ai_onprem-0.1.0/spb_onprem/data/params/insert_data_to_slice.py +22 -0
  42. superb_ai_onprem-0.1.0/spb_onprem/data/params/insert_prediction.py +25 -0
  43. superb_ai_onprem-0.1.0/spb_onprem/data/params/insert_scene.py +32 -0
  44. superb_ai_onprem-0.1.0/spb_onprem/data/params/remove_data_from_slice.py +22 -0
  45. superb_ai_onprem-0.1.0/spb_onprem/data/params/remove_data_meta.py +64 -0
  46. superb_ai_onprem-0.1.0/spb_onprem/data/params/update_annotation.py +30 -0
  47. superb_ai_onprem-0.1.0/spb_onprem/data/params/update_data.py +72 -0
  48. superb_ai_onprem-0.1.0/spb_onprem/data/params/update_scene.py +37 -0
  49. superb_ai_onprem-0.1.0/spb_onprem/data/params/upsert_data_meta.py +48 -0
  50. superb_ai_onprem-0.1.0/spb_onprem/data/queries.py +360 -0
  51. superb_ai_onprem-0.1.0/spb_onprem/data/service.py +524 -0
  52. superb_ai_onprem-0.1.0/spb_onprem/datasets/__init__.py +6 -0
  53. superb_ai_onprem-0.1.0/spb_onprem/datasets/entities/__init__.py +6 -0
  54. superb_ai_onprem-0.1.0/spb_onprem/datasets/entities/dataset.py +14 -0
  55. superb_ai_onprem-0.1.0/spb_onprem/datasets/params/__init__.py +11 -0
  56. superb_ai_onprem-0.1.0/spb_onprem/datasets/params/create_dataset.py +32 -0
  57. superb_ai_onprem-0.1.0/spb_onprem/datasets/params/dataset.py +26 -0
  58. superb_ai_onprem-0.1.0/spb_onprem/datasets/params/datasets.py +53 -0
  59. superb_ai_onprem-0.1.0/spb_onprem/datasets/params/update_dataset.py +39 -0
  60. superb_ai_onprem-0.1.0/spb_onprem/datasets/queries.py +79 -0
  61. superb_ai_onprem-0.1.0/spb_onprem/datasets/service.py +132 -0
  62. superb_ai_onprem-0.1.0/spb_onprem/exceptions.py +40 -0
  63. superb_ai_onprem-0.1.0/spb_onprem/slices/__init__.py +6 -0
  64. superb_ai_onprem-0.1.0/spb_onprem/slices/entities/__init__.py +5 -0
  65. superb_ai_onprem-0.1.0/spb_onprem/slices/entities/slice.py +17 -0
  66. superb_ai_onprem-0.1.0/spb_onprem/slices/params/__init__.py +23 -0
  67. superb_ai_onprem-0.1.0/spb_onprem/slices/params/create_slice.py +36 -0
  68. superb_ai_onprem-0.1.0/spb_onprem/slices/params/delete_slice.py +0 -0
  69. superb_ai_onprem-0.1.0/spb_onprem/slices/params/slice.py +42 -0
  70. superb_ai_onprem-0.1.0/spb_onprem/slices/params/slices.py +62 -0
  71. superb_ai_onprem-0.1.0/spb_onprem/slices/params/update_slice.py +45 -0
  72. superb_ai_onprem-0.1.0/spb_onprem/slices/queries.py +121 -0
  73. superb_ai_onprem-0.1.0/spb_onprem/slices/service.py +173 -0
  74. superb_ai_onprem-0.1.0/spb_onprem/users/__init__.py +0 -0
  75. superb_ai_onprem-0.1.0/spb_onprem/users/entities/__init__.py +5 -0
  76. superb_ai_onprem-0.1.0/spb_onprem/users/entities/auth.py +86 -0
  77. superb_ai_onprem-0.1.0/superb_ai_onprem.egg-info/PKG-INFO +246 -0
  78. superb_ai_onprem-0.1.0/superb_ai_onprem.egg-info/SOURCES.txt +79 -0
  79. superb_ai_onprem-0.1.0/superb_ai_onprem.egg-info/dependency_links.txt +1 -0
  80. superb_ai_onprem-0.1.0/superb_ai_onprem.egg-info/requires.txt +3 -0
  81. superb_ai_onprem-0.1.0/superb_ai_onprem.egg-info/top_level.txt +1 -0
@@ -0,0 +1,10 @@
1
+ # System SDK Configuration
2
+ # Set to "true" to use system SDK mode (typically used in Airflow DAGs)
3
+ SUPERB_SYSTEM_SDK=false
4
+
5
+ # Host Configuration
6
+ # Either SUNRISE_SERVER_URL or SUPERB_SYSTEM_SDK_HOST must be set when SUPERB_SYSTEM_SDK is true
7
+ SUPERB_SYSTEM_SDK_HOST=https://your-superb-ai-host
8
+
9
+ # User Configuration (Required when SUPERB_SYSTEM_SDK is true)
10
+ SUPERB_SYSTEM_SDK_USER_EMAIL=user@example.com
@@ -0,0 +1,30 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - 'v*' # Trigger on version tags
7
+
8
+ jobs:
9
+ deploy:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - name: Set up Python
14
+ uses: actions/setup-python@v4
15
+ with:
16
+ python-version: '3.x'
17
+
18
+ - name: Install dependencies
19
+ run: |
20
+ python -m pip install --upgrade pip
21
+ pip install build twine
22
+
23
+ - name: Build package
24
+ run: python -m build
25
+
26
+ - name: Publish to PyPI
27
+ env:
28
+ TWINE_USERNAME: __token__
29
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
30
+ run: twine upload dist/*
@@ -0,0 +1,49 @@
1
+ # IDE
2
+ .vscode
3
+ .idea
4
+
5
+ # Environment
6
+ .env
7
+ *.env
8
+
9
+ # Python
10
+ __pycache__/
11
+ *.py[cod]
12
+ *$py.class
13
+ *.so
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # Unit test / coverage reports
33
+ htmlcov/
34
+ .tox/
35
+ .nox/
36
+ .coverage
37
+ .coverage.*
38
+ .cache
39
+ nosetests.xml
40
+ coverage.xml
41
+ *.cover
42
+ .hypothesis/
43
+ .pytest_cache/
44
+
45
+ # Jupyter Notebook
46
+ .ipynb_checkpoints
47
+
48
+ # Logs
49
+ *.log
@@ -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,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,219 @@
1
+ # Superb AI On-premise SDK
2
+
3
+ Python SDK for Superb AI's On-premise solution. This SDK provides a simple interface to interact with your on-premise Superb AI installation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install superb-ai-onprem
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```python
14
+ from spb_onprem import DatasetService, DataService
15
+ from spb_onprem.data.enums import DataType
16
+
17
+ # Initialize services
18
+ dataset_service = DatasetService()
19
+ data_service = DataService()
20
+
21
+ # Create a dataset
22
+ dataset = dataset_service.create_dataset(
23
+ name="my-dataset",
24
+ description="My first dataset"
25
+ )
26
+
27
+ # Upload an image with annotation
28
+ with open("image.jpg", "rb") as f:
29
+ image_data = BytesIO(f.read())
30
+
31
+ data = data_service.create_image_data(
32
+ dataset_id=dataset.id,
33
+ key="image_1",
34
+ image_content=image_data,
35
+ annotation={
36
+ "labels": ["car", "person"],
37
+ "boxes": [
38
+ {"x": 100, "y": 100, "width": 200, "height": 200}
39
+ ]
40
+ }
41
+ )
42
+ ```
43
+
44
+ ## Features
45
+
46
+ - Dataset Management
47
+ - Create, update, and delete datasets
48
+ - List and filter datasets
49
+ - Data Management
50
+ - Upload images with annotations
51
+ - Update annotations
52
+ - Add/remove data from slices
53
+ - Manage metadata
54
+ - Slice Management
55
+ - Create and manage data slices
56
+ - Filter and organize your data
57
+
58
+ ## Usage Examples
59
+
60
+ ### Dataset Operations
61
+
62
+ ```python
63
+ from spb_onprem import DatasetService
64
+ from spb_onprem import DatasetsFilter, DatasetsFilterOptions
65
+
66
+ # Initialize service
67
+ dataset_service = DatasetService()
68
+
69
+ # Create a dataset
70
+ dataset = dataset_service.create_dataset(
71
+ name="my-dataset",
72
+ description="Dataset description"
73
+ )
74
+
75
+ # List datasets with filtering
76
+ filter = DatasetsFilter(
77
+ must_filter=DatasetsFilterOptions(
78
+ name_contains="test"
79
+ )
80
+ )
81
+ datasets = dataset_service.get_datasets(filter=filter)
82
+ ```
83
+
84
+ ### Data Operations
85
+
86
+ ```python
87
+ from spb_onprem import DataService
88
+ from spb_onprem import DataListFilter, DataFilterOptions
89
+
90
+ # Initialize service
91
+ data_service = DataService()
92
+
93
+ # List data with filtering
94
+ filter = DataListFilter(
95
+ must_filter=DataFilterOptions(
96
+ key_contains="image_",
97
+ annotation_exists=True
98
+ )
99
+ )
100
+ data_list = data_service.get_data_list(
101
+ dataset_id="your-dataset-id",
102
+ filter=filter
103
+ )
104
+
105
+ # Update annotation
106
+ data_service.update_annotation(
107
+ dataset_id="your-dataset-id",
108
+ data_id="your-data-id",
109
+ annotation={
110
+ "labels": ["updated_label"],
111
+ "boxes": [...]
112
+ }
113
+ )
114
+ ```
115
+
116
+ ### Slice Operations
117
+
118
+ ```python
119
+ from spb_onprem import SliceService
120
+
121
+ # Initialize service
122
+ slice_service = SliceService()
123
+
124
+ # Create a slice
125
+ slice = slice_service.create_slice(
126
+ dataset_id="your-dataset-id",
127
+ name="validation-set",
128
+ description="Validation data slice"
129
+ )
130
+
131
+ # Add data to slice
132
+ data_service.add_data_to_slice(
133
+ dataset_id="your-dataset-id",
134
+ data_id="your-data-id",
135
+ slice_id=slice.id
136
+ )
137
+ ```
138
+
139
+ ## Error Handling
140
+
141
+ The SDK provides specific error types for different scenarios:
142
+
143
+ ```python
144
+ from spb_onprem.exceptions import (
145
+ BadParameterError,
146
+ NotFoundError,
147
+ UnknownError
148
+ )
149
+
150
+ try:
151
+ dataset = dataset_service.get_dataset(dataset_id="non-existent-id")
152
+ except NotFoundError:
153
+ print("Dataset not found")
154
+ except BadParameterError as e:
155
+ print(f"Invalid parameter: {e}")
156
+ except UnknownError as e:
157
+ print(f"An unexpected error occurred: {e}")
158
+ ```
159
+
160
+ ## Configuration
161
+
162
+ The SDK supports two authentication methods:
163
+
164
+ ### 1. Config File Authentication (Default)
165
+
166
+ Create a config file at `~/.spb/onprem-config`:
167
+
168
+ ```ini
169
+ [default]
170
+ host=https://your-onprem-host
171
+ access_key=your-access-key
172
+ access_key_secret=your-access-key-secret
173
+ ```
174
+
175
+ This is the default authentication method when `SUPERB_SYSTEM_SDK=false` or not set.
176
+
177
+ ### 2. Environment Variables (for Airflow DAGs)
178
+
179
+ 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`.
180
+
181
+ Required environment variables:
182
+ ```bash
183
+ # Enable system SDK mode
184
+ export SUPERB_SYSTEM_SDK=true
185
+
186
+ # Set the host URL (either one is required)
187
+ export SUPERB_SYSTEM_SDK_HOST=https://your-superb-ai-host
188
+ # or
189
+ export SUNRISE_SERVER_URL=https://your-superb-ai-host
190
+
191
+ # Set the user email
192
+ export SUPERB_SYSTEM_SDK_USER_EMAIL=user@example.com
193
+ ```
194
+
195
+ You can set these environment variables:
196
+ - Directly in your shell
197
+ - In your Airflow DAG configuration
198
+ - Through your deployment environment
199
+ - Using a `.env` file with your preferred method of loading environment variables
200
+
201
+ Note:
202
+ - When `SUPERB_SYSTEM_SDK=true`, the SDK will ignore the config file (`~/.spb/onprem-config`) and use environment variables exclusively.
203
+ - When `SUPERB_SYSTEM_SDK=false` or not set, the SDK will look for authentication credentials in `~/.spb/onprem-config`.
204
+
205
+ ## Requirements
206
+
207
+ - Python >= 3.7
208
+ - requests >= 2.22.0
209
+ - urllib3 >= 1.21.1
210
+ - pydantic >= 1.8.0
211
+
212
+ ## License
213
+
214
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
215
+
216
+ ## Support
217
+
218
+ For support or feature requests, please contact the Superb AI team or create an issue in this repository.
219
+
@@ -0,0 +1,6 @@
1
+ [build-system]
2
+ requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.setuptools_scm]
6
+ write_to = "spb_onprem/_version.py"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,28 @@
1
+ from setuptools import setup, find_packages
2
+
3
+ with open("README.md", "r", encoding="utf-8") as fh:
4
+ long_description = fh.read()
5
+
6
+ setup(
7
+ name="superb-ai-onprem",
8
+ use_scm_version=True,
9
+ setup_requires=['setuptools_scm'],
10
+ author="Superb AI",
11
+ author_email="support@superb-ai.com",
12
+ description="Python SDK for Superb AI On-premise",
13
+ long_description=long_description,
14
+ long_description_content_type="text/markdown",
15
+ url="https://github.com/Superb-AI-Suite/superb-ai-onprem-python",
16
+ packages=find_packages(),
17
+ classifiers=[
18
+ "Programming Language :: Python :: 3",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Operating System :: OS Independent",
21
+ ],
22
+ python_requires=">=3.8",
23
+ install_requires=[
24
+ "requests>=2.22.0", # Python 3.7 지원 시작 버전
25
+ "urllib3>=1.21.1", # Retry 기능 안정화 버전
26
+ "pydantic>=1.8.0", # Python 3.7 지원 안정 버전
27
+ ],
28
+ )
@@ -0,0 +1,74 @@
1
+ try:
2
+ from ._version import version as __version__
3
+ except ImportError:
4
+ __version__ = "0.0.0.dev0"
5
+
6
+ # Services
7
+ from .datasets.service import DatasetService
8
+ from .data.service import DataService
9
+ from .slices.service import SliceService
10
+
11
+ # Core Entities
12
+ from .data.entities import (
13
+ Data,
14
+ Scene,
15
+ Annotation,
16
+ AnnotationVersion,
17
+ Prediction,
18
+ DataMeta,
19
+ )
20
+ from .datasets.entities import Dataset
21
+ from .slices.entities import Slice
22
+
23
+ # Enums
24
+ from .data.enums import (
25
+ DataType,
26
+ SceneType,
27
+ DataMetaTypes,
28
+ DataMetaValue,
29
+ )
30
+
31
+ # Filters
32
+ from .data.params.data_list import (
33
+ AnnotationFilter,
34
+ DataListFilter,
35
+ DataFilterOptions,
36
+ )
37
+ from .datasets.params.datasets import (
38
+ DatasetsFilter,
39
+ DatasetsFilterOptions,
40
+ )
41
+ from .slices.params.slices import (
42
+ SlicesFilterOptions,
43
+ )
44
+
45
+ __all__ = (
46
+ # Services
47
+ "DatasetService",
48
+ "DataService",
49
+ "SliceService",
50
+
51
+ # Core Entities
52
+ "Data",
53
+ "Scene",
54
+ "Annotation",
55
+ "AnnotationVersion",
56
+ "Prediction",
57
+ "DataMeta",
58
+ "Dataset",
59
+ "Slice",
60
+
61
+ # Enums
62
+ "DataType",
63
+ "SceneType",
64
+ "DataMetaTypes",
65
+ "DataMetaValue",
66
+
67
+ # Filters
68
+ "AnnotationFilter",
69
+ "DataListFilter",
70
+ "DataFilterOptions",
71
+ "DatasetsFilter",
72
+ "DatasetsFilterOptions",
73
+ "SlicesFilterOptions",
74
+ )