voltagegpu-cli 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
volt/sdk/utils.py ADDED
@@ -0,0 +1,94 @@
1
+ """Utility helpers for the Lium SDK."""
2
+
3
+ import hashlib
4
+ import random
5
+ import re
6
+ import time
7
+ from functools import wraps
8
+ from typing import Callable, TypeVar
9
+
10
+ import requests
11
+
12
+ from .exceptions import LiumRateLimitError, LiumServerError
13
+
14
+ F = TypeVar("F", bound=Callable[..., object])
15
+
16
+ # Human-friendly ID parts
17
+ ADJECTIVES = ["swift", "brave", "calm", "eager", "gentle", "cosmic", "golden", "lunar", "zesty", "noble"]
18
+ NOUNS = ["hawk", "lion", "eagle", "fox", "wolf", "shark", "raven", "matrix", "comet", "orbit"]
19
+
20
+
21
+ def generate_huid(id_str: str) -> str:
22
+ """Generate human-readable ID from UUID."""
23
+ if not id_str:
24
+ return "invalid"
25
+
26
+ digest = hashlib.md5(id_str.encode()).hexdigest()
27
+ adj = ADJECTIVES[int(digest[:4], 16) % len(ADJECTIVES)]
28
+ noun = NOUNS[int(digest[4:8], 16) % len(NOUNS)]
29
+ return f"{adj}-{noun}-{digest[-2:]}"
30
+
31
+
32
+ def extract_gpu_type(machine_name: str) -> str:
33
+ """Extract GPU type from machine name."""
34
+ patterns = [
35
+ (r"RTX\s*(\d{4})", lambda m: f"RTX{m.group(1)}"),
36
+ (r"([HBL])(\d{2,3}S?)", lambda m: f"{m.group(1)}{m.group(2)}"),
37
+ (r"A(\d{2,4})", lambda m: f"A{m.group(1)}"),
38
+ ]
39
+ for pattern, fmt in patterns:
40
+ if match := re.search(pattern, machine_name, re.I):
41
+ return fmt(match)
42
+ return machine_name.split()[-1] if machine_name else "Unknown"
43
+
44
+
45
+ def expand_gpu_shorthand(gpu_short: str) -> str:
46
+ """Expand GPU shorthand to a pattern that matches full machine names.
47
+
48
+ Examples:
49
+ A100 -> "A100" (matches "NVIDIA A100-SXM4-80GB", "NVIDIA A100-PCIE-40GB", etc.)
50
+ H200 -> "H200" (matches "NVIDIA H200", etc.)
51
+ RTX4090 -> "RTX 4090" (matches "NVIDIA GeForce RTX 4090", etc.)
52
+
53
+ Args:
54
+ gpu_short: Short GPU name like "A100", "H200", "RTX4090"
55
+
56
+ Returns:
57
+ Pattern string that can be used to filter machine names.
58
+ """
59
+ # Already a full name or pattern, return as-is
60
+ if len(gpu_short) > 10 or " " in gpu_short:
61
+ return gpu_short
62
+
63
+ gpu_upper = gpu_short.upper()
64
+
65
+ # Handle RTX cards - need to add space between RTX and number
66
+ if gpu_upper.startswith("RTX"):
67
+ # RTX4090 -> RTX 4090
68
+ match = re.match(r"RTX(\d+)", gpu_upper)
69
+ if match:
70
+ return f"RTX {match.group(1)}"
71
+
72
+ # For A-series (A100, A6000, etc.) and H-series (H100, H200, etc.)
73
+ # Just return as-is since the API does substring matching
74
+ # "A100" will match "NVIDIA A100-SXM4-80GB"
75
+ return gpu_short
76
+
77
+
78
+ def with_retry(max_attempts: int = 3, delay: float = 1.0):
79
+ """Retry decorator for API calls."""
80
+ def decorator(func: F) -> F:
81
+ @wraps(func)
82
+ def wrapper(*args, **kwargs):
83
+ for attempt in range(max_attempts):
84
+ try:
85
+ return func(*args, **kwargs)
86
+ except (LiumRateLimitError, LiumServerError, requests.RequestException):
87
+ if attempt == max_attempts - 1:
88
+ raise
89
+ time.sleep(delay * (2 ** attempt) + random.uniform(0, 0.5))
90
+ return wrapper # type: ignore[misc]
91
+ return decorator
92
+
93
+
94
+ __all__ = ["generate_huid", "extract_gpu_type", "expand_gpu_shorthand", "with_retry"]
@@ -0,0 +1,288 @@
1
+ Metadata-Version: 2.4
2
+ Name: voltagegpu-cli
3
+ Version: 1.0.0
4
+ Summary: VoltageGPU CLI - Command-line interface for managing GPU cloud resources on voltagegpu.com. Deploy, manage, and scale your GPU workloads with ease.
5
+ Project-URL: Homepage, https://voltagegpu.com
6
+ Project-URL: Documentation, https://docs.voltagegpu.com
7
+ Project-URL: Repository, https://github.com/voltagegpu/voltagegpu-cli
8
+ Project-URL: Issues, https://github.com/voltagegpu/voltagegpu-cli/issues
9
+ Author-email: VoltageGPU <support@voltagegpu.com>
10
+ Keywords: ai,cli,cloud,deep-learning,gpu,machine-learning,voltagegpu
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
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
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: System :: Distributed Computing
23
+ Requires-Python: >=3.9
24
+ Requires-Dist: click>=8.0
25
+ Requires-Dist: httpx>=0.24.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: black; extra == 'dev'
28
+ Requires-Dist: pytest; extra == 'dev'
29
+ Requires-Dist: wheel; extra == 'dev'
30
+ Provides-Extra: docs
31
+ Requires-Dist: sphinx-rtd-theme>=1.3; extra == 'docs'
32
+ Requires-Dist: sphinx>=7.3; extra == 'docs'
33
+ Description-Content-Type: text/markdown
34
+
35
+ # VoltageGPU CLI
36
+
37
+ Command-line interface and Python SDK for VoltageGPU - affordable GPU cloud computing for AI/ML workloads.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install voltagegpu-cli
43
+ ```
44
+
45
+ Or install from source:
46
+
47
+ ```bash
48
+ git clone https://github.com/voltagegpu/voltagegpu-cli.git
49
+ cd voltagegpu-cli
50
+ pip install -e .
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ ### 1. Configure your API key
56
+
57
+ Set the environment variable:
58
+
59
+ ```bash
60
+ export VOLT_API_KEY="your_api_key_here"
61
+ ```
62
+
63
+ Or create a config file at `~/.volt/config.ini`:
64
+
65
+ ```ini
66
+ [api]
67
+ api_key = your_api_key_here
68
+ ```
69
+
70
+ ### 2. List available templates
71
+
72
+ ```bash
73
+ volt templates list
74
+ ```
75
+
76
+ ### 3. Create a pod
77
+
78
+ ```bash
79
+ volt pods create --template <template_id> --name my-gpu-pod
80
+ ```
81
+
82
+ ### 4. SSH into your pod
83
+
84
+ ```bash
85
+ volt pods ssh <pod_id>
86
+ ```
87
+
88
+ ## CLI Commands
89
+
90
+ ### Pods
91
+
92
+ ```bash
93
+ # List all pods
94
+ volt pods list
95
+ volt pods list --json
96
+
97
+ # Get pod details
98
+ volt pods get <pod_id>
99
+
100
+ # Create a new pod
101
+ volt pods create --template <template_id> --name <name> [--gpu-count 1] [--ssh-key <key_id>]
102
+
103
+ # Start/Stop/Delete pods
104
+ volt pods start <pod_id>
105
+ volt pods stop <pod_id>
106
+ volt pods delete <pod_id> [--yes]
107
+
108
+ # Get SSH command
109
+ volt pods ssh <pod_id>
110
+ ```
111
+
112
+ ### Templates
113
+
114
+ ```bash
115
+ # List available templates
116
+ volt templates list
117
+ volt templates list --category llm
118
+ volt templates list --json
119
+
120
+ # Get template details
121
+ volt templates get <template_id>
122
+ ```
123
+
124
+ ### SSH Keys
125
+
126
+ ```bash
127
+ # List SSH keys
128
+ volt ssh-keys list
129
+
130
+ # Add a new SSH key
131
+ volt ssh-keys add --name "my-key" --file ~/.ssh/id_ed25519.pub
132
+ volt ssh-keys add --name "my-key" --key "ssh-ed25519 AAAA..."
133
+
134
+ # Delete an SSH key
135
+ volt ssh-keys delete <key_id>
136
+ ```
137
+
138
+ ### Machines
139
+
140
+ ```bash
141
+ # List available machines
142
+ volt machines list
143
+ volt machines list --gpu RTX4090
144
+ volt machines list --json
145
+ ```
146
+
147
+ ### Account
148
+
149
+ ```bash
150
+ # Check balance
151
+ volt account balance
152
+
153
+ # Get account info
154
+ volt account info
155
+ ```
156
+
157
+ ### Configuration
158
+
159
+ ```bash
160
+ # Show current configuration
161
+ volt config
162
+ ```
163
+
164
+ ## Python SDK
165
+
166
+ You can also use VoltageGPU as a Python library:
167
+
168
+ ```python
169
+ from volt import VoltageGPUClient
170
+
171
+ # Initialize client (uses VOLT_API_KEY env var or ~/.volt/config.ini)
172
+ client = VoltageGPUClient()
173
+
174
+ # List pods
175
+ pods = client.list_pods()
176
+ for pod in pods:
177
+ print(f"{pod.name}: {pod.status} ({pod.gpu_type})")
178
+
179
+ # Create a pod
180
+ pod = client.create_pod(
181
+ template_id="template-123",
182
+ name="my-training-pod",
183
+ gpu_count=2
184
+ )
185
+ print(f"Created pod: {pod.id}")
186
+
187
+ # Get SSH connection info
188
+ pod = client.get_pod(pod.id)
189
+ print(f"SSH: ssh -p {pod.ssh_port} root@{pod.ssh_host}")
190
+
191
+ # Stop and delete
192
+ client.stop_pod(pod.id)
193
+ client.delete_pod(pod.id)
194
+ ```
195
+
196
+ ### Context Manager
197
+
198
+ ```python
199
+ from volt import VoltageGPUClient
200
+
201
+ with VoltageGPUClient() as client:
202
+ templates = client.list_templates()
203
+ for t in templates:
204
+ print(f"{t.name}: ${t.hourly_price}/hr")
205
+ ```
206
+
207
+ ### Custom Configuration
208
+
209
+ ```python
210
+ from volt.sdk import Config, VoltageGPUClient
211
+
212
+ config = Config(
213
+ api_key="your_api_key",
214
+ base_url="https://voltagegpu.com/api"
215
+ )
216
+ client = VoltageGPUClient(config=config)
217
+ ```
218
+
219
+ ## Environment Variables
220
+
221
+ | Variable | Description | Default |
222
+ |----------|-------------|---------|
223
+ | `VOLT_API_KEY` | Your VoltageGPU API key | - |
224
+ | `VOLT_BASE_URL` | API base URL | `https://voltagegpu.com/api` |
225
+ | `LIUM_API_KEY` | Legacy API key (fallback) | - |
226
+
227
+ ## Configuration File
228
+
229
+ Create `~/.volt/config.ini`:
230
+
231
+ ```ini
232
+ [api]
233
+ api_key = your_api_key_here
234
+ ```
235
+
236
+ ## Output Formats
237
+
238
+ Most list commands support `--json` flag for machine-readable output:
239
+
240
+ ```bash
241
+ volt pods list --json | jq '.[] | select(.status == "running")'
242
+ ```
243
+
244
+ ## Examples
245
+
246
+ ### Launch a training job
247
+
248
+ ```bash
249
+ # Find a suitable template
250
+ volt templates list --category ml
251
+
252
+ # Create pod with SSH key
253
+ volt pods create \
254
+ --template pytorch-cuda12 \
255
+ --name training-job \
256
+ --gpu-count 4 \
257
+ --ssh-key my-key-id
258
+
259
+ # Get SSH command
260
+ volt pods ssh <pod_id>
261
+ ```
262
+
263
+ ### Monitor costs
264
+
265
+ ```bash
266
+ # Check balance
267
+ volt account balance
268
+
269
+ # List running pods with costs
270
+ volt pods list | grep running
271
+ ```
272
+
273
+ ### Batch operations with jq
274
+
275
+ ```bash
276
+ # Stop all running pods
277
+ volt pods list --json | jq -r '.[] | select(.status == "running") | .id' | xargs -I {} volt pods stop {}
278
+ ```
279
+
280
+ ## Support
281
+
282
+ - Website: https://voltagegpu.com
283
+ - Documentation: https://docs.voltagegpu.com
284
+ - Email: support@voltagegpu.com
285
+
286
+ ## License
287
+
288
+ MIT License - see LICENSE file for details.
@@ -0,0 +1,14 @@
1
+ volt/__init__.py,sha256=5mj6qn88CHB7HTYEfxpyf6KVNGAPLOAwkLnWRxqPQ8U,169
2
+ volt/cli/__init__.py,sha256=C30c4Qb9If5qp3-DL5izT4aqghi09o2DCjjMEoh1LqY,79
3
+ volt/cli/cli.py,sha256=dVUygtLU-sq8B2kpeQ8F5v8vnMyCMzm4iDx6QefYrd8,13060
4
+ volt/sdk/__init__.py,sha256=4Cv6YSKLInZBrO2WIaF3BTwxtj7CxUk_QxtoEK3Q-Xo,193
5
+ volt/sdk/client.py,sha256=Tl02DK-elpGmb0HLYgrt5chBEmrECnYkqag6SeFyysE,9351
6
+ volt/sdk/config.py,sha256=j01zsvw6GOnZ98CaSVdE3iKCZLf3T5OfTQNmTEWISh8,2286
7
+ volt/sdk/decorators.py,sha256=wtWhqEA4VvS9xf19yzWz7tNd0c4BjXHKpY5buhOecvA,7849
8
+ volt/sdk/exceptions.py,sha256=BK_RC1ef5LV50f6A-Z5BZaeN9KKKqjN5MRcQzAZmtKA,539
9
+ volt/sdk/models.py,sha256=PC3zpXadXF4VE6vHagTBBC_GFYtM0q7fa7QbgpheB_E,3125
10
+ volt/sdk/utils.py,sha256=NP58Hi5_Z5bDQYF5qaA8c-TmWfOoMIqEf0c8ZplTH9o,3276
11
+ voltagegpu_cli-1.0.0.dist-info/METADATA,sha256=1qK4A2iXZDJdV09gKglUvnHkDAtjlJDBbHuhsbyFY_0,5887
12
+ voltagegpu_cli-1.0.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
13
+ voltagegpu_cli-1.0.0.dist-info/entry_points.txt,sha256=oncTVsfHJOq_-Fl4QdWbbXfSVXbCRlYH3bbzxTcgu8s,43
14
+ voltagegpu_cli-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ volt = volt.cli.cli:main