Skip to content

Commit 72ca9cd

Browse files
Andrey Cheptsovclaude
andcommitted
Show failed creations in dstack preset
A creation that ends as failed was dropped from the listing, so the only way back to its trials and log was to already know the preset id. `_STATUS_DISPLAY` already had a red `failed` entry that nothing could reach. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 3fedd27 commit 72ca9cd

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/dstack/_internal/cli/services/presets/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def list_agent_sessions() -> list[dict[str, Any]]:
424424
path = session.path
425425
manifest = session.read_manifest()
426426
status = manifest.get("status")
427-
if status not in ("running", "interrupted", "success"):
427+
if status not in ("running", "interrupted", "success", "failed"):
428428
continue
429429
if status == "running" and not session_process_alive(manifest):
430430
status = "interrupted"

src/tests/_internal/cli/services/presets/test_create.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,20 @@ def test_load_agent_session_reads_any_status(self, tmp_path, monkeypatch):
833833
with pytest.raises(CLIError, match="Unknown preset"):
834834
load_agent_session("nope0000")
835835

836+
def test_lists_a_failed_session(self, tmp_path, monkeypatch):
837+
from dstack._internal.cli.services.presets.session import list_agent_sessions
838+
839+
self._session(tmp_path, "dead0000", "failed", "[t] boom\n")
840+
self._session(tmp_path, "beef0000", "success", "[t] saved preset\n")
841+
monkeypatch.setattr(
842+
"dstack._internal.cli.services.presets.session.get_presets_dir",
843+
lambda: tmp_path,
844+
)
845+
846+
listed = {entry["id"]: entry["status"] for entry in list_agent_sessions()}
847+
848+
assert listed == {"dead0000": "failed", "beef0000": "success"}
849+
836850
def test_print_session_log_dumps_log_verbatim(self, tmp_path, monkeypatch, capsys):
837851
session = self._session(
838852
tmp_path, "abcd0000", "success", "[t] trial 1 done\n[t] saved preset\n"

0 commit comments

Comments
 (0)