Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'preview' to workflow runtime metadata #4985

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
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