reanahub / reana-workflow-engine-snakemake

REANA Workflow Engine Snakemake
MIT License
0 stars 22 forks source link

allow parameters to be optional #55

Closed tiborsimko closed 1 year ago

tiborsimko commented 1 year ago

Current behaviour

Consider the reana-demo-helloworld demo example, but with hard-coded values:

diff --git a/workflow/snakemake/Snakefile b/workflow/snakemake/Snakefile
index e7344f2..fc8e3a9 100644
--- a/workflow/snakemake/Snakefile
+++ b/workflow/snakemake/Snakefile
@@ -19,10 +19,8 @@ rule all:

 rule helloworld:
     input:
-        helloworld=config["helloworld"],
-        inputfile=config["inputfile"],
-    params:
-        sleeptime=config["sleeptime"]
+        helloworld="code/helloworld.py",
+        inputfile="data/names.txt",
     output:
         "results/greetings.txt"
     container:
@@ -31,4 +29,4 @@ rule helloworld:
         "python {input.helloworld} "
         "--inputfile {input.inputfile} "
         "--outputfile {output} "
-        "--sleeptime {params.sleeptime}"
+        "--sleeptime 0"
diff --git a/workflow/snakemake/inputs.yaml b/workflow/snakemake/inputs.yaml
index 0a507cc..20e9ff3 100644
--- a/workflow/snakemake/inputs.yaml
+++ b/workflow/snakemake/inputs.yaml
@@ -1,3 +1 @@
-sleeptime: 0
-helloworld: code/helloworld.py
-inputfile: data/names.txt
+foo: bar

If you run the workflow:

$ reana-dev run-example -c r-d-helloworld -w snakemake

then everything works.

However, not that inputs.yaml is not really necessary in this case. If I try to remove it:

diff --git a/reana-snakemake.yaml b/reana-snakemake.yaml
index 49cb624..3531372 100644
--- a/reana-snakemake.yaml
+++ b/reana-snakemake.yaml
@@ -5,8 +5,6 @@ inputs:
     - data/names.txt
   directories:
     - workflow/snakemake
-  parameters:
-    input: workflow/snakemake/inputs.yaml
 workflow:
   type: snakemake
   file: workflow/snakemake/Snakefile

then things break and the workflow cannot be submitted:

$ reana-dev run-example -c r-d-helloworld -w snakemake
...
[WARNING] Job stats:
job           count    min threads    max threads
----------  -------  -------------  -------------
all               1              1              1
helloworld        1              1              1
total             2              1              1

==> ERROR: Cannot create workflow helloworld-snakemake-kubernetes:
'parameters'

Expected behaviour

If a workflow does not need parameters, then we should allow its submission.

It may be good to make the "parameters" property optional for those workflows that do not really require it.