Skip to content

Commit e950957

Browse files
authored
[be]improve remote execution (#7907)
add remote execution option such as debug session refactor the command internace in to seperate files
1 parent 9c0a519 commit e950957

22 files changed

Lines changed: 1299 additions & 1181 deletions

File tree

tools/remote_execution/blast/src/re_cli/cli_helper.py

Lines changed: 0 additions & 296 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Shared utilities for commands."""
2+
3+
from typing import cast
4+
5+
import click
6+
7+
from ..core.core_types import console
8+
from ..core.k8s_client import K8sClient, K8sConfig
9+
10+
11+
def get_client(ctx: click.Context) -> K8sClient:
12+
"""Lazy-init K8sClient from click context. Call from any command."""
13+
if ctx.obj.get("_client") is None:
14+
console.print("[Auth] getting K8sConfig")
15+
config = K8sConfig(
16+
namespace=ctx.obj["_k8s_namespace"],
17+
timeout=ctx.obj["_k8s_timeout"],
18+
)
19+
ctx.obj["_client"] = K8sClient(config)
20+
return cast(K8sClient, ctx.obj["_client"])
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Cancel command."""
2+
3+
import json
4+
import sys
5+
6+
import click
7+
8+
from ..core.core_types import console
9+
from . import get_client
10+
11+
12+
@click.command()
13+
@click.argument("run_id", type=str)
14+
@click.pass_context
15+
def cancel(ctx, run_id):
16+
"""Cancel a run and all its tasks."""
17+
as_json = ctx.obj.get("as_json", False)
18+
19+
client = get_client(ctx)
20+
21+
try:
22+
result = client.cancel_run(run_id)
23+
if as_json:
24+
print(json.dumps({"run_id": run_id, "status": "cancelled", **result}))
25+
26+
console.print(f"[yellow]○ Run {run_id} cancelled[/yellow]")
27+
if result.get("message"):
28+
console.print(f"[dim] {result['message']}[/dim]")
29+
except Exception as e:
30+
if as_json:
31+
print(json.dumps({"error": str(e)}))
32+
console.print(f"[red]Error: {e}[/red]")
33+
sys.exit(1)

0 commit comments

Comments
 (0)