kaio 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.
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kaio
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for the Kaio multi-tenant machine learning platform
|
|
5
|
+
Home-page: https://github.com/Kaion5-Compute/kaio
|
|
6
|
+
Author: Kaio Platform
|
|
7
|
+
Author-email: Kaio Platform <danielb@kaion5.com>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/Kaion5-Compute/kaio
|
|
10
|
+
Project-URL: Repository, https://github.com/Kaion5-Compute/kaio
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: requests>=2.25.0
|
|
25
|
+
Requires-Dist: packaging>=21.0
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: home-page
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
Dynamic: requires-python
|
|
30
|
+
|
|
31
|
+
# Kaio Python Client
|
|
32
|
+
|
|
33
|
+
A Python client for the Kaio multi-tenant machine learning platform that enables developers to run SageMaker jobs through simple APIs with automatic image resolution and secure file uploads.
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
pip install kaio
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from kaio import Client
|
|
45
|
+
|
|
46
|
+
# Initialize client
|
|
47
|
+
client = Client("https://api.kaion5.com")
|
|
48
|
+
|
|
49
|
+
# Login with your API key
|
|
50
|
+
client.login("your-api-key")
|
|
51
|
+
|
|
52
|
+
# Submit a job
|
|
53
|
+
result = client.submit_job(
|
|
54
|
+
directory="./my_code",
|
|
55
|
+
job_name="training-job",
|
|
56
|
+
instance_type="ml.g4dn.xlarge",
|
|
57
|
+
entrypoint="train.py"
|
|
58
|
+
)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Features
|
|
62
|
+
|
|
63
|
+
- **Automatic Image Resolution**: Detects your local ML framework and selects appropriate Docker images
|
|
64
|
+
- **Secure File Uploads**: Handles code packaging and S3 uploads automatically
|
|
65
|
+
- **Job Management**: Submit, monitor, and download results from SageMaker jobs
|
|
66
|
+
- **Multi-Framework Support**: Works with PyTorch, TensorFlow, and Scikit-learn
|
|
67
|
+
- **GPU/CPU Instance Matching**: Automatically selects GPU or CPU optimized containers
|
|
68
|
+
- **Automatic Dependencies**: Adds required packages (nbconvert, psutil, GPUtil) to requirements.txt
|
|
69
|
+
- **JWT Token Management**: Handles authentication token refresh automatically
|
|
70
|
+
|
|
71
|
+
## API Reference
|
|
72
|
+
|
|
73
|
+
### Client
|
|
74
|
+
|
|
75
|
+
#### `Client(api_base, verbose=False)`
|
|
76
|
+
|
|
77
|
+
Initialize the Kaio client.
|
|
78
|
+
|
|
79
|
+
**Parameters:**
|
|
80
|
+
- `api_base` (str): Base URL of the Kaio API endpoint
|
|
81
|
+
- `verbose` (bool): Enable verbose logging for debugging. Defaults to False.
|
|
82
|
+
|
|
83
|
+
**Example:**
|
|
84
|
+
```python
|
|
85
|
+
client = Client("https://api.kaion5.com", verbose=True)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### `login(api_key)`
|
|
89
|
+
|
|
90
|
+
Authenticate with API key and obtain JWT token.
|
|
91
|
+
|
|
92
|
+
**Parameters:**
|
|
93
|
+
- `api_key` (str): Your Kaio platform API key
|
|
94
|
+
|
|
95
|
+
**Returns:**
|
|
96
|
+
- `Client`: Self for method chaining
|
|
97
|
+
|
|
98
|
+
**Raises:**
|
|
99
|
+
- `requests.HTTPError`: If authentication fails
|
|
100
|
+
|
|
101
|
+
#### `submit_job(**kwargs)`
|
|
102
|
+
|
|
103
|
+
Submit a SageMaker job with automatic image resolution.
|
|
104
|
+
|
|
105
|
+
**Parameters:**
|
|
106
|
+
- `directory` (str): Path to code directory. Defaults to current directory.
|
|
107
|
+
- `job_name` (str): Unique name for the job. Defaults to "job".
|
|
108
|
+
- `instance_type` (str): SageMaker instance type. Defaults to "ml.m5.large".
|
|
109
|
+
- `instance_count` (int): Number of instances. Defaults to 1.
|
|
110
|
+
- `volume_size_gb` (int): EBS volume size in GB. Defaults to 5.
|
|
111
|
+
- `entrypoint` (str): Main script to execute (.py or .ipynb). Defaults to "train.py".
|
|
112
|
+
- `input_data` (str, optional): S3 URI for input data (not implemented yet).
|
|
113
|
+
- `framework` (str, optional): ML framework ("pytorch", "tensorflow", "sklearn").
|
|
114
|
+
- `framework_version` (str, optional): Framework version.
|
|
115
|
+
|
|
116
|
+
**Returns:**
|
|
117
|
+
- `dict`: Job submission result with status, job_name, and entrypoint
|
|
118
|
+
|
|
119
|
+
**Raises:**
|
|
120
|
+
- `requests.HTTPError`: If API calls fail
|
|
121
|
+
- `FileNotFoundError`: If directory or entrypoint doesn't exist
|
|
122
|
+
- `ValueError`: If code package exceeds volume capacity
|
|
123
|
+
|
|
124
|
+
#### `get_job(job_id)`
|
|
125
|
+
|
|
126
|
+
Get job status and details.
|
|
127
|
+
|
|
128
|
+
**Parameters:**
|
|
129
|
+
- `job_id` (str): Job identifier
|
|
130
|
+
|
|
131
|
+
**Returns:**
|
|
132
|
+
- `dict`: Job details including status, logs, and output URLs
|
|
133
|
+
|
|
134
|
+
**Raises:**
|
|
135
|
+
- `requests.HTTPError`: If job not found or API error
|
|
136
|
+
|
|
137
|
+
#### `download_output(job_id, output_dir=".")`
|
|
138
|
+
|
|
139
|
+
Download completed job output files.
|
|
140
|
+
|
|
141
|
+
**Parameters:**
|
|
142
|
+
- `job_id` (str): Job identifier
|
|
143
|
+
- `output_dir` (str): Local directory to save output. Defaults to current directory.
|
|
144
|
+
|
|
145
|
+
**Returns:**
|
|
146
|
+
- `Path`: Path to downloaded output tar.gz file
|
|
147
|
+
|
|
148
|
+
**Raises:**
|
|
149
|
+
- `RuntimeError`: If job is not completed
|
|
150
|
+
- `requests.HTTPError`: If download fails
|
|
151
|
+
|
|
152
|
+
## Supported Instance Types
|
|
153
|
+
|
|
154
|
+
### CPU Instances
|
|
155
|
+
- `ml.m5.large`, `ml.m5.xlarge`, `ml.m5.2xlarge`, `ml.m5.4xlarge`
|
|
156
|
+
- `ml.c5.large`, `ml.c5.xlarge`, `ml.c5.2xlarge`, `ml.c5.4xlarge`
|
|
157
|
+
|
|
158
|
+
### GPU Instances
|
|
159
|
+
- `ml.g4dn.xlarge`, `ml.g4dn.2xlarge`, `ml.g4dn.4xlarge`, `ml.g4dn.8xlarge`
|
|
160
|
+
- `ml.p3.2xlarge`, `ml.p3.8xlarge`, `ml.p3.16xlarge`
|
|
161
|
+
- `ml.g5.xlarge`, `ml.g5.2xlarge`, `ml.g5.4xlarge`, `ml.g5.8xlarge`
|
|
162
|
+
|
|
163
|
+
## Framework Auto-Detection
|
|
164
|
+
|
|
165
|
+
The SDK automatically detects your local ML framework and selects appropriate Docker images:
|
|
166
|
+
|
|
167
|
+
- **PyTorch**: Detects version and selects matching SageMaker PyTorch container
|
|
168
|
+
- **TensorFlow**: Detects version and selects matching SageMaker TensorFlow container
|
|
169
|
+
- **Scikit-learn**: Falls back to scikit-learn container for general ML workloads
|
|
170
|
+
|
|
171
|
+
## Code Requirements
|
|
172
|
+
|
|
173
|
+
### File Size Limits
|
|
174
|
+
Code packages must not exceed half your volume size:
|
|
175
|
+
- 5GB volume → 2.5GB max code package
|
|
176
|
+
- 10GB volume → 5GB max code package
|
|
177
|
+
|
|
178
|
+
### Automatic Dependencies
|
|
179
|
+
The SDK automatically adds these packages to your requirements.txt:
|
|
180
|
+
- `nbconvert` - For Jupyter notebook execution
|
|
181
|
+
- `psutil` - For system monitoring
|
|
182
|
+
- `GPUtil` - For GPU monitoring
|
|
183
|
+
|
|
184
|
+
## Examples
|
|
185
|
+
|
|
186
|
+
### Basic PyTorch Training
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from kaio import Client
|
|
190
|
+
|
|
191
|
+
client = Client("https://api.kaion5.com")
|
|
192
|
+
client.login("your-api-key")
|
|
193
|
+
|
|
194
|
+
result = client.submit_job(
|
|
195
|
+
directory="./pytorch_model",
|
|
196
|
+
job_name="pytorch-training",
|
|
197
|
+
instance_type="ml.g4dn.xlarge",
|
|
198
|
+
entrypoint="train.py",
|
|
199
|
+
volume_size_gb=10
|
|
200
|
+
)
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### TensorFlow with Custom Framework Version
|
|
204
|
+
|
|
205
|
+
```python
|
|
206
|
+
result = client.submit_job(
|
|
207
|
+
directory="./tensorflow_model",
|
|
208
|
+
job_name="tf-experiment",
|
|
209
|
+
instance_type="ml.p3.2xlarge",
|
|
210
|
+
framework="tensorflow",
|
|
211
|
+
framework_version="2.13.0",
|
|
212
|
+
entrypoint="model.py"
|
|
213
|
+
)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Jupyter Notebook Execution
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
result = client.submit_job(
|
|
220
|
+
directory="./notebooks",
|
|
221
|
+
job_name="data-analysis",
|
|
222
|
+
instance_type="ml.m5.xlarge",
|
|
223
|
+
entrypoint="analysis.ipynb"
|
|
224
|
+
)
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Error Handling
|
|
228
|
+
|
|
229
|
+
```python
|
|
230
|
+
import requests
|
|
231
|
+
|
|
232
|
+
try:
|
|
233
|
+
result = client.submit_job(
|
|
234
|
+
directory="./code",
|
|
235
|
+
job_name="my-job",
|
|
236
|
+
instance_type="ml.g4dn.xlarge"
|
|
237
|
+
)
|
|
238
|
+
except requests.HTTPError as e:
|
|
239
|
+
if e.response.status_code == 403:
|
|
240
|
+
print("Access denied - check your API key")
|
|
241
|
+
else:
|
|
242
|
+
print(f"API error: {e}")
|
|
243
|
+
except ValueError as e:
|
|
244
|
+
print(f"Configuration error: {e}")
|
|
245
|
+
except FileNotFoundError as e:
|
|
246
|
+
print(f"File not found: {e}")
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
MIT License
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
kaio-0.1.0.dist-info/licenses/LICENSE,sha256=_TVlejkXenceRFIY0xmMGtXuyR1IUZXRAZfHW0pa8yo,1069
|
|
2
|
+
kaio-0.1.0.dist-info/METADATA,sha256=jZXMM0fWVdYuWYa3Z_hp7oG-RU8xEdqBbMxhRU8_TXQ,7260
|
|
3
|
+
kaio-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
4
|
+
kaio-0.1.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
5
|
+
kaio-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Kaio Platform
|
|
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
|
+
|