Skip to content

Commit

Permalink
Pass install_path to SlurmInstallStrategy
Browse files Browse the repository at this point in the history
Co-authored-by: Lior Paz <liorpa@nvidia.com>
  • Loading branch information
TaekyungHeo and lappazos committed Jun 4, 2024
1 parent 967e7d7 commit c97c6c6
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(
) -> None:
super().__init__(system, env_vars, cmd_args)
self.slurm_system = cast(SlurmSystem, self.system)
self.install_path = self.slurm_system.install_path
self.docker_image_cache_manager = DockerImageCacheManager(
self.slurm_system.install_path, self.slurm_system.cache_docker_images_locally
)
Expand Down
39 changes: 39 additions & 0 deletions tests/test_slurm_install_strategy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from pathlib import Path

import pytest
from cloudai.systems import SlurmSystem
from cloudai.systems.slurm import SlurmNode, SlurmNodeState
from cloudai.systems.slurm.strategy import SlurmInstallStrategy


@pytest.fixture
def slurm_system(tmp_path: Path) -> SlurmSystem:
slurm_system = SlurmSystem(
name="TestSystem",
install_path=str(tmp_path / "install"),
output_path=str(tmp_path / "output"),
default_partition="main",
partitions={
"main": [
SlurmNode(name="node1", partition="main", state=SlurmNodeState.IDLE),
SlurmNode(name="node2", partition="main", state=SlurmNodeState.IDLE),
SlurmNode(name="node3", partition="main", state=SlurmNodeState.IDLE),
SlurmNode(name="node4", partition="main", state=SlurmNodeState.IDLE),
]
},
)
Path(slurm_system.install_path).mkdir()
Path(slurm_system.output_path).mkdir()
return slurm_system


@pytest.fixture
def slurm_install_strategy(slurm_system: SlurmSystem) -> SlurmInstallStrategy:
env_vars = {"TEST_VAR": "VALUE"}
cmd_args = {"docker_image_url": {"default": "http://example.com/docker_image"}}
strategy = SlurmInstallStrategy(slurm_system, env_vars, cmd_args)
return strategy


def test_install_path_attribute(slurm_install_strategy: SlurmInstallStrategy, slurm_system: SlurmSystem):
assert slurm_install_strategy.install_path == slurm_system.install_path

0 comments on commit c97c6c6

Please sign in to comment.