Skip to content

Commit

Permalink
Add 'preview' to workflow runtime metadata (#4985)
Browse files Browse the repository at this point in the history

Signed-off-by: Aaron Greenberg <[email protected]>
Signed-off-by: Paolo Di Tommaso <[email protected]>
Co-authored-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
greenberga and pditommaso authored May 16, 2024
1 parent c72e16f commit 935bb1e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ The following table lists the properties that can be accessed on the `workflow`
`workflow.manifest`
: Entries of the workflow manifest.

`workflow.preview`
: :::{versionadded} 24.04.0
:::
: Returns `true` whenever the current instance is a preview execution.

`workflow.profile`
: Used configuration profile.

Expand Down
8 changes: 8 additions & 0 deletions modules/nextflow/src/main/groovy/nextflow/Session.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ class Session implements ISession {
*/
boolean stubRun

/**
* Enable preview mode
*/
boolean preview

/**
* Folder(s) containing libs and classes to be added to the classpath
*/
Expand Down Expand Up @@ -345,6 +350,9 @@ class Session implements ISession {
// -- dry run
this.stubRun = config.stubRun

// -- preview
this.preview = config.preview

// -- normalize taskConfig object
if( config.process == null ) config.process = [:]
if( config.env == null ) config.env = [:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ class ConfigBuilder {
if( cmdRun.stubRun )
config.stubRun = cmdRun.stubRun

if( cmdRun.preview )
config.preview = cmdRun.preview

// -- sets the working directory
if( cmdRun.workDir )
config.workDir = cmdRun.workDir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ class WorkflowMetadata {
*/
boolean stubRun

/**
* Returns ``true`` whenever the current instance is in preview mode
*/
boolean preview

/**
* Which container engine was used to execute the workflow
*/
Expand Down Expand Up @@ -253,6 +258,7 @@ class WorkflowMetadata {
this.sessionId = session.uniqueId
this.resume = session.resumeMode
this.stubRun = session.stubRun
this.preview = session.preview
this.runName = session.runName
this.containerEngine = containerEngine0(session)
this.configFiles = session.configFiles?.collect { it.toAbsolutePath() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,22 @@ class ConfigBuilderTest extends Specification {
then:
config.stubRun == true
}


def 'should configure preview mode' () {
given:
Map config

when:
config = new ConfigBuilder().setCmdRun(new CmdRun()).build()
then:
!config.preview

when:
config = new ConfigBuilder().setCmdRun(new CmdRun(preview: true)).build()
then:
config.preview == true
}

def 'should merge profiles' () {
given:
def ENV = [:]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class WorkflowMetadataTest extends Specification {
metadata.configFiles == [Paths.get('foo').toAbsolutePath(), Paths.get('bar').toAbsolutePath()]
metadata.resume == false
metadata.stubRun == false
metadata.preview == false
metadata.userName == System.getProperty('user.name')
metadata.homeDir == Paths.get(System.getProperty('user.home'))
metadata.manifest.version == '1.0.0'
Expand All @@ -114,11 +115,13 @@ class WorkflowMetadataTest extends Specification {
session.profile >> 'foo_profile'
session.resumeMode >> true
session.stubRun >> true
session.preview >> true
metadata = new WorkflowMetadata(session, script)
then:
metadata.profile == 'foo_profile'
metadata.resume
metadata.stubRun
metadata.preview
}

def foo_test_method() {
Expand Down

0 comments on commit 935bb1e

Please sign in to comment.