diff --git a/hpcflow/sdk/submission/schedulers/slurm.py b/hpcflow/sdk/submission/schedulers/slurm.py index e6a4f4b0..2fa5f589 100644 --- a/hpcflow/sdk/submission/schedulers/slurm.py +++ b/hpcflow/sdk/submission/schedulers/slurm.py @@ -284,7 +284,8 @@ def __is_present_supported( Test if information is present on both sides, and also matches. """ return bool( - num_req and part_have and cls.is_num_cores_supported(num_req, part_have) + num_req is None + or (part_have and cls.is_num_cores_supported(num_req, part_have)) ) @classmethod diff --git a/hpcflow/tests/data/workflow_2_slurm.yaml b/hpcflow/tests/data/workflow_2_slurm.yaml new file mode 100644 index 00000000..011dda1c --- /dev/null +++ b/hpcflow/tests/data/workflow_2_slurm.yaml @@ -0,0 +1,24 @@ +template_components: + task_schemas: + - objective: locate_bash + outputs: + - parameter: bash_location + actions: + - commands: + - command: which bash + stdout: <> + environments: + - scope: + type: any + environment: null_env + +tasks: +- schema: locate_bash + +resources: + any: + scheduler_args: + directives: + --time: 00:30:00 +# --partition: serial + num_cores: 1 diff --git a/hpcflow/tests/schedulers/slurm/test_slurm_submission.py b/hpcflow/tests/schedulers/slurm/test_slurm_submission.py index 117fea0e..d0cc329d 100644 --- a/hpcflow/tests/schedulers/slurm/test_slurm_submission.py +++ b/hpcflow/tests/schedulers/slurm/test_slurm_submission.py @@ -12,3 +12,29 @@ def test_workflow_1(tmp_path: Path, null_config): p2 = wk.tasks[0].elements[0].outputs.p2 assert isinstance(p2, hf.ElementParameter) assert p2.value == "201" + + +@pytest.mark.slurm +def test_workflow_2(tmp_path: Path, null_config): + hf.config.add_scheduler("slurm") + wk = make_test_data_YAML_workflow("workflow_2_slurm.yaml", path=tmp_path) + wk.submit(wait=True, add_to_known=False) + bash_location = wk.tasks[0].elements[0].outputs.bash_location + assert isinstance(bash_location, hf.ElementParameter) + assert "bash" in bash_location.value + + +def test_slurm_partition_select(): + slurm = hf.SlurmPosix() + resources = hf.ElementResources() + config = { + "partitions": { + "serial": { + "num_nodes": [1, 1, 1], + "num_cores": [1, 1, 1], + "num_cores_per_node": [1, 1, 1], + } + } + } + slurm.process_resources(resources, config) + assert resources.SLURM_partition == "serial"