Skip to content

Commit 0b513cc

Browse files
committed
Address review comments
1 parent 0ab0ef0 commit 0b513cc

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/cloudai/systems/slurm/slurm_command_gen_strategy.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ def __init__(self, system: System, test_run: TestRun) -> None:
5151
self.test_run = test_run
5252

5353
self._node_spec_cache: dict[str, tuple[int, list[str]]] = {}
54+
55+
@property
56+
def nodelist_in_use(self) -> bool:
5457
_, nodes = self.get_cached_nodes_spec()
55-
self._nodelist_in_use: bool = len(nodes) > 0
58+
return len(nodes) > 0
5659

5760
@abstractmethod
5861
def _container_mounts(self) -> list[str]:
@@ -242,7 +245,7 @@ def image_path(self) -> Optional[str]:
242245
def gen_srun_prefix(self, use_pretest_extras: bool = False, with_num_nodes: bool = True) -> List[str]:
243246
num_nodes, _ = self.get_cached_nodes_spec()
244247
srun_command_parts = ["srun", "--export=ALL", f"--mpi={self.system.mpi}"]
245-
if with_num_nodes and not self._nodelist_in_use:
248+
if with_num_nodes and not self.nodelist_in_use:
246249
srun_command_parts.append(f"-N{num_nodes}")
247250
if use_pretest_extras and self.test_run.pre_test:
248251
for pre_tr in self.test_run.pre_test.test_runs:

tests/test_slurm_system.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,10 +437,10 @@ def test_per_test_isolation(self, mock_get_nodes: Mock, slurm_system: SlurmSyste
437437
ConcreteSlurmStrategy(slurm_system, test_run),
438438
)
439439

440-
assert mock_get_nodes.call_count == 2 # one call per strategy initialization
440+
assert mock_get_nodes.call_count == 0
441441

442442
res = strategy1.get_cached_nodes_spec()
443-
assert mock_get_nodes.call_count == 2
443+
assert mock_get_nodes.call_count == 1
444444
assert res == (2, ["node01", "node02"])
445445

446446
res = strategy2.get_cached_nodes_spec()

0 commit comments

Comments
 (0)