lyceum-cli 1.2.1__tar.gz → 1.2.3__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.
Files changed (49) hide show
  1. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/PKG-INFO +1 -1
  2. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/_version.py +1 -1
  3. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/inference/claude_code.py +1 -1
  4. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/inference/infer.py +53 -10
  5. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/vms/management.py +58 -3
  6. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum_cli.egg-info/PKG-INFO +1 -1
  7. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/pyproject.toml +5 -0
  8. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/tests/test_block_storage.py +86 -1
  9. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/tests/test_dedicated_deploy.py +26 -2
  10. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/README.md +0 -0
  11. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/__main__.py +0 -0
  12. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/__init__.py +0 -0
  13. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/auth/__init__.py +0 -0
  14. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/auth/environment.py +0 -0
  15. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/auth/keys.py +0 -0
  16. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/auth/login.py +0 -0
  17. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/__init__.py +0 -0
  18. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/execution/__init__.py +0 -0
  19. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/execution/config.py +0 -0
  20. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/execution/docker.py +0 -0
  21. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/execution/docker_compose.py +0 -0
  22. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/execution/gpu_selection.py +0 -0
  23. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/execution/jobs.py +0 -0
  24. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/execution/notebook.py +0 -0
  25. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/execution/python.py +0 -0
  26. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/inference/__init__.py +0 -0
  27. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/compute/inference/chat.py +0 -0
  28. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/orgs/__init__.py +0 -0
  29. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/orgs/management.py +0 -0
  30. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/storage/__init__.py +0 -0
  31. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/storage/block.py +0 -0
  32. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/storage/files.py +0 -0
  33. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/external/vms/__init__.py +0 -0
  34. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/main.py +0 -0
  35. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/shared/__init__.py +0 -0
  36. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/shared/config.py +0 -0
  37. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/shared/http.py +0 -0
  38. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/shared/imports.py +0 -0
  39. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/shared/orgs.py +0 -0
  40. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/shared/run_options.py +0 -0
  41. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/shared/streaming.py +0 -0
  42. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum/shared/ui.py +0 -0
  43. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum_cli.egg-info/SOURCES.txt +0 -0
  44. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum_cli.egg-info/dependency_links.txt +0 -0
  45. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum_cli.egg-info/entry_points.txt +0 -0
  46. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum_cli.egg-info/requires.txt +0 -0
  47. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/lyceum_cli.egg-info/top_level.txt +0 -0
  48. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/setup.cfg +0 -0
  49. {lyceum_cli-1.2.1 → lyceum_cli-1.2.3}/tests/test_orgs.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lyceum-cli
3
- Version: 1.2.1
3
+ Version: 1.2.3
4
4
  Summary: Command-line interface for Lyceum Cloud
5
5
  Author-email: Lyceum <support@lyceum.technology>
6
6
  License: MIT
@@ -7,4 +7,4 @@ __version__ lives in this module. A future refactor could move these modules
7
7
  under lyceum/cli/, claiming one subpackage the way the other two do.
