-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit tries to determine the use of DSL1 if the explict setting 'nextflow.enable.dsl' has not been provided in the nextflow config or script file. When the use of DSL1 cannot be inferred, it looks for the DSL mode specified via the env variable NXF_DEFAULT_DSL. If the env variable is found it finally defaults to DSL2. Signed-off-by: Paolo Di Tommaso <[email protected]>
- Loading branch information
1 parent
da101e8
commit 1f836f8
Showing
8 changed files
with
260 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,11 @@ package nextflow | |
import java.text.SimpleDateFormat | ||
import java.util.regex.Pattern | ||
|
||
import groovy.transform.CompileStatic | ||
import groovy.transform.EqualsAndHashCode | ||
import groovy.transform.ToString | ||
import groovy.util.logging.Slf4j | ||
import nextflow.exception.AbortOperationException | ||
import nextflow.util.VersionNumber | ||
import static nextflow.extension.Bolts.DATETIME_FORMAT | ||
|
||
|
@@ -14,13 +16,18 @@ import static nextflow.extension.Bolts.DATETIME_FORMAT | |
* | ||
* @author Paolo Di Tommaso <[email protected]> | ||
*/ | ||
@CompileStatic | ||
@Singleton(strict = false) | ||
@ToString(includeNames = true) | ||
@EqualsAndHashCode | ||
class NextflowMeta { | ||
|
||
private static final Pattern DSL_DECLARATION = ~/(?m)^\s*(nextflow\.(preview|enable)\.dsl\s*=\s*(\d))\s*(;?\s*)?(;?\/{2}.*)?$/ | ||
|
||
private static final Pattern DSL1_INPUT = ~/(?m)input:\s*(tuple|file|path|val|env|stdin)\b.*\s.*\bfrom\b.+$/ | ||
private static final Pattern DSL1_OUTPUT = ~/(?m)output:\s*(tuple|file|path|val|env|stdout)\b.*\s.*\binto\b.+$/ | ||
private static final Pattern DSL2_WORKFLOW = ~/\s+workflow\b.*\s*\{(\n|\r|.)*}/ | ||
|
||
private static boolean ignoreWarnDsl2 = System.getenv('NXF_IGNORE_WARN_DSL2')=='true' | ||
|
||
static trait Flags { | ||
|
@@ -114,7 +121,7 @@ class NextflowMeta { | |
* {@code true} when the workflow script uses DSL2 syntax, {@code false} otherwise. | ||
*/ | ||
boolean isDsl2() { | ||
enable.dsl == 2 | ||
enable.dsl == 2f | ||
} | ||
|
||
/** | ||
|
@@ -125,15 +132,22 @@ class NextflowMeta { | |
*/ | ||
@Deprecated | ||
boolean isDsl2Final() { | ||
enable.dsl == 2 | ||
enable.dsl == 2f | ||
} | ||
|
||
void enableDsl2() { | ||
this.enable.dsl = 2 | ||
this.enable.dsl = 2f | ||
} | ||
|
||
void disableDsl2() { | ||
enable.dsl = 1 | ||
enable.dsl = 1f | ||
} | ||
|
||
void enableDsl(String value) { | ||
if( value !in ['1','2'] ) { | ||
throw new AbortOperationException("Invalid Nextflow DSL value: $value") | ||
} | ||
this.enable.dsl = value=='1' ? 1f : 2f | ||
} | ||
|
||
boolean isStrictModeEnabled() { | ||
|
@@ -144,23 +158,25 @@ class NextflowMeta { | |
enable.strict = mode | ||
} | ||
|
||
void checkDsl2Mode(String script) { | ||
static String checkDslMode(String script) { | ||
final matcher = DSL_DECLARATION.matcher(script) | ||
final mode = matcher.find() ? matcher.group(2) : null | ||
if( !mode ) | ||
return | ||
return null | ||
final ver = matcher.group(3) | ||
if( mode == 'enable' ) { | ||
if( ver=='2' ) | ||
enableDsl2() | ||
else if( ver=='1' ) | ||
disableDsl2() | ||
else | ||
throw new IllegalArgumentException("Unknown nextflow DSL version: ${ver}") | ||
return ver | ||
} | ||
else if( mode == 'preview' ) | ||
throw new IllegalArgumentException("Preview nextflow mode 'preview' is not supported anymore -- Please use `nextflow.enable.dsl=2` instead") | ||
else | ||
throw new IllegalArgumentException("Unknown nextflow mode=${matcher.group(1)}") | ||
} | ||
|
||
static boolean probeDls1(String script) { | ||
boolean hasDsl1Input = DSL1_INPUT.matcher(script).find() | ||
boolean hasDsl1Output = DSL1_OUTPUT.matcher(script).find() | ||
boolean hasWorkflowDef = DSL2_WORKFLOW.matcher(script).find() | ||
return (hasDsl1Input || hasDsl1Output) && !hasWorkflowDef | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.