trainwave-cli 0.4.1__tar.gz → 0.4.2__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.
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/PKG-INFO +1 -1
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/pyproject.toml +1 -1
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/cli/jobs.py +51 -14
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/uv.lock +1 -1
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/.dockerignore +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/.gitignore +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/.gitlab-ci.yml +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/Makefile +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/README.md +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/README.md +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/basic/requirements.txt +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/basic/run.sh +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/basic/setup.sh +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/basic/train.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/basic/trainwave.toml +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/disk-exhaustion/requirements.txt +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/disk-exhaustion/run.sh +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/disk-exhaustion/setup.sh +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/disk-exhaustion/train.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/disk-exhaustion/trainwave.toml +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/memory-exhaustion/requirements.txt +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/memory-exhaustion/run.sh +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/memory-exhaustion/setup.sh +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/memory-exhaustion/train.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/memory-exhaustion/trainwave.toml +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/secret-leak/requirements.txt +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/secret-leak/run.sh +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/secret-leak/setup.sh +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/secret-leak/train.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/example/secret-leak/trainwave.toml +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/pyrightconfig.json +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/ruff.toml +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/tests/cli/test_auth.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/tests/cli/test_jobs.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/tests/cli/test_secrets.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/tests/cli/test_setup.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/tests/conftest.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/tests/test_api.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/tests/test_io.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/tests/test_main.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/tests/test_utils.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/__init__.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/api.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/cli/auth.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/cli/logs.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/cli/offers.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/cli/secrets.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/cli/setup.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/cli/ssh_keys.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/config/config.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/format_utils.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/io.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/main.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/utils.py +0 -0
- {trainwave_cli-0.4.1 → trainwave_cli-0.4.2}/trainwave_cli/xceptions.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "trainwave-cli"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.2"
|
|
4
4
|
description = "Trainwave CLI - A command-line interface for managing Trainwave resources"
|
|
5
5
|
authors = [{ name = "Johan Backman", email = "johan@trainwave.ai" }]
|
|
6
6
|
maintainers = [{ name = "Johan Backman", email = "johan@trainwave.ai" }]
|
|
@@ -20,7 +20,12 @@ from trainwave_cli.cli.logs import stream_logs
|
|
|
20
20
|
from trainwave_cli.config.config import config
|
|
21
21
|
from trainwave_cli.format_utils import cents_to_dollars_str
|
|
22
22
|
from trainwave_cli.io import create_tarball
|
|
23
|
-
from trainwave_cli.utils import
|
|
23
|
+
from trainwave_cli.utils import (
|
|
24
|
+
async_command,
|
|
25
|
+
ensure_api_key,
|
|
26
|
+
to_dict_recursive,
|
|
27
|
+
truncate_string,
|
|
28
|
+
)
|
|
24
29
|
|
|
25
30
|
# Terminal states — no point polling for RUNNING once the job is in one of these.
|
|
26
31
|
_TERMINAL_JOB_STATES = {
|
|
@@ -43,7 +48,9 @@ async def _wait_until_running(
|
|
|
43
48
|
typer.echo(f"Job {job.rid} state: {job.state.value}")
|
|
44
49
|
last_state = job.state
|
|
45
50
|
|
|
46
|
-
if job.state == JobStatus.RUNNING and any(
|
|
51
|
+
if job.state == JobStatus.RUNNING and any(
|
|
52
|
+
i.state == "RUNNING" for i in job.instances
|
|
53
|
+
):
|
|
47
54
|
return job
|
|
48
55
|
if job.state in _TERMINAL_JOB_STATES:
|
|
49
56
|
raise RuntimeError(
|
|
@@ -61,6 +68,7 @@ def _ssh_into_job(job: Job, proxy_host: str, proxy_port: int) -> None:
|
|
|
61
68
|
typer.echo(f"Connecting to {username}@{proxy_host}:{proxy_port}...")
|
|
62
69
|
os.execvp("ssh", ["ssh", "-p", str(proxy_port), f"{username}@{proxy_host}"])
|
|
63
70
|
|
|
71
|
+
|
|
64
72
|
app = typer.Typer()
|
|
65
73
|
|
|
66
74
|
|
|
@@ -72,10 +80,14 @@ async def launch( # noqa
|
|
|
72
80
|
# Basic job parameters
|
|
73
81
|
name: Annotated[str, typer.Option(help="The name of the job")],
|
|
74
82
|
project: Annotated[str, typer.Option(help="The project ID or RID")],
|
|
75
|
-
setup_command: Annotated[
|
|
83
|
+
setup_command: Annotated[
|
|
84
|
+
str, typer.Option(help="The command to run before the job")
|
|
85
|
+
],
|
|
76
86
|
run_command: Annotated[str, typer.Option(help="The command to run the job")],
|
|
77
87
|
# Optional params
|
|
78
|
-
organization: Annotated[
|
|
88
|
+
organization: Annotated[
|
|
89
|
+
str | None, typer.Option(help="ID or RID of organization")
|
|
90
|
+
] = None,
|
|
79
91
|
expires: Annotated[
|
|
80
92
|
str,
|
|
81
93
|
typer.Option(
|
|
@@ -92,17 +104,30 @@ async def launch( # noqa
|
|
|
92
104
|
] = True,
|
|
93
105
|
exclude_regex: Annotated[
|
|
94
106
|
str | None,
|
|
95
|
-
typer.Option(
|
|
107
|
+
typer.Option(
|
|
108
|
+
help="Files matching this pattern will be ignored when packaging up the job"
|
|
109
|
+
),
|
|
96
110
|
] = None,
|
|
97
111
|
# Harware parameters
|
|
98
|
-
image: Annotated[
|
|
112
|
+
image: Annotated[
|
|
113
|
+
str, typer.Option(help="The docker image to use as base for the job")
|
|
114
|
+
] = "",
|
|
99
115
|
hdd_size_mb: Annotated[int, typer.Option(help="Hard drive size in MB")] = 20,
|
|
100
116
|
memory_mb: Annotated[int, typer.Option(help="Memory in MB")] = 0,
|
|
101
117
|
cpus: Annotated[int, typer.Option(help="Number of CPUs")] = 0,
|
|
102
|
-
gpus: Annotated[
|
|
103
|
-
|
|
118
|
+
gpus: Annotated[
|
|
119
|
+
int, typer.Option(help="Number of GPUs to allocate of the `gpu_type`")
|
|
120
|
+
] = 0,
|
|
121
|
+
gpu_type: Annotated[
|
|
122
|
+
str, typer.Option(help="Canonical name of the GPU to use")
|
|
123
|
+
] = "",
|
|
104
124
|
compliance_soc2: Annotated[
|
|
105
|
-
bool | None,
|
|
125
|
+
bool | None,
|
|
126
|
+
typer.Option("--compliance-soc2", help="Only use SOC2 compliant machines"),
|
|
127
|
+
] = None,
|
|
128
|
+
clouds: Annotated[
|
|
129
|
+
list[str] | None,
|
|
130
|
+
typer.Option(help="List of cloud providers to use (e.g. GOOGLE, AWS, AZURE)"),
|
|
106
131
|
] = None,
|
|
107
132
|
interactive: Annotated[
|
|
108
133
|
bool,
|
|
@@ -139,6 +164,8 @@ async def launch( # noqa
|
|
|
139
164
|
}
|
|
140
165
|
if compliance_soc2 is not None:
|
|
141
166
|
conf["compliance_soc2"] = compliance_soc2
|
|
167
|
+
if clouds is not None:
|
|
168
|
+
conf["clouds"] = clouds
|
|
142
169
|
if interactive:
|
|
143
170
|
conf["interactive"] = True
|
|
144
171
|
|
|
@@ -177,7 +204,9 @@ async def launch( # noqa
|
|
|
177
204
|
tarball = create_tarball(
|
|
178
205
|
Path().cwd(), exclude_gitignore, exclude_regex, show_progress_bar=not json
|
|
179
206
|
)
|
|
180
|
-
await api_client.upload_code(
|
|
207
|
+
await api_client.upload_code(
|
|
208
|
+
Path(tarball.name), job.upload_url, show_progress_bar=not json
|
|
209
|
+
)
|
|
181
210
|
await api_client.code_submission(job)
|
|
182
211
|
|
|
183
212
|
co = asdict(job.cloud_offer)
|
|
@@ -187,7 +216,9 @@ async def launch( # noqa
|
|
|
187
216
|
"value": [truncate_string(str(co[k]), 50) for k in tab_keys],
|
|
188
217
|
}
|
|
189
218
|
if not json:
|
|
190
|
-
typer.echo(
|
|
219
|
+
typer.echo(
|
|
220
|
+
"\nMatched machine\n" + tabulate(tab_values, headers="keys") + "\n"
|
|
221
|
+
)
|
|
191
222
|
typer.echo(f"Cost per hour for this job: ${job.cost_per_hour:.2f}")
|
|
192
223
|
typer.echo(f"Job created: {job.rid} ({job.id}) -> {job.url}")
|
|
193
224
|
else:
|
|
@@ -221,7 +252,9 @@ async def list_jobs(
|
|
|
221
252
|
project: Annotated[str, typer.Option(help="Project ID or RID")] = "",
|
|
222
253
|
) -> None:
|
|
223
254
|
"""List all jobs in the current project."""
|
|
224
|
-
api_client = Api(
|
|
255
|
+
api_client = Api(
|
|
256
|
+
config.api_key, config.endpoint, project=project, organization=organization
|
|
257
|
+
)
|
|
225
258
|
jobs = await api_client.list_jobs()
|
|
226
259
|
|
|
227
260
|
headers = ["ID", "NAME", "STATUS", "GPUS", "COST", "CREATED"]
|
|
@@ -289,7 +322,9 @@ async def ssh(
|
|
|
289
322
|
] = None,
|
|
290
323
|
extra: Annotated[
|
|
291
324
|
list[str] | None,
|
|
292
|
-
typer.Argument(
|
|
325
|
+
typer.Argument(
|
|
326
|
+
help="Extra arguments forwarded to ssh (e.g. a command to run)."
|
|
327
|
+
),
|
|
293
328
|
] = None,
|
|
294
329
|
) -> None:
|
|
295
330
|
"""Open an SSH session to the running instance of a job."""
|
|
@@ -316,7 +351,9 @@ async def ssh(
|
|
|
316
351
|
if instance:
|
|
317
352
|
match = next((i for i in running if instance in (i.rid, i.id)), None)
|
|
318
353
|
if match is None:
|
|
319
|
-
typer.echo(
|
|
354
|
+
typer.echo(
|
|
355
|
+
f"Instance {instance} not found among running instances of {job.rid}."
|
|
356
|
+
)
|
|
320
357
|
sys.exit(1)
|
|
321
358
|
target = match
|
|
322
359
|
elif len(running) > 1:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|