Skip to content
Draft
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/reference/feature-flags.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Feature flags with the `nextflow.preview` prefix can cause pipelines run with ne
: When `true`, enables the use of modules with binary scripts. See {ref}`module-binaries` for more information.

`nextflow.enable.strict`
: :::{deprecated} 26.04.0
:::
: When `true`, executes the pipeline in "strict" mode, which introduces the following rules:

- When reading a params file, Nextflow will fail if a dynamic param value references an undefined variable
Expand Down
4 changes: 4 additions & 0 deletions docs/strict-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ If you are still using DSL1, see {ref}`dsl1-page` to learn how to migrate your N
The strict syntax can be enabled in Nextflow by setting the environment variable `NXF_SYNTAX_PARSER=v2`.
:::

:::{versionchanged} 26.04.0
The strict syntax is enabled by default. It can be disabled by setting the environment variable `NXF_SYNTAX_PARSER=v1`.
:::

## Overview

The strict syntax is a subset of DSL2. While DSL2 allows any Groovy syntax, the strict syntax allows only a subset of Groovy syntax for Nextflow scripts and config files. This new specification enables more specific error reporting, ensures more consistent code, and will allow the Nextflow language to evolve independently of Groovy.
Expand Down
2 changes: 1 addition & 1 deletion modules/nextflow/src/main/groovy/nextflow/NF.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NF {
}

static String getSyntaxParserVersion() {
return SysEnv.get('NXF_SYNTAX_PARSER', 'v1')
return SysEnv.get('NXF_SYNTAX_PARSER', 'v2')
}

static boolean isSyntaxParserV2() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class ConfigDsl extends Script {

private boolean strict

private boolean stripSecrets

private Path configPath

private Map paramOverrides
Expand All @@ -66,6 +68,10 @@ class ConfigDsl extends Script {
this.strict = value
}

void setStripSecrets(boolean value) {
this.stripSecrets = value
}

void setConfigPath(Path path) {
this.configPath = path
}
Expand Down Expand Up @@ -195,6 +201,7 @@ class ConfigDsl extends Script {
.setIgnoreIncludes(ignoreIncludes)
.setRenderClosureAsString(renderClosureAsString)
.setStrict(strict)
.setStripSecrets(stripSecrets)
.setBinding(binding.getVariables())
.setParams(target.params as Map)
.setProfiles(profiles)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class ConfigParserV2 implements ConfigParser {
}

@Override
ConfigParser setStripSecrets(boolean value) {
ConfigParserV2 setStripSecrets(boolean value) {
this.stripSecrets = value
return this
}
Expand Down Expand Up @@ -127,9 +127,11 @@ class ConfigParserV2 implements ConfigParser {
if( path )
script.setConfigPath(path)
script.setIgnoreIncludes(ignoreIncludes)
script.setRenderClosureAsString(renderClosureAsString)
script.setStrict(strict)
script.setStripSecrets(stripSecrets)
script.setParams(paramOverrides)
script.setProfiles(appliedProfiles)
script.setRenderClosureAsString(renderClosureAsString)
script.run()

final target = script.getTarget()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,12 @@ abstract class BaseScript extends Script implements ExecutionContext {

private Session session

private ProcessFactory processFactory

private ScriptMeta meta

private WorkflowDef entryFlow

private OutputDef publisher

@Lazy InputStream stdin = { System.in }()

BaseScript() {
meta = ScriptMeta.register(this)
}
Expand Down Expand Up @@ -90,7 +86,6 @@ abstract class BaseScript extends Script implements ExecutionContext {
private void setup() {
binding.owner = this
session = binding.getSession()
processFactory = session.newProcessFactory(this)

binding.setVariable( 'baseDir', session.baseDir )
binding.setVariable( 'projectDir', session.baseDir )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ class BaseScriptConsts {

public static Object[] EMPTY_ARGS = [] as Object[]

public static List<String> PRIVATE_NAMES = ['session','processFactory','taskProcessor','meta','entryFlow', 'publisher']
public static List<String> PRIVATE_NAMES = ['session','meta','entryFlow', 'publisher']
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,17 @@ class WorkflowDef extends BindableDef implements ChainableDef, IterableDef, Exec

private Object run0(Object[] args) {
collectInputs(binding, args)
// invoke the workflow execution
final closure = body.closure
closure.setDelegate(binding)
closure.setResolveStrategy(Closure.DELEGATE_FIRST)
closure.call()
// collect the workflow outputs
output = collectOutputs(declaredOutputs)
return output
final result = closure.call()
if( name == null ) {
return result
}
else {
output = collectOutputs(declaredOutputs)
return output
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class ScriptLoaderV2 implements ScriptLoader {

private boolean skipEntryFlow

private Object result

ScriptLoaderV2(Session session) {
this.session = session
}
Expand Down Expand Up @@ -69,7 +71,9 @@ class ScriptLoaderV2 implements ScriptLoader {
}

@Override
Object getResult() { null }
Object getResult() {
return result
}

@Override
ScriptLoaderV2 parse(Path scriptPath) {
Expand All @@ -83,14 +87,15 @@ class ScriptLoaderV2 implements ScriptLoader {
}

ScriptLoaderV2 parse(String scriptText) {
return parse0(scriptText, null)
parse0(scriptText, null)
return this
}

@Override
ScriptLoaderV2 runScript() {
assert session
assert mainScript
mainScript.run()
this.result = mainScript.run()
return this
}

Expand All @@ -104,17 +109,17 @@ class ScriptLoaderV2 implements ScriptLoader {
private void parse0(String scriptText, Path scriptPath) {
final compiler = getCompiler()
try {
final result = scriptPath
final compileResult = scriptPath
? compiler.compile(scriptPath.toFile())
: compiler.compile(scriptText)

mainScript = createScript(result.main(), session.binding, scriptPath, skipEntryFlow)
this.mainScript = createScript(compileResult.main(), session.binding, scriptPath, skipEntryFlow)

result.modules().forEach((path, clazz) -> {
compileResult.modules().forEach((path, clazz) -> {
createScript(clazz, new ScriptBinding(), path, true)
})

for( final name : result.processNames() )
for( final name : compileResult.processNames() )
ScriptMeta.addResolvedName(name)
}
catch( CompilationFailedException e ) {
Expand Down
Loading
Loading