Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,8 @@ the :ref:`k8s-page` section.
+---------------------------+-------------+--------------------------------------------------------------------------------+
| -pod-image | | Specify the container image for the Nextflow pod. |
+---------------------------+-------------+--------------------------------------------------------------------------------+
| -preview | | Run the workflow script skipping the execution of all processes |
+---------------------------+-------------+--------------------------------------------------------------------------------+
| -process. | {} | Set process options. Syntax ``-process.key=value`` |
+---------------------------+-------------+--------------------------------------------------------------------------------+
| -profile | | Choose a configuration profile. |
Expand Down
24 changes: 18 additions & 6 deletions modules/nextflow/src/main/groovy/nextflow/Session.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ class Session implements ISession {

boolean disableJobsCancellation

boolean dryRun

AnsiLogObserver ansiLogObserver

FilePorter getFilePorter() { filePorter }
Expand Down Expand Up @@ -447,16 +449,26 @@ class Session implements ISession {
igniters.add(action)
}

void fireDataflowNetwork() {
void fireDataflowNetwork(boolean dryRun=false) {
checkConfig()
notifyFlowBegin()

if( !NextflowMeta.instance.isDsl2() )
if( !NextflowMeta.instance.isDsl2() ) {
return
}

// bridge any dataflow queue into a broadcast channel
CH.broadcast()

if( dryRun ) {
terminated = true
}
else {
callIgniters()
}
}

private void callIgniters() {
log.debug "Ignite dataflow network (${igniters.size()})"
for( Closure action : igniters ) {
try {
Expand Down Expand Up @@ -611,15 +623,15 @@ class Session implements ISession {
terminated = true
monitorsBarrier.awaitCompletion()
log.debug "Session await > all barriers passed"
if( !aborted ) {
joinAllOperators()
log.trace "Session > after processors join"
}
}

void destroy() {
try {
log.trace "Session > destroying"
if( !aborted ) {
joinAllOperators()
log.trace "Session > after processors join"
}

// invoke shutdown callbacks
shutdown0()
Expand Down
10 changes: 7 additions & 3 deletions modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ class CmdRun extends CmdBase implements HubOptions {
@Parameter(names=['-stub-run','-stub'], description = 'Execute the workflow replacing process scripts with command stubs')
boolean stubRun

@Parameter(names=['-preview'], description = "Run the workflow script skipping the execution of all processes")
boolean preview

@Parameter(names=['-plugins'], description = 'Specify the plugins to be applied for this run e.g. nf-amazon,nf-tower')
String plugins

Expand Down Expand Up @@ -309,6 +312,7 @@ class CmdRun extends CmdBase implements HubOptions {
// -- create a new runner instance
final runner = new ScriptRunner(config)
runner.setScript(scriptFile)
runner.setDryRun(this.preview)
runner.session.profile = profile
runner.session.commandLine = launcher.cliString
runner.session.ansiLog = launcher.options.ansiLog
Expand Down Expand Up @@ -350,11 +354,11 @@ class CmdRun extends CmdBase implements HubOptions {
NextflowMeta.instance.enableDsl(dsl)
// -- show launch info
final ver = NF.dsl2 ? DSL2 : DSL1
final head = preview ? "* PREVIEW * $scriptFile.repository" : "Launching `$scriptFile.repository`"
if( scriptFile.repository )
log.info "Launching `$scriptFile.repository` [$runName] DSL${ver} - revision: ${scriptFile.revisionInfo}"
log.info "${head} [$runName] DSL${ver} - revision: ${scriptFile.revisionInfo}"
else
log.info "Launching `$scriptFile.source` [$runName] DSL${ver} - revision: ${scriptFile.getScriptId()?.substring(0,10)}"

log.info "${head} [$runName] DSL${ver} - revision: ${scriptFile.getScriptId()?.substring(0,10)}"
}

static String detectDslMode(ConfigMap config, String scriptText, Map sysEnv) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ class ScriptRunner {
*/
private def result

/**
* Simulate execution and exit
*/
private boolean dryRun

/**
* Instantiate the runner object creating a new session
*/
Expand All @@ -81,6 +86,11 @@ class ScriptRunner {
return this
}

ScriptRunner setDryRun( boolean value ) {
this.dryRun = value
return this
}

Session getSession() { session }

/**
Expand Down Expand Up @@ -118,8 +128,10 @@ class ScriptRunner {
parseScript(scriptFile, entryName)
// run the code
run()
// await termination
terminate()
// await completion
await()
// shutdown session
shutdown()
}
catch (Throwable e) {
session.abort(e)
Expand Down Expand Up @@ -213,12 +225,17 @@ class ScriptRunner {
// -- normalise output
result = normalizeOutput(scriptParser.getResult())
// -- ignite dataflow network
session.fireDataflowNetwork()
session.fireDataflowNetwork(dryRun)
}

protected terminate() {
protected await() {
if( dryRun )
return
log.debug "> Await termination "
session.await()
}

protected shutdown() {
session.destroy()
session.cleanup()
log.debug "> Execution complete -- Goodbye"
Expand Down