Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion hpcflow/sdk/submission/schedulers/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions hpcflow/tests/data/workflow_2_slurm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
template_components:
task_schemas:
- objective: locate_bash
outputs:
- parameter: bash_location
actions:
- commands:
- command: which bash
stdout: <<parameter:bash_location>>
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
26 changes: 26 additions & 0 deletions hpcflow/tests/schedulers/slurm/test_slurm_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"