Skip to content

Commit

Permalink
Improve on test
Browse files Browse the repository at this point in the history
  • Loading branch information
linsword13 committed Dec 11, 2024
1 parent 8ed5c0c commit a415baa
Showing 1 changed file with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ def test_slurm_workflow():
test_config = """
ramble:
variants:
workflow_manager: slurm
workflow_manager: '{wm_name}'
variables:
# This batch_submit is overridden
batch_submit: echo cmd_not_exist
# This batch_submit is overridden with slurm workflow manager
batch_submit: echo {wm_name}
mpi_command: mpirun -n {n_ranks} -hostfile hostfile
processes_per_node: 1
wm_name: ['None', 'slurm']
applications:
hostname:
workloads:
local:
experiments:
test:
test_{wm_name}:
variables:
n_nodes: 1
extra_sbatch_headers: "#SBATCH --gpus-per-task={n_threads}"
Expand All @@ -51,7 +52,24 @@ def test_slurm_workflow():
ws._re_read()
workspace("setup", "--dry-run", global_args=["-D", ws.root])

path = os.path.join(ws.experiment_dir, "hostname", "local", "test")
# assert the batch_submit is overriden, pointing to the generated script
all_exec_file = os.path.join(ws.root, "all_experiments")
with open(all_exec_file) as f:
content = f.read()
assert "echo None" in content
assert "echo slurm" not in content
assert os.path.join("hostname", "local", "test_slurm", "batch_submit") in content

# Assert on no workflow manager
path = os.path.join(ws.experiment_dir, "hostname", "local", "test_None")
files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
assert "slurm_execute_experiment" not in files
assert "batch_submit" not in files
assert "query_job" not in files
assert "cancel_job" not in files

# Assert on slurm workflow manager
path = os.path.join(ws.experiment_dir, "hostname", "local", "test_slurm")
files = [f for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
assert "slurm_execute_experiment" in files
assert "batch_submit" in files
Expand Down

0 comments on commit a415baa

Please sign in to comment.