From 1912361fcd1f240d6c50cb6a30737deeda8e6f85 Mon Sep 17 00:00:00 2001 From: shreyaskommuri Date: Wed, 10 Jun 2026 10:03:16 -0700 Subject: [PATCH 1/3] Keep standalone sleep dry-run from crashing on command generation Implement the sleep standalone command generator's store_test_run contract so dry-run can instantiate it and persist test-run.toml like the other standalone generators. Constraint: CloudAI CommandGenStrategy requires store_test_run on concrete strategies Rejected: Leaving sleep standalone without persisted test-run details | it keeps the documented dry-run smoke path broken Confidence: high Scope-risk: narrow Directive: Preserve test-run.toml persistence when changing standalone command generator contracts Tested: uv run pytest tests/workloads/sleep/test_command_gen_strategy_standalone.py -q Tested: uv run pytest tests/workloads/sleep -q Tested: uv run pytest tests/test_init.py tests/workloads/sleep/test_command_gen_strategy_standalone.py tests/workloads/sleep/test_command_gen_strategy_slurm.py -q Tested: uv run ruff check src/cloudai/workloads/sleep/standalone_command_gen_strategy.py tests/workloads/sleep/test_command_gen_strategy_standalone.py Not-tested: Full sleep dry-run completion; local harness interrupted the CLI smoke run after it passed the previous abstract-class crash and wrote test-run.toml files Signed-off-by: shreyaskommuri --- .../sleep/standalone_command_gen_strategy.py | 13 ++++++ .../test_command_gen_strategy_standalone.py | 45 +++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 tests/workloads/sleep/test_command_gen_strategy_standalone.py diff --git a/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py b/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py index aa99a6461..6e499c869 100644 --- a/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py +++ b/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py @@ -16,7 +16,10 @@ from typing import cast +import toml + from cloudai.core import CommandGenStrategy +from cloudai.models.scenario import TestRunDetails from .sleep import SleepCmdArgs, SleepTestDefinition @@ -24,7 +27,17 @@ class SleepStandaloneCommandGenStrategy(CommandGenStrategy): """Command generation strategy for the Sleep test on standalone systems.""" + def store_test_run(self) -> None: + tdef: SleepTestDefinition = cast(SleepTestDefinition, self.test_run.test) + sec = tdef.cmd_args.seconds + test_cmd = f"sleep {sec}" + self.test_run.output_path.mkdir(parents=True, exist_ok=True) + with (self.test_run.output_path / self.TEST_RUN_DUMP_FILE_NAME).open("w", encoding="utf-8") as f: + trd = TestRunDetails.from_test_run(self.test_run, test_cmd=test_cmd, full_cmd=test_cmd) + toml.dump(trd.model_dump(), f) + def gen_exec_command(self) -> str: + self.store_test_run() tdef: SleepTestDefinition = cast(SleepTestDefinition, self.test_run.test) tdef_cmd_args: SleepCmdArgs = tdef.cmd_args sec = tdef_cmd_args.seconds diff --git a/tests/workloads/sleep/test_command_gen_strategy_standalone.py b/tests/workloads/sleep/test_command_gen_strategy_standalone.py new file mode 100644 index 000000000..95964f422 --- /dev/null +++ b/tests/workloads/sleep/test_command_gen_strategy_standalone.py @@ -0,0 +1,45 @@ +# SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES +# Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from pathlib import Path + +import toml + +from cloudai.core import CommandGenStrategy, TestRun +from cloudai.models.scenario import TestRunDetails +from cloudai.systems.standalone import StandaloneSystem +from cloudai.workloads.sleep import SleepCmdArgs, SleepStandaloneCommandGenStrategy, SleepTestDefinition + + +def test_gen_exec_command_writes_test_run_details(tmp_path: Path, standalone_system: StandaloneSystem) -> None: + tdef = SleepTestDefinition( + name="sleep_test", + description="Simple sleep test", + test_template_name="Sleep", + cmd_args=SleepCmdArgs(seconds=60), + ) + tr = TestRun(name="sleep-job", test=tdef, num_nodes=1, nodes=[], output_path=tmp_path / "output") + + strategy = SleepStandaloneCommandGenStrategy(standalone_system, tr) + command = strategy.gen_exec_command() + + assert command == "sleep 60" + + dump_path = tr.output_path / CommandGenStrategy.TEST_RUN_DUMP_FILE_NAME + assert dump_path.is_file() + details = TestRunDetails.model_validate(toml.load(dump_path)) + assert details.test_cmd == "sleep 60" + assert details.full_cmd == "sleep 60" From 2be6b7ca47ec5c0b3c879b2b13b1c18f492c41cb Mon Sep 17 00:00:00 2001 From: shreyaskommuri Date: Wed, 10 Jun 2026 10:26:35 -0700 Subject: [PATCH 2/3] Avoid drift in sleep dry-run command generation The CodeRabbit review found the persisted test command and returned exec command were assembled independently. This keeps both paths sourced from one helper while preserving the existing output. Constraint: Address PR #921 review without changing sleep command behavior Rejected: Keep duplicated command formatting | preserves the reviewed drift risk Confidence: high Scope-risk: narrow Directive: Keep persisted test_cmd and returned exec command sourced from the same helper Tested: UV_CACHE_DIR=.uv-cache uv run --extra dev pytest tests/workloads/sleep/test_command_gen_strategy_standalone.py Not-tested: Full test suite --- .../sleep/standalone_command_gen_strategy.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py b/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py index 6e499c869..6b194d710 100644 --- a/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py +++ b/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py @@ -21,16 +21,18 @@ from cloudai.core import CommandGenStrategy from cloudai.models.scenario import TestRunDetails -from .sleep import SleepCmdArgs, SleepTestDefinition +from .sleep import SleepTestDefinition class SleepStandaloneCommandGenStrategy(CommandGenStrategy): """Command generation strategy for the Sleep test on standalone systems.""" - def store_test_run(self) -> None: + def _generate_sleep_command(self) -> str: tdef: SleepTestDefinition = cast(SleepTestDefinition, self.test_run.test) - sec = tdef.cmd_args.seconds - test_cmd = f"sleep {sec}" + return f"sleep {tdef.cmd_args.seconds}" + + def store_test_run(self) -> None: + test_cmd = self._generate_sleep_command() self.test_run.output_path.mkdir(parents=True, exist_ok=True) with (self.test_run.output_path / self.TEST_RUN_DUMP_FILE_NAME).open("w", encoding="utf-8") as f: trd = TestRunDetails.from_test_run(self.test_run, test_cmd=test_cmd, full_cmd=test_cmd) @@ -38,7 +40,4 @@ def store_test_run(self) -> None: def gen_exec_command(self) -> str: self.store_test_run() - tdef: SleepTestDefinition = cast(SleepTestDefinition, self.test_run.test) - tdef_cmd_args: SleepCmdArgs = tdef.cmd_args - sec = tdef_cmd_args.seconds - return f"sleep {sec}" + return self._generate_sleep_command() From 325fa78dfeb273d50c7032a5175b4047d79d2893 Mon Sep 17 00:00:00 2001 From: shreyaskommuri Date: Fri, 12 Jun 2026 08:01:43 -0700 Subject: [PATCH 3/3] Keep sleep standalone CI unblocked Update the modified standalone sleep command generator header so the CI-only copyright check reflects the 2026 edit year. Constraint: CI derives expected copyright years from git history and dirty status. Rejected: Changing the copyright checker | the checker correctly identified the modified source file. Confidence: high Scope-risk: narrow Directive: Preserve generated copyright year ranges when modifying existing files. Tested: uv run python -m pytest tests/test_check_copyright_headers.py -q -m ci_only; uv run pytest tests/test_init.py tests/workloads/sleep/test_command_gen_strategy_standalone.py tests/workloads/sleep/test_command_gen_strategy_slurm.py -q; git diff --check Not-tested: Full repository pytest suite after this one-line metadata fix. --- src/cloudai/workloads/sleep/standalone_command_gen_strategy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py b/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py index 6b194d710..b4494b971 100644 --- a/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py +++ b/src/cloudai/workloads/sleep/standalone_command_gen_strategy.py @@ -1,5 +1,5 @@ # SPDX-FileCopyrightText: NVIDIA CORPORATION & AFFILIATES -# Copyright (c) 2024-2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # # Licensed under the Apache License, Version 2.0 (the "License");