8
8
  """
9
9
 
10
- __version__ = "1.2.1"
10
+ __version__ = "1.2.3"
@@ -19,7 +19,7 @@ console = Console()
19
19
  # or ~/.claude settings on this machine.
20
20
  CLAUDE_PROFILE_DIR = Path.home() / ".lyceum" / "claude"
21
21
 
22
- DEFAULT_MODEL = "moonshotai/kimi-k3"
22
+ DEFAULT_MODEL = "moonshotai/kimi-k3.1-pro"
23
23
  DEFAULT_FAST_MODEL = "z-ai/glm-5.3-flash"
24
24
 
25
25
  # Use explicit Lyceum IDs so the backend never has to guess a substitute.
@@ -74,7 +74,7 @@ def _is_dedicated_inference_hidden() -> bool:
74
74
 
75
75
  def _fetch_dedicated_models() -> list[dict]:
76
76
  """Serverless models a dedicated deployment may run, on their default GPU shape."""
77
- return api_request("GET", "/api/v2/external/inference/models", timeout=20.0).get("models", [])
77
+ return api_request("GET", "/external/inference/models", timeout=20.0).get("models", [])
78
78
 
79
79
 
80
80
  def _format_gpus(gpu_type: str, gpu_count: int) -> str:
@@ -181,14 +181,27 @@ def deploy_model(
181
181
  target_latency: float = typer.Option(None, "--target-latency", hidden=True),
182
182
  stabilisation: int = typer.Option(None, "--stabilisation", hidden=True),
183
183
  gpu_count: int = typer.Option(
184
- None, "--gpu-count", help="GPUs per replica, defaults per model (also sets --tensor-parallel-size)"
184
+ None,
185
+ "--gpu-count",
186
+ help="GPUs per replica, defaults per model (also sets --tensor-parallel-size)",
187
+ ),
188
+ offload: bool = typer.Option(
189
+ None,
190
+ "--offload/--no-offload",
191
+ help=(
192
+ "Serve requests the deployment cannot from Lyceum's serverless capacity (default off). That may include a "
193
+ "third-party provider under Lyceum's data terms unless your org is restricted to Lyceum's own"
194
+ ),
185
195
  ),
186
196
  yes: bool = typer.Option(False, "--yes", "-y", help="Do not ask before creating"),
187
197
  wait: bool = typer.Option(False, "--wait", "-w", help="Wait until deployment has healthy replicas"),
188
198
  ):
189
199
  """Deploy a serverless model on dedicated GPUs."""
190
200
  models = _fetch_dedicated_models()
191
- model = next((m for m in models if model_id.lower() in (m["serving_name"].lower(), m["hf_model_id"].lower())), None)
201
+ model = next(
202
+ (m for m in models if model_id.lower() in (m["serving_name"].lower(), m["hf_model_id"].lower())),
203
+ None,
204
+ )
192
205
  if model is None:
193
206
  console.print(f"[red]{model_id} cannot be deployed on dedicated GPUs.[/red]")
194
207
  console.print("[dim]See the models that can: lyceum infer models --dedicated[/dim]")
@@ -222,7 +235,10 @@ def deploy_model(
222
235
  raise typer.Exit(0)
223
236
 
224
237
  if hf_token is None and not yes and not (os.getenv("HF_TOKEN") or os.getenv("HUGGING_FACE_HUB_TOKEN")):
225
- if typer.confirm("No HF token detected. Provide one (required for gated models)?", default=False):
238
+ if typer.confirm(
239
+ "No HF token detected. Provide one (required for gated models)?",
240
+ default=False,
241
+ ):
226
242
  hf_token = typer.prompt("HuggingFace Token", hide_input=True)
227
243
 
228
244
  payload = {
@@ -233,6 +249,7 @@ def deploy_model(
233
249
  overrides = {
234
250
  "gpu_count": gpu_count,
235
251
  "gpu_type": gpu_type,
252
+ "offload": offload,
236
253
  "stabilisation_window": stabilisation,
237
254
  "target_latency_p95_ms": target_latency,
238
255
  "target_rps": target_rps,
@@ -241,7 +258,7 @@ def deploy_model(
241
258
  if hf_token:
242
259
  payload["hf_token"] = hf_token
243
260
 
244
- data = api_request("POST", "/api/v2/external/inference/create", json=payload)
261
+ data = api_request("POST", "/external/inference/create", json=payload)
245
262
  deployment_id = data.get("deployment_id", "?")
246
263
 
247
264
  console.print("\n[green]Deployment created![/green]")
@@ -261,6 +278,30 @@ def deploy_model(
261
278
  _wait_for_healthy(deployment_id, timeout=model["ready_timeout_s"])
262
279
 
263
280
 
281
+ def _offload_label(enabled: bool | None) -> str:
282
+ return "enabled" if enabled else "disabled"
283
+
284
+
285
+ @infer_app.command("offload", hidden=_is_dedicated_inference_hidden())
286
+ def set_offload(
287
+ deployment_id: str = typer.Argument(..., help="Deployment ID"),
288
+ enabled: bool = typer.Option(..., "--enable/--disable", help="Turn offloading on or off"),
289
+ ):
290
+ """Turn offloading on or off for a deployment.
291
+
292
+ Enabled, requests the deployment cannot serve go to Lyceum's serverless capacity,
293
+ which may include a third-party provider under Lyceum's data terms unless your
294
+ org is restricted to Lyceum's own.
295
+ """
296
+ data = api_request(
297
+ "POST",
298
+ "/external/inference/offload",
299
+ json={"deployment_id": deployment_id, "offload": enabled},
300
+ )
301
+ console.print(f" Deployment ID: [cyan]{data.get('deployment_id')}[/cyan]")
302
+ console.print(f" Offload: [yellow]{_offload_label(data.get('offload'))}[/yellow]")
303
+
304
+
264
305
  @infer_app.command("stop")
265
306
  def stop_model(
266
307
  deployment_id: str = typer.Argument(..., help="Deployment ID to stop"),
@@ -268,7 +309,7 @@ def stop_model(
268
309
  """Stop a deployed model and all its replicas."""
269
310
  console.print(f"[dim]Stopping deployment {deployment_id[:12]}...[/dim]")
270
311
 
271
- data = api_request("DELETE", "/api/v2/external/inference/stop", json={"deployment_id": deployment_id})
312
+ data = api_request("DELETE", "/external/inference/stop", json={"deployment_id": deployment_id})
272
313
  console.print("[green]Deployment stopped![/green]")
273
314
  console.print(f" Deployment ID: [cyan]{data.get('deployment_id')}[/cyan]")
274
315
  console.print(f" Status: [yellow]{data.get('status')}[/yellow]")
@@ -283,7 +324,7 @@ def deployment_status(
283
324
  """Show detailed status of a deployment."""
284
325
  dep = api_request(
285
326
  "GET",
286
- "/api/v2/external/inference/get",
327
+ "/external/inference/get",
287
328
  params={"deployment_id": deployment_id, "include_terminated": str(include_terminated).lower()},
288
329
  timeout=15.0,
289
330
  )
@@ -307,6 +348,8 @@ def deployment_status(
307
348
  console.print(f" Target p95: {dep['target_latency_p95_ms']} ms")
308
349
  if dep.get("stabilisation_window") is not None:
309
350
  console.print(f" Stabilisation: {dep['stabilisation_window']} s")
351
+ if dep.get("offload") is not None:
352
+ console.print(f" Offload: {_offload_label(dep['offload'])}")
310
353
 
311
354
  replicas = dep.get("replicas", [])
312
355
  if replicas:
@@ -359,7 +402,7 @@ def list_deployments(
359
402
  """List your dedicated deployments."""
360
403
  data = api_request(
361
404
  "GET",
362
- "/api/v2/external/inference/list",
405
+ "/external/inference/list",
363
406
  params={"include_terminated": str(include_terminated).lower()},
364
407
  timeout=15.0,
365
408
  )
@@ -425,7 +468,7 @@ def replica_logs(
425
468
  replica_id: str = typer.Argument(..., help="Replica ID"),
426
469
  ):
427
470
  """Show last container logs for a failed replica."""
428
- data = api_request("GET", f"/api/v2/external/inference/replica/{replica_id}/logs", timeout=15.0)
471
+ data = api_request("GET", f"/external/inference/replica/{replica_id}/logs", timeout=15.0)
429
472
  error_logs = data.get("error_logs")
430
473
  if not error_logs:
431
474
  console.print(f"[yellow]No logs available for replica {replica_id}[/yellow]")
@@ -445,7 +488,7 @@ def _wait_for_healthy(deployment_id: str, timeout: int = 600, poll_interval: int
445
488
  while time.time() < deadline:
446
489
  try:
447
490
  response = httpx.get(
448
- f"{config.base_url}/api/v2/external/inference/get",
491
+ f"{config.base_url}/external/inference/get",
449
492
  headers=headers,
450
493
  params={"deployment_id": deployment_id},
451
494
  timeout=15.0,
@@ -47,6 +47,54 @@ def _print_ssh_command(ip_addr: str):
47
47
  console.print(f"\n[cyan]SSH command:[/cyan] ssh -i <your-key> lyceum@{ip_addr}")
48
48
 
49
49
 
50
+ def _attached_volumes_of(vm_id: str) -> list[dict[str, Any]]:
51
+ try:
52
+ data = api_request("GET", f"/api/v2/external/vms/{vm_id}/status", silent=True)
53
+ except typer.Exit:
54
+ return []
55
+ return (data or {}).get("volumes") or []
56
+
57
+
58
+ def _print_volumes_with_ids(volumes: list[dict[str, Any]]):
59
+ for volume in volumes:
60
+ size = volume.get("size_gb")
61
+ mount_path = volume.get("mount_path")
62
+ details = ", ".join(part for part in (f"{size} GB" if size else "", mount_path or "") if part)
63
+ console.print(f" [cyan]{volume.get('volume_id', '-')}[/cyan]" + (f" [dim]{details}[/dim]" if details else ""))
64
+
65
+
66
+ def _warn_about_attached_storage_being_not_deleted(volumes: list[dict[str, Any]]):
67
+ if not volumes:
68
+ return
69
+
70
+ one = len(volumes) == 1
71
+ noun, them, keep = ("volume", "it", "keeps") if one else ("volumes", "them", "keep")
72
+ console.print(f"\n[yellow]This VM is holding {len(volumes)} block storage {noun}:[/yellow]")
73
+ _print_volumes_with_ids(volumes)
74
+ console.print(
75
+ f"[yellow]Stopping the VM detaches {them} but does not delete {them}.[/yellow]\n"
76
+ f"[dim]The {noun} {keep} your data and {keep} being billed until you delete {them} separately.[/dim]\n"
77
+ )
78
+
79
+
80
+ def _report_detached_storage_with_usage_hints(volumes: list[dict[str, Any]]):
81
+ if not volumes:
82
+ return
83
+
84
+ one = len(volumes) == 1
85
+ noun = "volume" if one else "volumes"
86
+ verb = "is" if one else "are"
87
+ console.print(f"\n[yellow]{len(volumes)} block storage {noun} outlived the VM and {verb} still billed:[/yellow]")
88
+ _print_volumes_with_ids(volumes)
89
+ console.print(f"\n[dim]Delete {'it' if one else 'each one'} with:[/dim]")
90
+ for volume in volumes:
91
+ console.print(f" [cyan]lyceum storage block delete {volume.get('volume_id', '<volume-id>')}[/cyan]")
92
+ console.print(
93
+ f"[dim]Or keep {'it' if one else 'them'} for the next VM: "
94
+ "lyceum vm start --attach-storage <volume-id> ...[/dim]"
95
+ )
96
+
97
+
50
98
  def _validate_storage_options(
51
99
  attach_storage: list[str] | None,
52
100
  create_block_storage: int | None,
@@ -73,11 +121,14 @@ def _print_storage_result(data: dict[str, Any]):
73
121
  """Report the block storage a VM was created with, if any."""
74
122
  volume = data.get("volume")
75
123
  if volume:
124
+ name = volume.get("name", "-")
76
125
  console.print(
77
- f"[bold]Block storage:[/bold] {volume['volume_id']} "
126
+ f"[bold]Block storage:[/bold] {name} "
78
127
  f"({volume['size_gb']} GB, {_status_style(volume.get('status', 'pending'))})"
79
128
  )
80
- console.print("[dim]The volume outlives this VM; delete it with: lyceum storage block delete <id>[/dim]")
129
+ # The volume is named here rather than identified, because the provider
130
+ # has issued no ID yet. `storage block list` carries it once it has.
131
+ console.print("[dim]The volume outlives this VM; see it with: lyceum storage block list[/dim]")
81
132
 
82
133
  notice = data.get("volume_notice")
83
134
  if notice:
@@ -575,11 +626,15 @@ def terminate_instance(
575
626
  ):
576
627
  """Stop and delete a VM instance"""
577
628
  if not force:
629
+ _warn_about_attached_storage_being_not_deleted(_attached_volumes_of(vm_id))
578
630
  confirm = typer.confirm(f"Are you sure you want to terminate VM {vm_id}?")
579
631
  if not confirm:
580
632
  console.print("[yellow]Termination cancelled.[/yellow]")
581
633
  return
582
634
 
583
635
  console.print("[dim]Terminating VM instance...[/dim]")
584
- data = api_request("DELETE", f"/api/v2/external/vms/{vm_id}")
636
+ data = api_request("DELETE", f"/api/v2/external/vms/{vm_id}") or {}
585
637
  console.print(f"[green]✓ {data.get('message', 'VM instance terminated successfully')}[/green]")
638
+ # Taken from the delete rather than the lookup above, so --force hears about
639
+ # the storage too.
640
+ _report_detached_storage_with_usage_hints(data.get("detached_volumes") or [])
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lyceum-cli
3
- Version: 1.2.1
3
+ Version: 1.2.3
4
4
  Summary: Command-line interface for Lyceum Cloud
5
5
  Author-email: Lyceum <support@lyceum.technology>
6
6
  License: MIT
@@ -40,6 +40,11 @@ Dashboard = "https://dashboard.lyceum.technology"
40
40
  [project.scripts]
41
41
  lyceum = "lyceum.main:app"
42
42
 
43
+ [dependency-groups]
44
+ test = [
45
+ "pytest==9.0.2",
46
+ ]
47
+
43
48
  [tool.setuptools.dynamic]
44
49
  version = { attr = "lyceum._version.__version__" }
45
50
 
@@ -1,6 +1,7 @@
1
1
  """The CLI surface for block storage: `storage block` and `vm start`'s options."""
