From 2564dc3619768231604f5b5f75a17df7a6f327b7 Mon Sep 17 00:00:00 2001 From: Andrew Reid Date: Mon, 23 Oct 2023 10:38:18 -0400 Subject: [PATCH 1/2] Draft cluster snakefile stuff. The "Snakefile_cluster_iteration" file manages the list of widths, and can iterate over jobs on the cluster and then do a (trivial) aggregation step. The queuing_config.yaml file is a short cluster config that removes the need to type the cluster stuff into the command line. It conventionally goes in $HOME/.config/snakemake/queuing/config.yaml, and is accessed by "snakemake --profile=queuing". The Snakefile has mpi stuff for the trivial aggregation rule because the cluster-ness of it applies to all the rules. This is clumsy, but not wrong. --- episodes/files/Snakefile_cluster_iteration | 24 ++++++++++++++++++++++ episodes/files/queuing_config.yaml | 6 ++++++ 2 files changed, 30 insertions(+) create mode 100644 episodes/files/Snakefile_cluster_iteration create mode 100644 episodes/files/queuing_config.yaml diff --git a/episodes/files/Snakefile_cluster_iteration b/episodes/files/Snakefile_cluster_iteration new file mode 100644 index 0000000..41a94a2 --- /dev/null +++ b/episodes/files/Snakefile_cluster_iteration @@ -0,0 +1,24 @@ +# +# Run a bunch of Amdahl jobs and aggregate the output. +# +WIDTHS=[1,2] +# +def getwidth(wildcards): + return wildcards.sample + +rule plot: + input: expand('{size}.out',size=WIDTHS) + output: 'done.out' + resources: + mpi="mpirun", + tasks=1 + shell: 'echo "{WIDTHS}, Done!" > done.out' +rule iterate: + input: + output: '{sample}.out' + resources: + mpi="mpirun", + tasks=getwidth + shell: + "module load OpenMPI; mpirun -np {resources.tasks} amdahl > {wildcards.sample}.out" + diff --git a/episodes/files/queuing_config.yaml b/episodes/files/queuing_config.yaml new file mode 100644 index 0000000..7db5043 --- /dev/null +++ b/episodes/files/queuing_config.yaml @@ -0,0 +1,6 @@ +# snakemake -j 3 --cluster "sbatch -N 1 -n {resources.tasks} -p node" +cluster: + sbatch + --partition=node + --nodes=1 + --tasks={resources.tasks} From 3cb2dfbd0a1e8c706c6923e725201bd0fea3abce Mon Sep 17 00:00:00 2001 From: Andrew Reid Date: Wed, 20 Dec 2023 11:02:50 -0500 Subject: [PATCH 2/2] Adding an iterative snakefile. No cluster shenanigans in this one, just straight-up iteration, maybe a useful intermediate step. --- episodes/files/Snakefile_iterative | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 episodes/files/Snakefile_iterative diff --git a/episodes/files/Snakefile_iterative b/episodes/files/Snakefile_iterative new file mode 100644 index 0000000..8fe13f8 --- /dev/null +++ b/episodes/files/Snakefile_iterative @@ -0,0 +1,13 @@ +# +# Iterative example. +# +NAMES=['one','two','three'] +# +rule done: + input: expand('{name}.out',name=NAMES) + output: 'done.out' + shell: 'echo "Done!" > done.out' +rule iterate: + input: + output: '{sample}.out' + shell: 'echo {output} > {output}'