Skip to content

Commit b4cdd8c

Browse files
committed
DRY common slurm args
1 parent 540de85 commit b4cdd8c

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

tests/psimulate/test_e2e.py

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ def _read_metadata(output_dir: Path) -> pd.DataFrame:
162162
return pd.read_csv(metadata_path)
163163

164164

165+
def _common_slurm_args(slurm_project: str) -> list[str]:
166+
"""Return common SLURM-related CLI arguments used across tests."""
167+
return [
168+
"-P",
169+
slurm_project,
170+
"-r",
171+
"00:03:00",
172+
"-m",
173+
"1",
174+
]
175+
176+
165177
def _run_basic_simulation(
166178
tmp_path: Path,
167179
slurm_project: str,
@@ -181,12 +193,7 @@ def _run_basic_simulation(
181193
str(_BRANCHES),
182194
"-o",
183195
str(result_dir),
184-
"-P",
185-
slurm_project,
186-
"-r",
187-
"00:03:00",
188-
"-m",
189-
"1",
196+
*_common_slurm_args(slurm_project),
190197
"-w",
191198
str(_EXPECTED_TOTAL_JOBS),
192199
]
@@ -268,12 +275,7 @@ def test_run_with_max_workers(self, shared_tmp_path: Path, slurm_project: str) -
268275
str(_BRANCHES),
269276
"-o",
270277
str(result_dir),
271-
"-P",
272-
slurm_project,
273-
"-r",
274-
"00:03:00",
275-
"-m",
276-
"1",
278+
*_common_slurm_args(slurm_project),
277279
"-w",
278280
"2", # Limit to 2 concurrent workers for 4 jobs
279281
]
@@ -318,12 +320,7 @@ def test_restart_completes_remaining(
318320
[
319321
"restart",
320322
str(output_dir),
321-
"-P",
322-
slurm_project,
323-
"-r",
324-
"00:03:00",
325-
"-m",
326-
"1",
323+
*_common_slurm_args(slurm_project),
327324
"-w",
328325
str(_EXPECTED_TOTAL_JOBS),
329326
]
@@ -365,12 +362,7 @@ def test_expand_adds_draws_and_seeds(
365362
"1",
366363
"--add-seeds",
367364
"1",
368-
"-P",
369-
slurm_project,
370-
"-r",
371-
"00:03:00",
372-
"-m",
373-
"1",
365+
*_common_slurm_args(slurm_project),
374366
"-w",
375367
str(_EXPECTED_TOTAL_JOBS),
376368
]
@@ -426,8 +418,7 @@ def test_large_results(self, shared_tmp_path: Path, slurm_project: str) -> None:
426418
str(self._NUM_WORKERS),
427419
"-o",
428420
str(result_dir),
429-
"-P",
430-
slurm_project,
421+
*_common_slurm_args(slurm_project),
431422
"-w",
432423
str(self._NUM_WORKERS),
433424
],

0 commit comments

Comments
 (0)