From 939d5b59adf4f6488af30e91f23cd5c5b85e182b Mon Sep 17 00:00:00 2001 From: Hendrik Cannoodt Date: Tue, 10 Oct 2023 06:14:33 +0200 Subject: [PATCH] Refactor the nextflow code to handle the auto.publish as a string --- src/main/resources/io/viash/platforms/nextflow/VDSL3Helper.nf | 2 +- .../io/viash/platforms/nextflow/workflowFactory/processAuto.nf | 3 ++- .../platforms/nextflow/workflowFactory/processWorkflowArgs.nf | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/resources/io/viash/platforms/nextflow/VDSL3Helper.nf b/src/main/resources/io/viash/platforms/nextflow/VDSL3Helper.nf index b774bfffb..b4cafea64 100644 --- a/src/main/resources/io/viash/platforms/nextflow/VDSL3Helper.nf +++ b/src/main/resources/io/viash/platforms/nextflow/VDSL3Helper.nf @@ -240,7 +240,7 @@ def _vdsl3ProcessFactory(Map workflowArgs, Map meta, String rawScript) { def escapedScript = rawScript.replace('\\', '\\\\').replace('$', '\\$').replace('"""', '\\"\\"\\"') // publishdir assert - def assertStr = (workflowArgs.auto.publish == true) || workflowArgs.auto.transcript ? + def assertStr = (workflowArgs.auto.publish == "true") || workflowArgs.auto.transcript ? """\nassert task.publishDir.size() > 0: "if auto.publish is true, params.publish_dir needs to be defined.\\n Example: --publish_dir './output/'" """ : "" diff --git a/src/main/resources/io/viash/platforms/nextflow/workflowFactory/processAuto.nf b/src/main/resources/io/viash/platforms/nextflow/workflowFactory/processAuto.nf index adf243a18..603888d59 100644 --- a/src/main/resources/io/viash/platforms/nextflow/workflowFactory/processAuto.nf +++ b/src/main/resources/io/viash/platforms/nextflow/workflowFactory/processAuto.nf @@ -18,7 +18,8 @@ def processAuto(Map auto) { assert auto.transcript instanceof Boolean, "auto.transcript must be a boolean" // check auto.publish - assert auto.publish instanceof Boolean || auto.publish == "state", "auto.publish must be a boolean or 'state'" + assert auto.publish instanceof CharSequence + assert auto.publish in ["true", "false", "state"], "auto.publish must be 'true', 'false', or 'state'" return auto.subMap(expectedKeys) } diff --git a/src/main/resources/io/viash/platforms/nextflow/workflowFactory/processWorkflowArgs.nf b/src/main/resources/io/viash/platforms/nextflow/workflowFactory/processWorkflowArgs.nf index 9b1719665..404233c39 100644 --- a/src/main/resources/io/viash/platforms/nextflow/workflowFactory/processWorkflowArgs.nf +++ b/src/main/resources/io/viash/platforms/nextflow/workflowFactory/processWorkflowArgs.nf @@ -29,7 +29,7 @@ def processWorkflowArgs(Map args, Map defaultWfArgs, Map meta) { workflowArgs["auto"] = processAuto(defaultWfArgs.auto + workflowArgs["auto"]) // auto define publish, if so desired - if (workflowArgs.auto.publish == true && (workflowArgs.directives.publishDir != null ? workflowArgs.directives.publishDir : [:]).isEmpty()) { + if (workflowArgs.auto.publish == "true" && (workflowArgs.directives.publishDir != null ? workflowArgs.directives.publishDir : [:]).isEmpty()) { // can't assert at this level thanks to the no_publish profile // assert params.containsKey("publishDir") || params.containsKey("publish_dir") : // "Error in module '${workflowArgs['key']}': if auto.publish is true, params.publish_dir needs to be defined.\n" +