Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions nemo_run/run/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,9 @@ def _get_job_info_and_dict(
idx: int, job: Job | JobGroup
) -> tuple[list[str], dict[str, str]]:
job_info = []
job_status = job.status(runner=self._runner)
job_info.append(f"[bold green]Task {idx}[/bold green]: [bold orange1]{job.id}")
job_info.append(
f"- [bold green]Status[/bold green]: {str(job.status(runner=self._runner))}"
)
job_info.append(f"- [bold green]Status[/bold green]: {str(job_status)}")
job_info.append(f"- [bold green]Executor[/bold green]: {job.executor.info()}")

try:
Expand All @@ -927,7 +926,7 @@ def _get_job_info_and_dict(
]
job_dict = {
"name": job.id,
"status": job.status(runner=self._runner),
"status": job_status,
"executor": job.executor.info(),
"job_id": app_id,
"handle": job.handle,
Expand Down
24 changes: 24 additions & 0 deletions test/run/test_experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,30 @@ def test_experiment_status(mock_get_runner, temp_dir):
mock_print.assert_called()


@patch("nemo_run.run.experiment.get_runner")
def test_experiment_status_polls_job_once(mock_get_runner, temp_dir):
"""Experiment.status() should call job.status() once per job.

Previously the display text and returned dict each called job.status(),
producing duplicate backend requests (and duplicate error logs on failure).
"""
mock_runner = MagicMock()
mock_get_runner.return_value = mock_runner

with Experiment("test-exp") as exp:
task = run.Partial(dummy_function, x=1, y=2)
exp.add(task, name="test-job")
exp.jobs[0].status = MagicMock(return_value=AppState.SUCCEEDED)

exp.status(return_dict=True)
exp.jobs[0].status.assert_called_once_with(runner=mock_runner)

exp.jobs[0].status.reset_mock()
with patch.object(exp.console, "print"):
exp.status()
exp.jobs[0].status.assert_called_once_with(runner=mock_runner)


@patch("nemo_run.run.experiment.get_runner")
def test_experiment_cancel(mock_get_runner, temp_dir):
"""Test cancelling an experiment job."""
Expand Down
Loading