Skip to content

Commit

Permalink
Merge pull request #83 from Snakemake-Profiles/resources-partition
Browse files Browse the repository at this point in the history
Test resources partition key
  • Loading branch information
percyfal authored Feb 17, 2022
2 parents fd355d9 + bb498c4 commit 8838d43
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,16 @@ Resources specified in Snakefiles must all be in the correct
unit/format as expected by `sbatch`. The implemented resource names
are given (and may be adjusted) in the `slurm_utils.RESOURCE_MAPPING`
global. This is intended for system agnostic resources such as time
and memory.
and memory. Currently supported resources are `time`, `mem`,
`mem-per-cpu`, `nodes`, and `partition`. An example rule resources
configuration follows:

rule bwa_mem:
resources:
time = "00:10:00",
mem = 12000,
partition = "debug"


### Advanced argument conversion (EXPERIMENTAL)
By default, Snakefile resources are provided as-is to the sbatch
Expand Down
13 changes: 13 additions & 0 deletions tests/Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ rule wildcard_job:
rule simemory:
output: "siunit.txt"
shell: "touch {output}"


rule set_partition_in_cc:
output: "partition.cc.txt"
shell:
"echo {resources} > {output}"

rule set_partition_in_resources:
output: "partition.resources.txt"
resources:
partition = "debug"
shell:
"echo {resources} > {output}"
3 changes: 3 additions & 0 deletions tests/cluster-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ short_queue:

simemory:
mem: 1G

set_partition_in_cc:
partition: debug
8 changes: 8 additions & 0 deletions tests/test_slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,11 @@ def test_si_units(smk_runner, profile):
)
assert "Memory specification can not be satisfied" in smk_runner.output
assert "--mem=1000" in smk_runner.output


@pytest.mark.parametrize("cluster_config", [True, False])
def test_partition(smk_runner, profile, cluster_config):
options = f"--cluster-config {smk_runner.cluster_config}" if cluster_config else ""
target = "partition.cc.txt" if cluster_config else "partition.resources.txt"
smk_runner.make_target(target, options=options, stream=False)
assert smk_runner.check_jobstatus("debug", "-n -o Partition")

0 comments on commit 8838d43

Please sign in to comment.