qbraid-cli 0.13.3__tar.gz → 0.15.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.
- {qbraid_cli-0.13.3/qbraid_cli.egg-info → qbraid_cli-0.15.0}/PKG-INFO +4 -4
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/pyproject.toml +4 -4
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/agents/app.py +70 -3
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/compute/app.py +60 -167
- qbraid_cli-0.15.0/qbraid_cli/compute/instances.py +1342 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/compute/profiles.py +4 -0
- qbraid_cli-0.15.0/qbraid_cli/compute/server.py +249 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/compute/ssh.py +102 -75
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/envs/app.py +47 -11
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/lab/__init__.py +2 -2
- qbraid_cli-0.15.0/qbraid_cli/lab/app.py +49 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/main.py +2 -2
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0/qbraid_cli.egg-info}/PKG-INFO +4 -4
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli.egg-info/SOURCES.txt +1 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli.egg-info/requires.txt +3 -3
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/tests/test_cli_e2e.py +5 -2
- qbraid_cli-0.13.3/qbraid_cli/compute/server.py +0 -589
- qbraid_cli-0.13.3/qbraid_cli/lab/app.py +0 -50
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/LICENSE +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/README.md +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/_build_info.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/_version.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/account/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/account/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/admin/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/admin/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/admin/headers.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/admin/validation.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/agents/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/ai/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/ai/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/ai/token.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/compute/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/configure/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/configure/actions.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/configure/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/devices/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/devices/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/devices/validation.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/envs/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/envs/activate.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/envs/create.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/envs/data_handling.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/envs/groups.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/envs/publish.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/envs/registry.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/envs/share.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/exceptions.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/handlers.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/jobs/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/jobs/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/jobs/groups.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/kernels/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/kernels/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/pip/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/pip/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/pip/hooks.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/projects/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/projects/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/py.typed +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/skills/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/skills/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/troubleshoot/__init__.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli/troubleshoot/app.py +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli.egg-info/dependency_links.txt +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli.egg-info/entry_points.txt +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/qbraid_cli.egg-info/top_level.txt +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/setup.cfg +0 -0
- {qbraid_cli-0.13.3 → qbraid_cli-0.15.0}/tests/test_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: qbraid-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.15.0
|
|
4
4
|
Summary: Command Line Interface for interacting with all parts of the qBraid platform.
|
|
5
5
|
Author-email: qBraid Development Team <contact@qbraid.com>
|
|
6
6
|
License-Expression: LicenseRef-Proprietary
|
|
@@ -30,11 +30,11 @@ Requires-Dist: typer>=0.12.1
|
|
|
30
30
|
Requires-Dist: rich>=10.11.0
|
|
31
31
|
Requires-Dist: click<=8.3.3
|
|
32
32
|
Requires-Dist: questionary>=2.0.0
|
|
33
|
-
Requires-Dist: qbraid-core>=0.
|
|
33
|
+
Requires-Dist: qbraid-core>=0.5.0
|
|
34
34
|
Provides-Extra: compute
|
|
35
|
-
Requires-Dist: qbraid-core[compute]>=0.
|
|
35
|
+
Requires-Dist: qbraid-core[compute]>=0.5.0; extra == "compute"
|
|
36
36
|
Provides-Extra: envs
|
|
37
|
-
Requires-Dist: qbraid-core[environments]>=0.
|
|
37
|
+
Requires-Dist: qbraid-core[environments]>=0.5.0; extra == "envs"
|
|
38
38
|
Provides-Extra: dev
|
|
39
39
|
Requires-Dist: isort; extra == "dev"
|
|
40
40
|
Requires-Dist: black; extra == "dev"
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "qbraid-cli"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.15.0"
|
|
8
8
|
description = "Command Line Interface for interacting with all parts of the qBraid platform."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [{ name = "qBraid Development Team", email = "contact@qbraid.com" }]
|
|
@@ -32,7 +32,7 @@ dependencies = [
|
|
|
32
32
|
"rich>=10.11.0",
|
|
33
33
|
"click<=8.3.3",
|
|
34
34
|
"questionary>=2.0.0",
|
|
35
|
-
"qbraid-core>=0.
|
|
35
|
+
"qbraid-core>=0.5.0",
|
|
36
36
|
]
|
|
37
37
|
requires-python = ">= 3.10"
|
|
38
38
|
|
|
@@ -43,8 +43,8 @@ Documentation = "https://docs.qbraid.com/v2/cli/api-reference/qbraid"
|
|
|
43
43
|
Discord = "https://discord.gg/KugF6Cnncm"
|
|
44
44
|
|
|
45
45
|
[project.optional-dependencies]
|
|
46
|
-
compute = ["qbraid-core[compute]>=0.
|
|
47
|
-
envs = ["qbraid-core[environments]>=0.
|
|
46
|
+
compute = ["qbraid-core[compute]>=0.5.0"]
|
|
47
|
+
envs = ["qbraid-core[environments]>=0.5.0"]
|
|
48
48
|
dev = ["isort", "black", "pytest", "pytest-cov", "pytest-asyncio"]
|
|
49
49
|
|
|
50
50
|
[project.scripts]
|
|
@@ -3,13 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
"""Agents CLI - Monitor and manage AI coding agent sessions."""
|
|
5
5
|
|
|
6
|
+
import inspect
|
|
6
7
|
import os
|
|
7
8
|
import re
|
|
8
9
|
import signal
|
|
9
10
|
import time
|
|
10
11
|
from datetime import datetime
|
|
12
|
+
from enum import Enum
|
|
11
13
|
from pathlib import Path
|
|
12
|
-
from typing import List, Optional
|
|
14
|
+
from typing import Any, Callable, Dict, List, Optional
|
|
13
15
|
|
|
14
16
|
import click
|
|
15
17
|
import typer
|
|
@@ -1096,10 +1098,59 @@ def _interactive_attach(console_: Console) -> str:
|
|
|
1096
1098
|
return selected
|
|
1097
1099
|
|
|
1098
1100
|
|
|
1101
|
+
class ApprovalMode(str, Enum):
|
|
1102
|
+
"""How much the agent asks before acting.
|
|
1103
|
+
|
|
1104
|
+
A launched agent is detached, so a confirmation prompt has nobody to
|
|
1105
|
+
answer it — ``auto`` is the mode for anything you intend to leave running.
|
|
1106
|
+
"""
|
|
1107
|
+
|
|
1108
|
+
ASK = "ask"
|
|
1109
|
+
AUTO = "auto"
|
|
1110
|
+
|
|
1111
|
+
|
|
1112
|
+
def _approval_kwargs(method: Callable[..., Any], approval: Optional[str]) -> Dict[str, Any]:
|
|
1113
|
+
"""Forward ``approval`` only to a qbraid-core new enough to accept it.
|
|
1114
|
+
|
|
1115
|
+
The CLI's floor is qbraid-core>=0.5.0, which predates the parameter. Passing
|
|
1116
|
+
it unconditionally would raise TypeError on EVERY launch there, not only
|
|
1117
|
+
when --approval was used — so detect support and, when the user actually
|
|
1118
|
+
asked for a mode we cannot honour, say so plainly instead of forwarding it.
|
|
1119
|
+
|
|
1120
|
+
A Mock reports ``(*args, **kwargs)``; VAR_KEYWORD therefore counts as
|
|
1121
|
+
support, which is both correct in general and keeps test doubles working.
|
|
1122
|
+
"""
|
|
1123
|
+
try:
|
|
1124
|
+
params = inspect.signature(method).parameters
|
|
1125
|
+
supported = "approval" in params or any(
|
|
1126
|
+
param.kind is inspect.Parameter.VAR_KEYWORD for param in params.values()
|
|
1127
|
+
)
|
|
1128
|
+
except (TypeError, ValueError): # pragma: no cover - non-introspectable callable
|
|
1129
|
+
supported = True
|
|
1130
|
+
|
|
1131
|
+
if supported:
|
|
1132
|
+
return {"approval": approval}
|
|
1133
|
+
|
|
1134
|
+
if approval is not None:
|
|
1135
|
+
try:
|
|
1136
|
+
from qbraid_core import __version__ as core_version
|
|
1137
|
+
except ImportError: # pragma: no cover
|
|
1138
|
+
core_version = "unknown"
|
|
1139
|
+
handle_error(
|
|
1140
|
+
error_type="UnsupportedOptionError",
|
|
1141
|
+
message=(
|
|
1142
|
+
f"--approval requires a newer qbraid-core (installed: {core_version}). "
|
|
1143
|
+
"Upgrade with: pip install -U qbraid-core"
|
|
1144
|
+
),
|
|
1145
|
+
include_traceback=False,
|
|
1146
|
+
)
|
|
1147
|
+
return {}
|
|
1148
|
+
|
|
1149
|
+
|
|
1099
1150
|
@agents_app.command("launch")
|
|
1100
1151
|
def agents_launch(
|
|
1101
1152
|
tool: Optional[str] = typer.Option(
|
|
1102
|
-
None, "--tool", "-t", help="Agent tool (claude, claude-auto
|
|
1153
|
+
None, "--tool", "-t", help="Agent tool (claude, codeq, codex; claude-auto = claude --approval auto)"
|
|
1103
1154
|
),
|
|
1104
1155
|
cwd: Optional[str] = typer.Option(None, "--cwd", help="Working directory"),
|
|
1105
1156
|
name: Optional[str] = typer.Option(None, "--name", "-n", help="Agent name"),
|
|
@@ -1116,10 +1167,21 @@ def agents_launch(
|
|
|
1116
1167
|
compute: Optional[str] = typer.Option(
|
|
1117
1168
|
None, "--compute", "-c", help="SSH alias for remote compute server"
|
|
1118
1169
|
),
|
|
1170
|
+
approval: Optional[ApprovalMode] = typer.Option(
|
|
1171
|
+
None,
|
|
1172
|
+
"--approval",
|
|
1173
|
+
help="ask: the agent confirms before acting. auto: it acts without asking.",
|
|
1174
|
+
),
|
|
1119
1175
|
):
|
|
1120
1176
|
"""Launch an AI coding agent.
|
|
1121
1177
|
|
|
1122
1178
|
Starts the agent in a managed tmux session.
|
|
1179
|
+
|
|
1180
|
+
The agent runs detached, so nothing is watching its confirmation prompts.
|
|
1181
|
+
Pass --approval auto for an agent you intend to leave running: it starts
|
|
1182
|
+
the tool in its own non-interactive mode instead of parking on a prompt
|
|
1183
|
+
until you come back. Approval mode is remembered, so `qbraid agents
|
|
1184
|
+
resume` restores it.
|
|
1123
1185
|
"""
|
|
1124
1186
|
try:
|
|
1125
1187
|
from qbraid_core.services.agents import AgentLauncher, AgentLauncherError
|
|
@@ -1148,6 +1210,7 @@ def agents_launch(
|
|
|
1148
1210
|
instructions=instructions,
|
|
1149
1211
|
agent_type=agent_type,
|
|
1150
1212
|
tags=tag,
|
|
1213
|
+
**_approval_kwargs(launcher.remote_launch, approval.value if approval else None),
|
|
1151
1214
|
)
|
|
1152
1215
|
else:
|
|
1153
1216
|
|
|
@@ -1164,6 +1227,7 @@ def agents_launch(
|
|
|
1164
1227
|
parent_session_id=parent,
|
|
1165
1228
|
team_id=team,
|
|
1166
1229
|
tags=tag,
|
|
1230
|
+
**_approval_kwargs(launcher.launch, approval.value if approval else None),
|
|
1167
1231
|
progress_callback=_clone_progress if repo else None,
|
|
1168
1232
|
)
|
|
1169
1233
|
|
|
@@ -1334,12 +1398,15 @@ def agents_resume(
|
|
|
1334
1398
|
if original:
|
|
1335
1399
|
tool_value = original.tool.value if original.tool else "claude"
|
|
1336
1400
|
fork_name = name or f"{tmux_win}-fork"
|
|
1337
|
-
# Launch fresh with same tool and cwd
|
|
1401
|
+
# Launch fresh with same tool and cwd.
|
|
1338
1402
|
session = launcher.launch(
|
|
1339
1403
|
tool=tool_value,
|
|
1340
1404
|
cwd=original.cwd,
|
|
1341
1405
|
name=fork_name,
|
|
1342
1406
|
instructions=None,
|
|
1407
|
+
# A fork of a detached agent must not quietly
|
|
1408
|
+
# become one that waits for a human.
|
|
1409
|
+
**_approval_kwargs(launcher.launch, getattr(original, "approval", None)),
|
|
1343
1410
|
)
|
|
1344
1411
|
else:
|
|
1345
1412
|
console.print("[red]Could not find original session to fork.[/red]")
|
|
@@ -7,13 +7,21 @@ from typing import Optional
|
|
|
7
7
|
|
|
8
8
|
import typer
|
|
9
9
|
from rich.console import Console
|
|
10
|
-
from rich.panel import Panel
|
|
11
10
|
from rich.table import Table
|
|
12
11
|
|
|
13
12
|
from qbraid_cli.handlers import handle_error, run_progress_task
|
|
14
13
|
|
|
14
|
+
from .instances import (
|
|
15
|
+
_ON_DEMAND_WAIT_TIMEOUT,
|
|
16
|
+
_SUBSCRIPTION_WAIT_TIMEOUT,
|
|
17
|
+
_fail,
|
|
18
|
+
instances_app,
|
|
19
|
+
run_launch,
|
|
20
|
+
run_list,
|
|
21
|
+
run_stop,
|
|
22
|
+
)
|
|
15
23
|
from .profiles import profiles_app
|
|
16
|
-
from .server import
|
|
24
|
+
from .server import server_app
|
|
17
25
|
from .ssh import ssh_app
|
|
18
26
|
|
|
19
27
|
compute_app = typer.Typer(
|
|
@@ -29,16 +37,17 @@ compute_app = typer.Typer(
|
|
|
29
37
|
" \u2022 Connect VS Code or Cursor to a remote server\n"
|
|
30
38
|
" \u2022 Launch AI agents on more powerful hardware\n\n"
|
|
31
39
|
"Quick start:\n"
|
|
32
|
-
" qbraid compute up <profile>
|
|
33
|
-
" qbraid compute status
|
|
34
|
-
" qbraid compute
|
|
35
|
-
" qbraid compute down
|
|
40
|
+
" qbraid compute up <profile> # Launch an instance + configure SSH\n"
|
|
41
|
+
" qbraid compute status # List your instances\n"
|
|
42
|
+
" qbraid compute instances ... # launch/start/stop/terminate/ssh/...\n"
|
|
43
|
+
" qbraid compute down # Stop an instance"
|
|
36
44
|
),
|
|
37
45
|
no_args_is_help=True,
|
|
38
46
|
)
|
|
39
47
|
console = Console()
|
|
40
48
|
|
|
41
49
|
# Add subcommand groups
|
|
50
|
+
compute_app.add_typer(instances_app, name="instances")
|
|
42
51
|
compute_app.add_typer(profiles_app, name="profiles")
|
|
43
52
|
compute_app.add_typer(server_app, name="server")
|
|
44
53
|
compute_app.add_typer(ssh_app, name="ssh")
|
|
@@ -58,204 +67,88 @@ def _get_client():
|
|
|
58
67
|
|
|
59
68
|
@compute_app.command("up")
|
|
60
69
|
def compute_up(
|
|
61
|
-
profile_slug: str = typer.Argument(..., help="Profile slug to
|
|
62
|
-
cluster_id: Optional[str] = typer.Option(None, "--cluster", "-c", help="
|
|
63
|
-
timeout: int = typer.Option(
|
|
70
|
+
profile_slug: str = typer.Argument(..., help="Profile slug to launch"),
|
|
71
|
+
cluster_id: Optional[str] = typer.Option(None, "--cluster", "-c", help="Subscription cluster ID"),
|
|
72
|
+
timeout: Optional[int] = typer.Option(
|
|
73
|
+
None,
|
|
74
|
+
"--timeout",
|
|
75
|
+
"-t",
|
|
76
|
+
help=f"Seconds to wait (default {_ON_DEMAND_WAIT_TIMEOUT} on-demand, "
|
|
77
|
+
f"{_SUBSCRIPTION_WAIT_TIMEOUT} subscription)",
|
|
78
|
+
),
|
|
64
79
|
no_ssh: bool = typer.Option(False, "--no-ssh", help="Skip SSH configuration"),
|
|
65
80
|
):
|
|
66
|
-
"""
|
|
81
|
+
"""Launch an instance and configure SSH.
|
|
67
82
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
83
|
+
Alias for `qbraid compute instances launch <profile> --ssh`. On-demand
|
|
84
|
+
profiles always launch a new instance; the subscription server attaches
|
|
85
|
+
if it's already running.
|
|
71
86
|
|
|
72
87
|
Example:
|
|
73
|
-
qbraid compute up
|
|
88
|
+
qbraid compute up gpu-l4
|
|
74
89
|
"""
|
|
75
90
|
try:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if not no_ssh:
|
|
84
|
-
console.print("Configuring SSH...")
|
|
85
|
-
_setup_ssh(client, cluster_id)
|
|
86
|
-
return
|
|
87
|
-
|
|
88
|
-
# Start server
|
|
89
|
-
console.print(f"Starting server with profile '[cyan]{profile_slug}[/cyan]'...")
|
|
90
|
-
|
|
91
|
-
def start():
|
|
92
|
-
return client.start_server(profile_slug, cluster_id)
|
|
93
|
-
|
|
94
|
-
run_progress_task(
|
|
95
|
-
start,
|
|
96
|
-
description="Starting...",
|
|
97
|
-
include_error_traceback=False,
|
|
91
|
+
run_launch(
|
|
92
|
+
profile_slug,
|
|
93
|
+
wait=True,
|
|
94
|
+
ssh=not no_ssh,
|
|
95
|
+
timeout=timeout,
|
|
96
|
+
cluster_id=cluster_id,
|
|
97
|
+
client=_get_client(),
|
|
98
98
|
)
|
|
99
|
-
|
|
100
|
-
# Wait for server
|
|
101
|
-
def wait():
|
|
102
|
-
return client.wait_for_server(timeout=timeout, cluster_id=cluster_id)
|
|
103
|
-
|
|
104
|
-
try:
|
|
105
|
-
status = run_progress_task(
|
|
106
|
-
wait,
|
|
107
|
-
description="Waiting for server to be ready...",
|
|
108
|
-
include_error_traceback=False,
|
|
109
|
-
)
|
|
110
|
-
except TimeoutError:
|
|
111
|
-
console.print(f"[yellow]Server did not start within {timeout}s[/yellow]")
|
|
112
|
-
console.print("Check status: qbraid compute server status")
|
|
113
|
-
raise typer.Exit(code=1)
|
|
114
|
-
|
|
115
|
-
# Configure SSH
|
|
116
|
-
if not no_ssh:
|
|
117
|
-
console.print()
|
|
118
|
-
_setup_ssh(client, cluster_id)
|
|
119
|
-
|
|
120
99
|
except (typer.Exit, SystemExit):
|
|
121
100
|
raise
|
|
122
|
-
except Exception as
|
|
123
|
-
|
|
124
|
-
raise typer.Exit(code=1)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def _setup_ssh(client, cluster_id: Optional[str]):
|
|
128
|
-
"""Configure SSH for the running server."""
|
|
129
|
-
from qbraid_core.services.compute import setup_qbraid_ssh
|
|
130
|
-
|
|
131
|
-
token_resp = client.get_session_token(cluster_id)
|
|
132
|
-
status = client.get_server_status(cluster_id)
|
|
133
|
-
username = status.user_info.name if status.user_info else token_resp.token.user
|
|
134
|
-
|
|
135
|
-
ssh_config = setup_qbraid_ssh(
|
|
136
|
-
username=username,
|
|
137
|
-
token=token_resp.token.token,
|
|
138
|
-
cluster_id=token_resp.cluster_id,
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
# Show connection info
|
|
142
|
-
panel_lines = [
|
|
143
|
-
"[bold cyan]SSH[/bold cyan]",
|
|
144
|
-
f" {ssh_config['ssh_command']}",
|
|
145
|
-
"",
|
|
146
|
-
"[bold blue]VSCode[/bold blue]",
|
|
147
|
-
f" {ssh_config['vscode_command']}",
|
|
148
|
-
"",
|
|
149
|
-
"[bold magenta]Cursor[/bold magenta]",
|
|
150
|
-
f" {ssh_config['cursor_command']}",
|
|
151
|
-
]
|
|
152
|
-
|
|
153
|
-
panel = Panel(
|
|
154
|
-
"\n".join(panel_lines),
|
|
155
|
-
title="Connect with",
|
|
156
|
-
border_style="green",
|
|
157
|
-
)
|
|
158
|
-
console.print(panel)
|
|
101
|
+
except Exception as err: # pylint: disable=broad-exception-caught
|
|
102
|
+
_fail(err)
|
|
159
103
|
|
|
160
104
|
|
|
161
105
|
@compute_app.command("down")
|
|
162
106
|
def compute_down(
|
|
163
|
-
|
|
107
|
+
target: Optional[str] = typer.Argument(
|
|
108
|
+
None, help="Instance: id, hash, label, profile slug, or 'subscription'"
|
|
109
|
+
),
|
|
110
|
+
cluster_id: Optional[str] = typer.Option(None, "--cluster", "-c", help="Subscription cluster ID"),
|
|
111
|
+
instance: Optional[str] = typer.Option(None, "--instance", "-i", help="Same as the positional target"),
|
|
164
112
|
force: bool = typer.Option(False, "--force", "-f", help="Skip confirmation"),
|
|
165
|
-
cleanup_ssh: bool = typer.Option(False, "--cleanup-ssh", help="Remove SSH config"),
|
|
113
|
+
cleanup_ssh: bool = typer.Option(False, "--cleanup-ssh", help="Remove the subscription SSH config"),
|
|
166
114
|
):
|
|
167
|
-
"""Stop
|
|
115
|
+
"""Stop an instance.
|
|
116
|
+
|
|
117
|
+
Alias for `qbraid compute instances stop`. With no target, stops your
|
|
118
|
+
running on-demand instance (asking which if several) or else the
|
|
119
|
+
subscription server.
|
|
168
120
|
|
|
169
121
|
Example:
|
|
170
122
|
qbraid compute down
|
|
171
|
-
qbraid compute down
|
|
123
|
+
qbraid compute down trainer
|
|
172
124
|
"""
|
|
173
125
|
try:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
# Route to a BMA instance if an on-demand instance is running.
|
|
177
|
-
target_instance = _select_bma_instance(client, None, "stop")
|
|
178
|
-
if target_instance:
|
|
179
|
-
if not force:
|
|
180
|
-
confirm = typer.confirm(f"Stop instance {target_instance}?")
|
|
181
|
-
if not confirm:
|
|
182
|
-
console.print("Cancelled.")
|
|
183
|
-
raise typer.Exit(code=0)
|
|
184
|
-
|
|
185
|
-
def stop_instance():
|
|
186
|
-
return client.stop_bma_instance(target_instance)
|
|
187
|
-
|
|
188
|
-
inst = run_progress_task(
|
|
189
|
-
stop_instance,
|
|
190
|
-
description=f"Stopping {target_instance}...",
|
|
191
|
-
include_error_traceback=False,
|
|
192
|
-
)
|
|
193
|
-
console.print(f"[green]Stopping instance {inst.instance_id}[/green]")
|
|
194
|
-
console.print(f" Status: {inst.status.value}")
|
|
195
|
-
console.print("[dim]Poll with: qbraid compute status[/dim]")
|
|
196
|
-
return
|
|
197
|
-
|
|
198
|
-
# Check if a legacy server is running
|
|
199
|
-
status = client.get_server_status(cluster_id)
|
|
200
|
-
if not status.server_running and not status.server_starting:
|
|
201
|
-
console.print("[dim]No server is currently running.[/dim]")
|
|
202
|
-
return
|
|
203
|
-
|
|
204
|
-
if not force:
|
|
205
|
-
profile = status.current_profile or "unknown"
|
|
206
|
-
confirm = typer.confirm(f"Stop server (profile: {profile})?")
|
|
207
|
-
if not confirm:
|
|
208
|
-
console.print("Cancelled.")
|
|
209
|
-
raise typer.Exit(code=0)
|
|
210
|
-
|
|
211
|
-
# Stop server
|
|
212
|
-
def stop():
|
|
213
|
-
return client.stop_server(cluster_id)
|
|
214
|
-
|
|
215
|
-
run_progress_task(
|
|
216
|
-
stop,
|
|
217
|
-
description="Stopping server...",
|
|
218
|
-
include_error_traceback=False,
|
|
219
|
-
)
|
|
220
|
-
|
|
221
|
-
# Cleanup SSH if requested
|
|
126
|
+
run_stop(target or instance, yes=force, cluster_id=cluster_id, client=_get_client())
|
|
222
127
|
if cleanup_ssh:
|
|
223
128
|
from qbraid_core.services.compute.ssh import remove_pod_ssh_config
|
|
224
129
|
|
|
225
|
-
|
|
226
|
-
removed = remove_pod_ssh_config("lab")
|
|
227
|
-
if removed:
|
|
130
|
+
if remove_pod_ssh_config("lab"):
|
|
228
131
|
console.print("[dim]SSH config removed.[/dim]")
|
|
229
|
-
|
|
230
132
|
except (typer.Exit, SystemExit):
|
|
231
133
|
raise
|
|
232
|
-
except Exception as
|
|
233
|
-
|
|
234
|
-
raise typer.Exit(code=1)
|
|
134
|
+
except Exception as err: # pylint: disable=broad-exception-caught
|
|
135
|
+
_fail(err)
|
|
235
136
|
|
|
236
137
|
|
|
237
138
|
@compute_app.command("status")
|
|
238
139
|
def compute_status(
|
|
239
|
-
cluster_id: Optional[str] = typer.Option(None, "--cluster", "-c", help="
|
|
140
|
+
cluster_id: Optional[str] = typer.Option(None, "--cluster", "-c", help="Subscription cluster ID"),
|
|
240
141
|
):
|
|
241
|
-
"""
|
|
142
|
+
"""List your instances.
|
|
242
143
|
|
|
243
|
-
|
|
144
|
+
Alias for `qbraid compute instances list`.
|
|
244
145
|
"""
|
|
245
146
|
try:
|
|
246
|
-
client
|
|
247
|
-
status = client.get_server_status(cluster_id)
|
|
248
|
-
instances = _print_unified_status_table(client, status)
|
|
249
|
-
|
|
250
|
-
if not status.server_running and not status.server_starting and not instances:
|
|
251
|
-
console.print()
|
|
252
|
-
console.print("[dim]Start with: qbraid compute up <profile>[/dim]")
|
|
253
|
-
|
|
147
|
+
run_list(cluster_id, client=_get_client())
|
|
254
148
|
except (typer.Exit, SystemExit):
|
|
255
149
|
raise
|
|
256
|
-
except Exception as
|
|
257
|
-
|
|
258
|
-
raise typer.Exit(code=1)
|
|
150
|
+
except Exception as err: # pylint: disable=broad-exception-caught
|
|
151
|
+
_fail(err)
|
|
259
152
|
|
|
260
153
|
|
|
261
154
|
@compute_app.command("list")
|