2
2
 
3
3
  import pytest
4
+ import typer
4
5
  from typer.testing import CliRunner
5
6
 
6
7
  from lyceum.external.storage import block
@@ -271,7 +272,7 @@ def test_a_copy_can_be_switched_off(gateway):
271
272
 
272
273
  def test_a_new_volume_is_asked_for_by_size(gateway):
273
274
  gateway.bodies["/api/v2/external/vms/create"] = _vm_body(
274
- volume={"volume_id": "hyd-devel-vol-new", "size_gb": 100, "status": "pending"}
275
+ volume={"name": "hyd-devel-vol-new", "size_gb": 100, "status": "pending"}
275
276
  )
276
277
 
277
278
  result = runner.invoke(app, [*_VM_ARGS, "--create-block-storage", "100"])
@@ -312,3 +313,87 @@ def test_a_volume_being_copied_is_reported_instead_of_polled(gateway):
312
313
  assert result.exit_code == 0
313
314
  assert "being copied" in result.output
314
315
  assert "lyceum storage block list" in result.output
316
+
317
+
318
+ # --- lyceum vm stop ---------------------------------------------------------
319
+
320
+
321
+ def _stop_bodies(gateway, volumes: list[dict], detached: list[dict] | None = None):
322
+ """What the gateway answers a stop with: the VM's storage, then the delete."""
323
+ gateway.bodies["/api/v2/external/vms/vm-1/status"] = {"vm_id": "vm-1", "status": "ready", "volumes": volumes}
324
+ gateway.bodies["/api/v2/external/vms/vm-1"] = {
325
+ "vm_id": "vm-1",
326
+ "status": "terminated",
327
+ "message": "VM vm-1 has been terminated",
328
+ "detached_volumes": volumes if detached is None else detached,
329
+ }
330
+
331
+
332
+ def test_stopping_a_vm_names_its_storage_before_asking(gateway):
333
+ """The prompt is the last point at which knowing costs the customer nothing."""
334
+ _stop_bodies(gateway, [_VOLUME])
335
+
336
+ result = runner.invoke(app, ["vm", "stop", "vm-1"], input="y\n")
337
+
338
+ assert result.exit_code == 0
339
+ assert "vol-abc" in result.output
340
+ assert "does not delete" in result.output
341
+ # Being billed on is the part no other command would have told them.
342
+ assert "billed" in result.output
343
+
344
+
345
+ def test_a_vm_without_storage_is_not_warned_about_any(gateway):
346
+ _stop_bodies(gateway, [])
347
+
348
+ result = runner.invoke(app, ["vm", "stop", "vm-1"], input="y\n")
349
+
350
+ assert result.exit_code == 0
351
+ assert "block storage" not in result.output.lower()
352
+
353
+
354
+ def test_declining_the_prompt_stops_nothing(gateway):
355
+ _stop_bodies(gateway, [_VOLUME])
356
+
357
+ result = runner.invoke(app, ["vm", "stop", "vm-1"], input="n\n")
358
+
359
+ assert result.exit_code == 0
360
+ assert "cancelled" in result.output.lower()
361
+ assert not any(method == "DELETE" for method, _path, _kwargs in gateway.calls)
362
+
363
+
364
+ def test_the_storage_left_behind_comes_with_the_command_that_deletes_it(gateway):
365
+ _stop_bodies(gateway, [_VOLUME])
366
+
367
+ result = runner.invoke(app, ["vm", "stop", "vm-1"], input="y\n")
368
+
369
+ assert result.exit_code == 0
370
+ assert "lyceum storage block delete vol-abc" in result.output
371
+
372
+
373
+ def test_force_hears_about_the_storage_even_though_it_skips_the_prompt(gateway):
374
+ """--force waives the question, not the answer: the volumes are still billed."""
375
+ _stop_bodies(gateway, [_VOLUME])
376
+
377
+ result = runner.invoke(app, ["vm", "stop", "vm-1", "--force"])
378
+
379
+ assert result.exit_code == 0
380
+ # Nothing was asked, so the status lookup behind the prompt was not made.
381
+ assert [path for _method, path, _kwargs in gateway.calls] == ["/api/v2/external/vms/vm-1"]
382
+ assert "lyceum storage block delete vol-abc" in result.output
383
+
384
+
385
+ def test_a_status_lookup_that_fails_does_not_block_the_stop(gateway, monkeypatch):
386
+ """Not knowing about the storage is no reason to refuse to stop the VM."""
387
+ _stop_bodies(gateway, [_VOLUME])
388
+
389
+ def refuse_the_status(method, path, **kwargs):
390
+ if path.endswith("/status"):
391
+ raise typer.Exit(1)
392
+ return gateway(method, path, **kwargs)
393
+
394
+ monkeypatch.setattr(management, "api_request", refuse_the_status)
395
+
396
+ result = runner.invoke(app, ["vm", "stop", "vm-1"], input="y\n")
397
+
398
+ assert result.exit_code == 0
399
+ assert "terminated" in result.output
@@ -29,11 +29,14 @@ def gateway(monkeypatch):
29
29
  creates = []
