diff --git a/docs/reference/cli.md b/docs/reference/cli.md index c030df46bb..5f5fa077d3 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -1072,6 +1072,11 @@ The `run` command is used to execute a local pipeline script or remote pipeline `-disable-jobs-cancellation` : Prevent the cancellation of child jobs on execution termination +`-dry` +: :::{versionadded} 25.10.0 + ::: +: Print the tasks that will be executed, then exit without executing any tasks. Can be combined with `-resume` to test how much a previous run can be resumed. + `-dsl1` : :::{deprecated} 23.09.0-edge ::: diff --git a/modules/nextflow/src/main/groovy/nextflow/Session.groovy b/modules/nextflow/src/main/groovy/nextflow/Session.groovy index d45f26c528..75ffd3b4e7 100644 --- a/modules/nextflow/src/main/groovy/nextflow/Session.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/Session.groovy @@ -128,6 +128,11 @@ class Session implements ISession { */ boolean resumeMode + /** + * whenever it has been launched as a dry run + */ + boolean dryRun + /** * The folder where workflow outputs are stored */ @@ -363,11 +368,14 @@ class Session implements ISession { } log.debug "Session UUID: $uniqueId" + // -- dry run + this.dryRun = config.dryRun + // -- set the run name this.runName = config.runName ?: NameGenerator.next() log.debug "Run name: $runName" - // -- dry run + // -- stub run this.stubRun = config.stubRun // -- preview diff --git a/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy b/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy index d096e678e6..457ace9344 100644 --- a/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy @@ -97,6 +97,9 @@ class CmdRun extends CmdBase implements HubOptions { @Parameter(names=['-resume'], description = 'Execute the script using the cached results, useful to continue executions that was stopped by an error') String resume + @Parameter(names=['-dry'], description = 'Print the tasks that will be executed, then exit without executing any tasks') + boolean dryRun + @Parameter(names=['-ps','-pool-size'], description = 'Number of threads in the execution pool', hidden = true) Integer poolSize diff --git a/modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy b/modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy index 0341f73523..5add54ea79 100644 --- a/modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy @@ -601,6 +601,11 @@ class ConfigBuilder { if( cmdRun.resume ) config.resume = cmdRun.resume + // -- sets the dry run option + if( cmdRun.dryRun ) { + config.dryRun = cmdRun.dryRun + } + if( config.isSet('resume') ) config.resume = normalizeResumeId(config.resume as String) diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy index c4860deaeb..c619cd9053 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy @@ -72,6 +72,7 @@ import nextflow.executor.CachedTaskHandler import nextflow.executor.Executor import nextflow.executor.StoredTaskHandler import nextflow.extension.CH +import nextflow.extension.ChannelEx import nextflow.extension.DataflowHelper import nextflow.file.FileHelper import nextflow.file.FileHolder @@ -825,6 +826,12 @@ class TaskProcessor { continue } + if( session.dryRun ) { + log.info "[DRY RUN] execute task > ${safeTaskName(task)} [${hash}]" + ChannelEx.update(state) { StateObj it -> it.incCompleted() } + break + } + final lock = lockManager.acquire(hash) final workDir = task.getWorkDirFor(hash) try {