trainwave-cli 0.1.8__tar.gz → 0.1.9__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.1.8 → trainwave_cli-0.1.9}/PKG-INFO +1 -1
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/pyproject.toml +1 -1
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/cli/auth.py +18 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/cli/jobs.py +41 -26
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/cli/setup.py +13 -6
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/README.md +0 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/__init__.py +0 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/api.py +0 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/cli/offers.py +0 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/config/config.py +0 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/format_utils.py +0 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/io.py +0 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/main.py +0 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/utils.py +0 -0
- {trainwave_cli-0.1.8 → trainwave_cli-0.1.9}/trainwave_cli/xceptions.py +0 -0
|
@@ -22,6 +22,9 @@ LOGIN_POLLING_SLEEP_TIME: Annotated[int, "seconds"] = 5
|
|
|
22
22
|
@app.command()
|
|
23
23
|
@async_command
|
|
24
24
|
async def login() -> None:
|
|
25
|
+
"""
|
|
26
|
+
Login to Trainwave. This will open a browser window for you to authenticate.
|
|
27
|
+
"""
|
|
25
28
|
api_client = Api(None, config.endpoint)
|
|
26
29
|
session_url, session_token = await api_client.create_cli_auth_session()
|
|
27
30
|
|
|
@@ -68,6 +71,9 @@ async def login() -> None:
|
|
|
68
71
|
@async_command
|
|
69
72
|
@ensure_api_key
|
|
70
73
|
async def logout() -> None:
|
|
74
|
+
"""
|
|
75
|
+
Logout from Trainwave. This will remove the API key from the configuration.
|
|
76
|
+
"""
|
|
71
77
|
config_manager.delete()
|
|
72
78
|
logger.info("Logged out")
|
|
73
79
|
|
|
@@ -76,6 +82,9 @@ async def logout() -> None:
|
|
|
76
82
|
@async_command
|
|
77
83
|
@ensure_api_key
|
|
78
84
|
async def whoami() -> None:
|
|
85
|
+
"""
|
|
86
|
+
Get the current user's information.
|
|
87
|
+
"""
|
|
79
88
|
api = Api(config.api_key, config.endpoint)
|
|
80
89
|
res = await api.get_myself()
|
|
81
90
|
typer.echo(res.email)
|
|
@@ -84,6 +93,9 @@ async def whoami() -> None:
|
|
|
84
93
|
@app.command()
|
|
85
94
|
@async_command
|
|
86
95
|
async def set_token(api_key: str):
|
|
96
|
+
"""
|
|
97
|
+
Manually set the API key for Trainwave.
|
|
98
|
+
"""
|
|
87
99
|
api = Api(api_key, config.endpoint)
|
|
88
100
|
logger.info("Checking API key...")
|
|
89
101
|
if await api.check_api_key():
|
|
@@ -99,11 +111,17 @@ async def set_token(api_key: str):
|
|
|
99
111
|
@async_command
|
|
100
112
|
@ensure_api_key
|
|
101
113
|
async def token() -> None:
|
|
114
|
+
"""
|
|
115
|
+
Print the current API key.
|
|
116
|
+
"""
|
|
102
117
|
typer.echo(config.api_key)
|
|
103
118
|
|
|
104
119
|
|
|
105
120
|
@app.command()
|
|
106
121
|
@async_command
|
|
107
122
|
async def set_endpoint(endpoint: str) -> None:
|
|
123
|
+
"""
|
|
124
|
+
Set the endpoint for Trainwave.
|
|
125
|
+
"""
|
|
108
126
|
config.endpoint = endpoint
|
|
109
127
|
config_manager.save()
|
|
@@ -33,25 +33,28 @@ app = typer.Typer()
|
|
|
33
33
|
@ensure_api_key
|
|
34
34
|
async def launch( # noqa
|
|
35
35
|
# Basic job parameters
|
|
36
|
-
name: Annotated[str, typer.Option()],
|
|
37
|
-
project: Annotated[str, typer.Option()],
|
|
38
|
-
setup_command: Annotated[str, typer.Option()],
|
|
39
|
-
run_command: Annotated[str, typer.Option()],
|
|
36
|
+
name: Annotated[str, typer.Option(help="The name of the job")],
|
|
37
|
+
project: Annotated[str, typer.Option(help="The project ID or RID")],
|
|
38
|
+
setup_command: Annotated[str, typer.Option(help="The command to run before the job")],
|
|
39
|
+
run_command: Annotated[str, typer.Option(help="The command to run the job")],
|
|
40
40
|
# Optional params
|
|
41
|
-
organization: Annotated[Optional[str], typer.Option()] = None,
|
|
42
|
-
expires: Annotated[str, typer.Option()] = "",
|
|
41
|
+
organization: Annotated[Optional[str], typer.Option(help="ID or RID of organization")] = None,
|
|
42
|
+
expires: Annotated[str, typer.Option(help="Time til' the job will be automatically terminated. Example `1d`, `2h`` etc.")] = "",
|
|
43
43
|
env_vars={}, # dict[str, str] not supported by typer yet
|
|
44
|
-
exclude_gitignore: Annotated[bool, typer.Option()] = True,
|
|
45
|
-
exclude_regex: Annotated[Optional[str], typer.Option()] = None,
|
|
44
|
+
exclude_gitignore: Annotated[bool, typer.Option(help="If set the gitignore file will be used to ignore files when packaging the job")] = True,
|
|
45
|
+
exclude_regex: Annotated[Optional[str], typer.Option(help="Files matching this pattern will be ignored when packaging up the job")] = None,
|
|
46
46
|
# Harware parameters
|
|
47
|
-
image: Annotated[str, typer.Option()] = "",
|
|
48
|
-
hdd_size_mb: Annotated[int, typer.Option()] = 20,
|
|
49
|
-
memory_mb: Annotated[int, typer.Option()] = 0,
|
|
50
|
-
cpus: Annotated[int, typer.Option()] = 0,
|
|
51
|
-
gpus: Annotated[int, typer.Option()] = 0,
|
|
52
|
-
gpu_type: Annotated[str, typer.Option()] = "",
|
|
53
|
-
compliance_soc2: Annotated[Optional[bool], typer.Option()] = None,
|
|
47
|
+
image: Annotated[str, typer.Option(help="The docker image to use as base for the job")] = "",
|
|
48
|
+
hdd_size_mb: Annotated[int, typer.Option(help="Hard drive size in MB")] = 20,
|
|
49
|
+
memory_mb: Annotated[int, typer.Option(help="Memory in MB")] = 0,
|
|
50
|
+
cpus: Annotated[int, typer.Option(help="Number of CPUs")] = 0,
|
|
51
|
+
gpus: Annotated[int, typer.Option(help="Number of GPUs to allocate of the `gpu_type`")] = 0,
|
|
52
|
+
gpu_type: Annotated[str, typer.Option(help="Canonical name of the GPU to use")] = "",
|
|
53
|
+
compliance_soc2: Annotated[Optional[bool], typer.Option(help="Only use SOC2 compliant machines")] = None,
|
|
54
54
|
) -> None:
|
|
55
|
+
"""
|
|
56
|
+
Launch a job on Trainwave using the current configuration.
|
|
57
|
+
"""
|
|
55
58
|
api_client = Api(config.api_key, config.endpoint, project)
|
|
56
59
|
# Interpolate environe variables
|
|
57
60
|
env_vars = eval(env_vars)
|
|
@@ -103,8 +106,8 @@ async def launch( # noqa
|
|
|
103
106
|
"name": tab_keys,
|
|
104
107
|
"value": [render(k, conf[k]) for k in tab_keys],
|
|
105
108
|
}
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
typer.echo(tabulate(tab_values, headers="keys"))
|
|
110
|
+
typer.echo("\n")
|
|
108
111
|
|
|
109
112
|
tarball = None
|
|
110
113
|
try:
|
|
@@ -119,9 +122,9 @@ async def launch( # noqa
|
|
|
119
122
|
"name": tab_keys,
|
|
120
123
|
"value": [truncate_string(str(co[k]), 50) for k in tab_keys],
|
|
121
124
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
+
typer.echo("\nMatched machine\n" + tabulate(tab_values, headers="keys") + "\n")
|
|
126
|
+
typer.echo(f"Cost per hour for this job: ${job.cost_per_hour:.2f}")
|
|
127
|
+
typer.echo(f"Job created: {job.rid} ({job.id}) -> {job.url}")
|
|
125
128
|
except Exception as e:
|
|
126
129
|
traceback.print_exc()
|
|
127
130
|
logger.error(f"An error occurred: {e}")
|
|
@@ -135,9 +138,12 @@ async def launch( # noqa
|
|
|
135
138
|
@use_toml_config(default_value="trainwave.toml")
|
|
136
139
|
@ensure_api_key
|
|
137
140
|
async def list_jobs(
|
|
138
|
-
organization: Annotated[str, typer.Option()],
|
|
139
|
-
project: Annotated[str, typer.Option()] = "",
|
|
141
|
+
organization: Annotated[str, typer.Option(help="Organization ID or RID")],
|
|
142
|
+
project: Annotated[str, typer.Option(help="Project ID or RID")] = "",
|
|
140
143
|
) -> None:
|
|
144
|
+
"""
|
|
145
|
+
List all jobs in the current project.
|
|
146
|
+
"""
|
|
141
147
|
api_client = Api(
|
|
142
148
|
config.api_key, config.endpoint, project=project, organization=organization
|
|
143
149
|
)
|
|
@@ -165,11 +171,14 @@ async def list_jobs(
|
|
|
165
171
|
@use_toml_config(default_value="trainwave.toml")
|
|
166
172
|
@ensure_api_key
|
|
167
173
|
async def status(
|
|
168
|
-
project: Annotated[str, typer.Option()],
|
|
174
|
+
project: Annotated[str, typer.Option(help="Project ID or RID")],
|
|
169
175
|
job_id: str,
|
|
170
176
|
) -> None:
|
|
177
|
+
"""
|
|
178
|
+
Get the status of a job.
|
|
179
|
+
"""
|
|
171
180
|
api_client = Api(config.api_key, config.endpoint, project)
|
|
172
|
-
|
|
181
|
+
typer.echo(await api_client.job_status(job_id))
|
|
173
182
|
|
|
174
183
|
|
|
175
184
|
@app.command()
|
|
@@ -177,12 +186,15 @@ async def status(
|
|
|
177
186
|
@use_toml_config(default_value="trainwave.toml")
|
|
178
187
|
@ensure_api_key
|
|
179
188
|
async def cancel(
|
|
180
|
-
project: Annotated[str, typer.Option()],
|
|
189
|
+
project: Annotated[str, typer.Option(help="Project ID or RID")],
|
|
181
190
|
job_id: str,
|
|
182
191
|
):
|
|
192
|
+
"""
|
|
193
|
+
Cancel a job.
|
|
194
|
+
"""
|
|
183
195
|
api_client = Api(config.api_key, config.endpoint, project)
|
|
184
196
|
await api_client.cancel_job(job_id)
|
|
185
|
-
|
|
197
|
+
typer.echo(f"Cancelled job: {job_id}")
|
|
186
198
|
|
|
187
199
|
|
|
188
200
|
@app.command()
|
|
@@ -191,6 +203,9 @@ async def cancel(
|
|
|
191
203
|
async def logs(
|
|
192
204
|
job_id: str,
|
|
193
205
|
) -> None:
|
|
206
|
+
"""
|
|
207
|
+
Get the logs of a job.
|
|
208
|
+
"""
|
|
194
209
|
logger.remove()
|
|
195
210
|
logger.add(
|
|
196
211
|
sys.stdout,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import copy
|
|
2
2
|
import time
|
|
3
3
|
import webbrowser
|
|
4
|
-
from typing import Annotated, Any, Optional
|
|
4
|
+
from typing import Annotated, Any, Optional, cast
|
|
5
5
|
|
|
6
6
|
import toml
|
|
7
7
|
import typer
|
|
@@ -60,13 +60,20 @@ async def _run_setup_guide(existing_config: dict[str, Any]) -> dict[str, Any]:
|
|
|
60
60
|
@async_command
|
|
61
61
|
@ensure_api_key
|
|
62
62
|
async def default(
|
|
63
|
-
config: Annotated[Optional[str], typer.
|
|
64
|
-
accept: Annotated[bool, "Accept overwrite of config"] = False,
|
|
63
|
+
config: Annotated[Optional[str], typer.Option(help="Provide a config path")] = "trainwave.toml",
|
|
64
|
+
accept: Annotated[bool, typer.Option(help="Accept overwrite of config without prompt")] = False,
|
|
65
65
|
) -> None:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
config_path = config
|
|
66
|
+
"""
|
|
67
|
+
Runs a configuration guide in the browser to create or update a config file.
|
|
69
68
|
|
|
69
|
+
If a config file already exists, it will be merged with the new config. Otherwise, a
|
|
70
|
+
new one will be created. The config file will be saved to the provided path.
|
|
71
|
+
|
|
72
|
+
If no path is provided, the default path is `trainwave.toml`.
|
|
73
|
+
|
|
74
|
+
You can run this command over-and-over to re-configure the config before launching a job.
|
|
75
|
+
"""
|
|
76
|
+
config_path = cast(str, config)
|
|
70
77
|
try:
|
|
71
78
|
existing_config = toml_loader(config_path)
|
|
72
79
|
except FileNotFoundError:
|
|
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
|