Skip to content

Commit 13205f5

Browse files
authored
Merge pull request #757 from NVIDIA/am/bug-4730612
Fix a crash during dry-run for Dynamo scenario
2 parents f5b2ceb + 05b7165 commit 13205f5

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

src/cloudai/_core/base_installer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,12 @@ def mark_as_installed(self, items: Iterable[Installable]) -> InstallStatusResult
268268
Returns:
269269
InstallStatusResult: Result containing the status and error message if any.
270270
"""
271-
install_results = {}
271+
install_results: dict[Installable, InstallStatusResult] = {}
272272
for item in self.all_items(items):
273-
self.mark_as_installed_one(item)
273+
result = self.mark_as_installed_one(item)
274+
install_results[item] = result
275+
276+
self._populate_successful_install(items, install_results)
274277

275278
return InstallStatusResult(True, "All items marked as installed successfully.", install_results)
276279

src/cloudai/cli/handlers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ def handle_dry_run_and_run(args: argparse.Namespace) -> int:
289289
logging.error("Failed to install workloads components.")
290290
logging.error(result.message)
291291
return 1
292+
elif args.mode == "dry-run":
293+
# simulate installation for dry-run
294+
installables, installer = prepare_installation(system, tests, test_scenario)
295+
result = installer.mark_as_installed(installables)
296+
if not result.success:
297+
logging.warning("Failed to mark workloads components as installed for dry-run.")
292298

293299
logging.info(test_scenario.pretty_print())
294300

tests/test_base_installer.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,21 @@ def test_order_of_items_does_not_matter(self, installer: SlurmInstaller):
293293
)
294294
assert f2._installed_path is not None, "Second file was not marked as installed"
295295

296+
def test_both_mark_as_installed(self, installer: SlurmInstaller):
297+
f1, f2 = File(src=Path(__file__)), File(src=Path(__file__))
298+
299+
assert f1 == f2, "Files should be equal"
300+
assert f1 is not f2, "Files should be distinct objects"
301+
assert f1._installed_path is None, "First file should not be installed before test"
302+
assert f2._installed_path is None, "Second file should not be installed before test"
303+
304+
res = installer.mark_as_installed([f1, f2])
305+
306+
assert res.success, "mark_as_installed should succeed"
307+
assert f1._installed_path is not None, "First file should have installed_path set"
308+
assert f2._installed_path is not None, "Second file should have installed_path set"
309+
assert f1._installed_path == f2._installed_path, "Files should have same installed_path"
310+
296311

297312
@pytest.fixture(params=["k8s", "slurm"])
298313
def installer(

0 commit comments

Comments
 (0)