30
30
 
31
31
  def api_request(method, path, **kw):
32
- if path == "/api/v2/external/inference/models":
32
+ if path == "/external/inference/models":
33
33
  return {"models": [GLM52, FLASH]}
34
- if path == "/api/v2/external/inference/create":
34
+ if path == "/external/inference/create":
35
35
  creates.append(kw["json"])
36
36
  return {"deployment_id": "d1", "status": "pending"}
37
+ if path == "/external/inference/offload":
38
+ creates.append(kw["json"])
39
+ return kw["json"]
37
40
  raise AssertionError(path)
38
41
 
39
42
  monkeypatch.setattr(infer, "api_request", api_request)
@@ -103,3 +106,24 @@ def test_wait_uses_the_model_ready_timeout(gateway, monkeypatch):
103
106
  monkeypatch.setattr(infer, "_wait_for_healthy", lambda d, timeout: waited.append((d, timeout)))
104
107
  assert _run("deploy", "deepseek/deepseek-v4-flash-0731", "--wait").exit_code == 0
105
108
  assert waited == [("d1", 4800)]
109
+
110
+
111
+ def test_deploy_offload_is_sent_only_when_given(gateway):
112
+ assert _run("deploy", "deepseek/deepseek-v4-flash-0731").exit_code == 0
113
+ assert "offload" not in gateway[0]
114
+ assert _run("deploy", "deepseek/deepseek-v4-flash-0731", "--offload").exit_code == 0
115
+ assert gateway[1]["offload"] is True
116
+ assert _run("deploy", "deepseek/deepseek-v4-flash-0731", "--no-offload").exit_code == 0
117
+ assert gateway[2]["offload"] is False
118
+
119
+
120
+ def test_offload_command_posts_the_switch(gateway):
121
+ result = _run("offload", "d1", "--enable")
122
+ assert result.exit_code == 0
123
+ assert "enabled" in result.output
124
+ assert _run("offload", "d1", "--disable").exit_code == 0
125
+ assert gateway == [
126
+ {"deployment_id": "d1", "offload": True},
127
+ {"deployment_id": "d1", "offload": False},
128
+ ]
129
+ assert _run("offload", "d1").exit_code == 2
File without changes
File without changes
File without changes