-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
45 lines (37 loc) · 1.46 KB
/
Copy pathrun.py
File metadata and controls
45 lines (37 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""Interactive coordinator container (`run` and `shell` aliases)."""
from typing import Annotated
import typer
from container_cli.utils import check_token, run_make
app = typer.Typer(help="Run coordinator container")
@app.command()
def run(
cpus: Annotated[int | None, typer.Option("--cpus", help="CPU count")] = None,
memory: Annotated[str | None, typer.Option("--memory", help="Memory limit (e.g. 12G)")] = None,
name: Annotated[str | None, typer.Option("--name", help="Container name")] = None,
) -> None:
"""Run an interactive coordinator shell (hands off TTY)."""
check_token()
make_vars: dict[str, str] = {}
if cpus is not None:
make_vars["CPUS"] = str(cpus)
if memory:
make_vars["MEMORY"] = memory
if name:
make_vars["NAME"] = name
run_make("run", make_vars, tty=True)
@app.command()
def shell(
cpus: Annotated[int | None, typer.Option("--cpus", help="CPU count")] = None,
memory: Annotated[str | None, typer.Option("--memory", help="Memory limit (e.g. 12G)")] = None,
name: Annotated[str | None, typer.Option("--name", help="Container name")] = None,
) -> None:
"""Alias for run — open an interactive shell in the coordinator container."""
check_token()
make_vars: dict[str, str] = {}
if cpus is not None:
make_vars["CPUS"] = str(cpus)
if memory:
make_vars["MEMORY"] = memory
if name:
make_vars["NAME"] = name
run_make("shell", make_vars, tty=True)