Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use System Install Path Instead of Local Member Variables #206

Merged
merged 1 commit into from
Sep 27, 2024
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
2 changes: 0 additions & 2 deletions src/cloudai/_core/test_template_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class TestTemplateStrategy:

Attributes
system (System): The system schema object.
install_path (str): Path where the benchmarks are to be installed.
env_vars (Dict[str, Any]): Default environment variables.
cmd_args (Dict[str, Any]): Default command-line arguments.
default_env_vars (Dict[str, str]): Constructed default environment variables.
Expand All @@ -47,7 +46,6 @@ def __init__(self, system: System, env_vars: Dict[str, Any], cmd_args: Dict[str,
cmd_args (Dict[str, Any]): Default command-line arguments.
"""
self.system = system
self.install_path = ""
self.env_vars = env_vars
self.cmd_args = cmd_args
self.default_env_vars = self._construct_default_env_vars()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def is_installed(self) -> InstallStatusResult:
return InstallStatusResult(success=True)
else:
if self.docker_image_cache_manager.cache_docker_images_locally:
expected_docker_image_path = (
self.docker_image_cache_manager.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
)
expected_docker_image_path = self.system.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
return InstallStatusResult(
success=False,
message=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def is_installed(self) -> InstallStatusResult:
return InstallStatusResult(success=True)
else:
if self.docker_image_cache_manager.cache_docker_images_locally:
expected_docker_image_path = (
self.docker_image_cache_manager.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
)
expected_docker_image_path = self.system.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
return InstallStatusResult(
success=False,
message=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@


class NeMoLauncherSlurmCommandGenStrategy(SlurmCommandGenStrategy):
"""
Command generation strategy for NeMo Megatron Launcher on Slurm systems.

Attributes
install_path (Path): The installation path of CloudAI.
"""
"""Command generation strategy for NeMo Megatron Launcher on Slurm systems."""

def gen_exec_command(
self,
Expand All @@ -44,7 +39,7 @@ def gen_exec_command(
final_env_vars = self._override_env_vars(final_env_vars, extra_env_vars)

launcher_path = (
self.install_path
self.system.install_path
/ NeMoLauncherSlurmInstallStrategy.SUBDIR_PATH
/ NeMoLauncherSlurmInstallStrategy.REPOSITORY_NAME
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, system: System, env_vars: Dict[str, Any], cmd_args: Dict[str,
self.docker_image_url = cmd_args["docker_image_url"]

def is_installed(self) -> InstallStatusResult:
subdir_path = self.install_path / self.SUBDIR_PATH
subdir_path = self.system.install_path / self.SUBDIR_PATH
repo_path = subdir_path / self.REPOSITORY_NAME
repo_installed = repo_path.is_dir()

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

subdir_path = self.install_path / self.SUBDIR_PATH
subdir_path = self.system.install_path / self.SUBDIR_PATH
subdir_path.mkdir(parents=True, exist_ok=True)

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

def _check_datasets_on_nodes(self, data_dir_path: Path) -> DatasetCheckResult:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def is_installed(self) -> InstallStatusResult:
return InstallStatusResult(success=True)
else:
if self.docker_image_cache_manager.cache_docker_images_locally:
expected_docker_image_path = (
self.docker_image_cache_manager.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
)
expected_docker_image_path = self.system.install_path / self.SUBDIR_PATH / self.DOCKER_IMAGE_FILENAME
return InstallStatusResult(
success=False,
message=(
Expand Down