Skip to content

Commit

Permalink
Deprecate isDsl2Final method
Browse files Browse the repository at this point in the history
As DSL2 *preview* mode is not supported any more
the semantic for 'isDsl2' and 'isDsl2Final' is identical.

This commit remove the use of the latter and mark it as
deprecated since it's not needed anymore.

Signed-off-by: Paolo Di Tommaso <paolo.ditommaso@gmail.com>
  • Loading branch information
pditommaso committed Apr 23, 2022
1 parent ae7ba35 commit 0f63f1a
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 39 deletions.
1 change: 1 addition & 0 deletions modules/nextflow/src/main/groovy/nextflow/NF.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class NF {
NextflowMeta.instance.isDsl2()
}

@Deprecated
static boolean isDsl2Final() {
NextflowMeta.instance.isDsl2Final()
}
Expand Down
12 changes: 12 additions & 0 deletions modules/nextflow/src/main/groovy/nextflow/NextflowMeta.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,22 @@ class NextflowMeta {
fmt.parse(str)
}

/**
* Determine if the workflow script uses DSL2 mode
*
* {@code true} when the workflow script uses DSL2 syntax, {@code false} otherwise.
*/
boolean isDsl2() {
enable.dsl == 2
}

/**
* As of the removal of DSL2 preview mode, the semantic of this method
* is identical to {@link #isDsl2()}.
* @return
* {@code true} when the workflow script uses DSL2 syntax, {@code false} otherwise.
*/
@Deprecated
boolean isDsl2Final() {
enable.dsl == 2
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ class NextflowDSLImpl implements ASTTransformation {
}
}
}
else if( (varX=isVariableX(stm.expression)) && (varX.name=='stdin' || varX.name=='stdout') && NF.isDsl2Final() ) {
else if( (varX=isVariableX(stm.expression)) && (varX.name=='stdin' || varX.name=='stdout') && NF.isDsl2() ) {
final name = varX.name=='stdin' ? '_in_stdin' : '_out_stdout'
final call = new MethodCallExpression( new VariableExpression('this'), name, new ArgumentListExpression() )
// remove replace the old one with the new one
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,20 +323,14 @@ class OpCall implements Callable {
protected void checkDeprecation(Method method) {
if( method.getAnnotation(Deprecated) ) {
def messg = "Operator `$methodName` is deprecated -- it will be removed in a future release"
if( NF.dsl2Final )
if( NF.isDsl2() )
throw new DeprecationException(messg)
log.warn messg
}
else if( method.getAnnotation(DeprecatedDsl2) && NF.isDsl2() ) {
def annot = method.getAnnotation(DeprecatedDsl2)
def messg
if( NF.dsl2Final ) {
messg = annot.message() ?: "Operator `$methodName` is deprecated".toString()
throw new DeprecationException(messg)
} else {
messg = annot.message() ?: "Operator `$methodName` is deprecated -- it will be removed in a future release".toString()
}
log.warn messg
def messg = annot.message() ?: "Operator `$methodName` has been deprecated -- it's not available in DSL2 syntax".toString()
throw new DeprecationException(messg)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ class TaskContext implements Map<String,Object>, Cloneable {
return path

// make from the module dir
def module = NF.isDsl2Final() ? ScriptMeta.get(this.script)?.getModuleDir() : null
def module = NF.isDsl2() ? ScriptMeta.get(this.script)?.getModuleDir() : null
if( module ) {
def target = module.resolve('templates').resolve(path)
if (Files.exists(target))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ abstract class BaseScript extends Script implements ExecutionContext {
*/
protected Map getConfig() {
final msg = "The access of `config` object is deprecated"
if( NF.dsl2Final )
if( NF.dsl2 )
throw new DeprecationException(msg)
log.warn(msg)
session.getConfig()
Expand All @@ -84,7 +84,7 @@ abstract class BaseScript extends Script implements ExecutionContext {
*/
protected void echo(boolean value = true) {
final msg = "The use of `echo` method has been deprecated"
if( NF.dsl2Final )
if( NF.dsl2 )
throw new DeprecationException(msg)
log.warn(msg)
session.getConfig().process.echo = value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class IncludeDef {
@Deprecated
IncludeDef( String module ) {
final msg = "Anonymous module inclusion is deprecated -- Replace `include '${module}'` with `include { MODULE_NAME } from '${module}'`"
if( NF.isDsl2Final() )
if( NF.isDsl2() )
throw new DeprecationException(msg)
log.warn msg
this.path = module
Expand All @@ -65,7 +65,7 @@ class IncludeDef {
IncludeDef(TokenVar token, String alias=null) {
def component = token.name; if(alias) component += " as $alias"
def msg = "Unwrapped module inclusion is deprecated -- Replace `include $component from './MODULE/PATH'` with `include { $component } from './MODULE/PATH'`"
if( NF.isDsl2Final() )
if( NF.isDsl2() )
throw new DeprecationException(msg)
log.warn msg

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,7 @@ class ProcessConfig implements Map<String,Object>, Cloneable {

InParam _in_set( Object... obj ) {
final msg = "Input of type `set` is deprecated -- Use `tuple` instead"
if( NF.dsl2Final ) throw new DeprecationException(msg)
if( NF.isDsl2() ) log.warn1(msg)
if( NF.isDsl2() ) throw new DeprecationException(msg)
new TupleInParam(this).bind(obj)
}

Expand Down Expand Up @@ -605,8 +604,7 @@ class ProcessConfig implements Map<String,Object>, Cloneable {

OutParam _out_set( Object... obj ) {
final msg = "Output of type `set` is deprecated -- Use `tuple` instead"
if( NF.dsl2Final ) throw new DeprecationException(msg)
if( NF.isDsl2() ) log.warn1(msg)
if( NF.isDsl2() ) throw new DeprecationException(msg)
new TupleOutParam(this) .bind(obj)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ScriptBinding extends WorkflowBinding {
void setVariable( String name, Object value ) {
if( name == 'channel' ) {
final msg = 'The use of the identifier `channel` as variable name is discouraged and will be deprecated in a future version'
if( NF.isDsl2Final() ) throw new DeprecationException(msg)
if( NF.isDsl2() ) throw new DeprecationException(msg)
log.warn(msg)
}
if( name != 'args' && name != 'params' )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,8 @@ abstract class BaseOutParam extends BaseParam implements OutParam {

BaseOutParam mode( def mode ) {
final msg = "Process output `mode` is not supported any more"
if( NF.isDsl2Final() )
if( NF.isDsl2() )
throw new DeprecationException(msg)
else if( NF.isDsl2() )
log.warn(msg)
this.mode = BasicMode.parseValue(mode)
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class FileInParam extends BaseInParam implements PathQualifier {

// the ability to pass a closure as file name has been replaced by
// lazy gstring -- this should be deprecated
if( obj instanceof Closure && !NF.dsl2Final ) {
if( obj instanceof Closure && !NF.dsl2 ) {
filePattern = obj
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,57 +95,57 @@ class FileOutParam extends BaseOutParam implements OutParam, OptionalParam, Path

@Deprecated
FileOutParam separatorChar( String value ) {
if( NF.dsl2Final ) throw new DeprecationException("Option `separatorChar is not supported any more")
if( NF.dsl2 ) throw new DeprecationException("Option `separatorChar is not supported any more")
this.separatorChar = value
return this
}

@Deprecated
FileOutParam includeInputs( boolean flag ) {
if( NF.dsl2Final ) throw new DeprecationException("Deprecated syntax error - replace `includeInputs $flag` with `, includeInputs: $flag` ")
if( NF.dsl2 ) throw new DeprecationException("Deprecated syntax error - replace `includeInputs $flag` with `, includeInputs: $flag` ")
this.includeInputs = flag
return this
}

@Deprecated
FileOutParam includeHidden( boolean flag ) {
if( NF.dsl2Final ) throw new DeprecationException("Deprecated syntax error - replace `includeHidden $flag` with `, includeHidden: $flag`")
if( NF.dsl2 ) throw new DeprecationException("Deprecated syntax error - replace `includeHidden $flag` with `, includeHidden: $flag`")
this.hidden = flag
return this
}

@Deprecated
FileOutParam hidden( boolean flag ) {
if( NF.dsl2Final ) throw new DeprecationException("Deprecated syntax error - replace `hidden $flag` with use `, hidden: $flag`")
if( NF.dsl2 ) throw new DeprecationException("Deprecated syntax error - replace `hidden $flag` with use `, hidden: $flag`")
this.hidden = flag
return this
}

@Deprecated
FileOutParam type( String value ) {
if( NF.dsl2Final ) throw new DeprecationException("Deprecated syntax error - replace `type $value` with `, type: $value`")
if( NF.dsl2 ) throw new DeprecationException("Deprecated syntax error - replace `type $value` with `, type: $value`")
assert value in ['file','dir','any']
type = value
return this
}

@Deprecated
FileOutParam maxDepth( int value ) {
if( NF.dsl2Final ) throw new DeprecationException("Deprecated syntax error - replace `maxDepth $value` with `, maxDepth: $value`")
if( NF.dsl2 ) throw new DeprecationException("Deprecated syntax error - replace `maxDepth $value` with `, maxDepth: $value`")
maxDepth = value
return this
}

@Deprecated
FileOutParam followLinks( boolean value ) {
if( NF.dsl2Final ) throw new DeprecationException("Deprecated syntax error - replace `followLinks $value` with `, followLinks: $value`")
if( NF.dsl2 ) throw new DeprecationException("Deprecated syntax error - replace `followLinks $value` with `, followLinks: $value`")
followLinks = value
return this
}

@Deprecated
FileOutParam glob( boolean value ) {
if( NF.dsl2Final ) throw new DeprecationException("Deprecated syntax error - replace `glob $value` with `, glob: $value` ")
if( NF.dsl2 ) throw new DeprecationException("Deprecated syntax error - replace `glob $value` with `, glob: $value` ")
glob = value
return this
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TupleInParam extends BaseInParam {
for( def item : obj ) {

if( item instanceof TokenVar ) {
if( NF.dsl2Final ) {
if( NF.dsl2 ) {
final msg = "Unqualified input value declaration has been deprecated - replace `tuple ${item.name},..` with `tuple val(${item.name}),..`"
throw new DeprecationException(msg)
}
Expand All @@ -71,7 +71,7 @@ class TupleInParam extends BaseInParam {
.bind( item.target )
}
else if( item instanceof Map ) {
if( NF.dsl2Final ) {
if( NF.dsl2 ) {
final msg = "Unqualified input file declaration has been deprecated - replace `tuple $item,..` with `tuple path(${item.key}, stageAs:'${item.value}'),..`"
throw new DeprecationException(msg)
}
Expand All @@ -87,15 +87,15 @@ class TupleInParam extends BaseInParam {
newItem(StdInParam)
}
else if( item instanceof GString ) {
if( NF.dsl2Final )
if( NF.dsl2 )
throw new DeprecationException("Unqualified input file declaration has been deprecated - replace `tuple \"$item\".. with `tuple path(\"$item\")..`")
newItem(FileInParam).bind(item)
}
else if( item == '-' ) {
newItem(StdInParam)
}
else if( item instanceof String ) {
if( NF.dsl2Final )
if( NF.dsl2 )
throw new DeprecationException("Unqualified input file declaration has been deprecated - replace `tuple '$item',..` with `tuple path('$item'),..`")
newItem(FileInParam).bind(item)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class TupleOutParam extends BaseOutParam implements OptionalParam {

for( def item : obj ) {
if( item instanceof TokenVar ) {
if( NF.dsl2Final )
if( NF.dsl2 )
throw new DeprecationException("Unqualified output value declaration has been deprecated - replace `tuple ${item.name},..` with `tuple val(${item.name}),..`")
create(ValueOutParam).bind(item)
}
Expand All @@ -63,15 +63,15 @@ class TupleOutParam extends BaseOutParam implements OptionalParam {
create(EnvOutParam).bind(item.val)
}
else if( item instanceof GString ) {
if( NF.dsl2Final )
if( NF.dsl2 )
throw new DeprecationException("Unqualified output path declaration has been deprecated - replace `tuple \"$item\",..` with `tuple path(\"$item\"),..`")
create(FileOutParam).bind(item)
}
else if( item instanceof TokenStdoutCall || item == '-' ) {
create(StdOutParam).bind('-')
}
else if( item instanceof String ) {
if( NF.dsl2Final )
if( NF.dsl2 )
throw new DeprecationException("Unqualified output path declaration has been deprecated - replace `tuple '$item',..` with `tuple path('$item'),..`")
create(FileOutParam).bind(item)
}
Expand Down

0 comments on commit 0f63f1a

Please sign in to comment.