Skip to content

Commit ad2b9ac

Browse files
authored
Merge pull request #676 from NVIDIA/am/auto-install
Auto install missing components for workloads in run mode
2 parents e1d52c2 + 6f14a98 commit ad2b9ac

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/cloudai/_core/base_installer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ def install(self, items: Iterable[Installable]) -> InstallStatusResult:
182182
return InstallStatusResult(False, f"Error preparing install dir '{self.system.install_path.absolute()}'")
183183

184184
logging.debug(f"Going to install {len(set(items))} uniq item(s) (total is {len(list(items))})")
185-
logging.info(f"Going to install {len(set(items))} item(s)")
186185

187186
install_results: dict[Installable, InstallStatusResult] = {}
188187
with ThreadPoolExecutor(max_workers=self.num_workers) as executor:

src/cloudai/cli/handlers.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
BaseInstaller,
3232
CloudAIGymEnv,
3333
Installable,
34+
InstallStatusResult,
3435
MissingTestError,
3536
Parser,
3637
Registry,
@@ -237,21 +238,16 @@ def _handle_single_sbatch(args: argparse.Namespace, system: System) -> bool:
237238

238239
def _check_installation(
239240
args: argparse.Namespace, system: System, tests: list[Test], test_scenario: TestScenario
240-
) -> bool:
241-
logging.info("Checking if test templates are installed.")
241+
) -> InstallStatusResult:
242+
logging.info("Checking if workloads components are installed.")
242243
installables, installer = prepare_installation(system, tests, test_scenario)
243244

244245
if args.enable_cache_without_check:
245246
result = installer.mark_as_installed(installables)
246247
else:
247248
result = installer.is_installed(installables)
248249

249-
if args.mode == "run" and not result.success:
250-
logging.error("CloudAI has not been installed. Please run install mode first.")
251-
logging.error(result.message)
252-
return False
253-
254-
return True
250+
return result
255251

256252

257253
def handle_dry_run_and_run(args: argparse.Namespace) -> int:
@@ -271,8 +267,18 @@ def handle_dry_run_and_run(args: argparse.Namespace) -> int:
271267
logging.info(f"Scheduler: {system.scheduler}")
272268
logging.info(f"Test Scenario Name: {test_scenario.name}")
273269

274-
if not _check_installation(args, system, tests, test_scenario):
275-
return 1
270+
result = _check_installation(args, system, tests, test_scenario)
271+
if args.mode == "run" and not result.success:
272+
logging.info("Not all workloads components are installed. Installing...")
273+
installables, installer = prepare_installation(system, tests, test_scenario)
274+
275+
result = installer.install(installables)
276+
if result.success:
277+
logging.info(f"CloudAI is successfully installed into '{system.install_path.absolute()}'.")
278+
else:
279+
logging.error("Failed to install workloads components.")
280+
logging.error(result.message)
281+
return 1
276282

277283
logging.info(test_scenario.pretty_print())
278284

0 commit comments

Comments
 (0)