Skip to content

Commit 648c6a4

Browse files
authored
Use system install path instead of local member variables (#206)
1 parent c593617 commit 648c6a4

File tree

6 files changed

+11
-24
lines changed

6 files changed

+11
-24
lines changed

src/cloudai/_core/test_template_strategy.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class TestTemplateStrategy:
2828
2929
Attributes
3030
system (System): The system schema object.
31-
install_path (str): Path where the benchmarks are to be installed.
3231
env_vars (Dict[str, Any]): Default environment variables.
3332
cmd_args (Dict[str, Any]): Default command-line arguments.
3433
default_env_vars (Dict[str, str]): Constructed default environment variables.
@@ -47,7 +46,6 @@ def __init__(self, system: System, env_vars: Dict[str, Any], cmd_args: Dict[str,
4746
cmd_args (Dict[str, Any]): Default command-line arguments.
4847
"""
4948
self.system = system
50-
self.install_path = ""
5149
self.env_vars = env_vars
5250
self.cmd_args = cmd_args
5351
self.default_env_vars = self._construct_default_env_vars()

src/cloudai/schema/test_template/jax_toolbox/slurm_install_strategy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ def is_installed(self) -> InstallStatusResult:
3333
return InstallStatusResult(success=True)
3434
else:
3535
if self.docker_image_cache_manager.cache_docker_images_locally:
36-
expected_docker_image_path = (
37-
self.docker_image_cache_manager.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
38-
)
36+
expected_docker_image_path = self.system.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
3937
return InstallStatusResult(
4038
success=False,
4139
message=(

src/cloudai/schema/test_template/nccl_test/slurm_install_strategy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ def is_installed(self) -> InstallStatusResult:
3939
return InstallStatusResult(success=True)
4040
else:
4141
if self.docker_image_cache_manager.cache_docker_images_locally:
42-
expected_docker_image_path = (
43-
self.docker_image_cache_manager.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
44-
)
42+
expected_docker_image_path = self.system.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
4543
return InstallStatusResult(
4644
success=False,
4745
message=(

src/cloudai/schema/test_template/nemo_launcher/slurm_command_gen_strategy.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323

2424

2525
class NeMoLauncherSlurmCommandGenStrategy(SlurmCommandGenStrategy):
26-
"""
27-
Command generation strategy for NeMo Megatron Launcher on Slurm systems.
28-
29-
Attributes
30-
install_path (Path): The installation path of CloudAI.
31-
"""
26+
"""Command generation strategy for NeMo Megatron Launcher on Slurm systems."""
3227

3328
def gen_exec_command(
3429
self,
@@ -44,7 +39,7 @@ def gen_exec_command(
4439
final_env_vars = self._override_env_vars(final_env_vars, extra_env_vars)
4540

4641
launcher_path = (
47-
self.install_path
42+
self.system.install_path
4843
/ NeMoLauncherSlurmInstallStrategy.SUBDIR_PATH
4944
/ NeMoLauncherSlurmInstallStrategy.REPOSITORY_NAME
5045
)

src/cloudai/schema/test_template/nemo_launcher/slurm_install_strategy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def __init__(self, system: System, env_vars: Dict[str, Any], cmd_args: Dict[str,
6565
self.docker_image_url = cmd_args["docker_image_url"]
6666

6767
def is_installed(self) -> InstallStatusResult:
68-
subdir_path = self.install_path / self.SUBDIR_PATH
68+
subdir_path = self.system.install_path / self.SUBDIR_PATH
6969
repo_path = subdir_path / self.REPOSITORY_NAME
7070
repo_installed = repo_path.is_dir()
7171

@@ -117,7 +117,7 @@ def install(self) -> InstallStatusResult:
117117
except PermissionError as e:
118118
return InstallStatusResult(success=False, message=str(e))
119119

120-
subdir_path = self.install_path / self.SUBDIR_PATH
120+
subdir_path = self.system.install_path / self.SUBDIR_PATH
121121
subdir_path.mkdir(parents=True, exist_ok=True)
122122

123123
data_dir_path = Path(self.default_cmd_args["data_dir"])
@@ -171,10 +171,10 @@ def _check_install_path_access(self):
171171
PermissionError: If the install path does not exist or if there is no permission to create directories and
172172
files.
173173
"""
174-
if not self.install_path.exists():
175-
raise PermissionError(f"Install path {self.install_path} does not exist.")
176-
if not self.install_path.is_dir() or not os.access(self.install_path, os.W_OK):
177-
raise PermissionError(f"No permission to write in install path {self.install_path}.")
174+
if not self.system.install_path.exists():
175+
raise PermissionError(f"Install path {self.system.install_path} does not exist.")
176+
if not self.system.install_path.is_dir() or not os.access(self.system.install_path, os.W_OK):
177+
raise PermissionError(f"No permission to write in install path {self.system.install_path}.")
178178

179179
def _check_datasets_on_nodes(self, data_dir_path: Path) -> DatasetCheckResult:
180180
"""

src/cloudai/schema/test_template/ucc_test/slurm_install_strategy.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ def is_installed(self) -> InstallStatusResult:
3939
return InstallStatusResult(success=True)
4040
else:
4141
if self.docker_image_cache_manager.cache_docker_images_locally:
42-
expected_docker_image_path = (
43-
self.docker_image_cache_manager.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
44-
)
42+
expected_docker_image_path = self.system.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
4543
return InstallStatusResult(
4644
success=False,
4745
message=(

0 commit comments

Comments
 (0)