Skip to content

Commit ea60dfb

Browse files
authored
Improve deprecation warnings (#5939)
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
1 parent 0206d1f commit ea60dfb

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

modules/nextflow/src/main/groovy/nextflow/ast/NextflowDSLImpl.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ class NextflowDSLImpl implements ASTTransformation {
742742
* closure expression and set a `when` directive in the process configuration properties.
743743
*
744744
* See {@link nextflow.script.ProcessConfig#configProperties}
745-
* See {@link nextflow.processor.TaskConfig#getGuard(java.lang.String)}
745+
* See {@link nextflow.processor.TaskConfig#getWhenGuard()}
746746
*/
747747
protected BlockStatement addWhenGuardCall( List<Statement> statements, StringBuilder source, BlockStatement parent ) {
748748
createBlock0(PROCESS_WHEN, statements, source, parent)

modules/nextflow/src/main/groovy/nextflow/processor/TaskConfig.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -550,17 +550,17 @@ class TaskConfig extends LazyMap implements Cloneable {
550550
}
551551

552552
/**
553-
* Get a closure guard condition and evaluate to a boolean result
553+
* Get the when guard condition if present and evaluate it
554554
*
555-
* @param name The name of the guard to test e.g. {@code when}
556555
* @return {@code true} when the condition is verified
557556
*/
558-
protected boolean getGuard( String name, boolean defValue=true ) throws FailedGuardException {
557+
protected boolean getWhenGuard(boolean defValue=true) throws FailedGuardException {
559558

560-
final code = target.get(name)
559+
final code = target.get(NextflowDSLImpl.PROCESS_WHEN)
561560
if( code == null )
562561
return defValue
563562

563+
log.warn1 "The `when` process section is deprecated -- use conditional logic in the calling workflow instead"
564564
String source = null
565565
try {
566566
if( code instanceof Closure ) {
@@ -571,7 +571,7 @@ class TaskConfig extends LazyMap implements Cloneable {
571571
return code as Boolean
572572
}
573573
catch( Throwable e ) {
574-
throw new FailedGuardException("Cannot evaluate `$name` expression", source, e)
574+
throw new FailedGuardException("Cannot evaluate `when` expression", source, e)
575575
}
576576
}
577577

modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ import groovyx.gpars.group.PGroup
5454
import nextflow.NF
5555
import nextflow.Nextflow
5656
import nextflow.Session
57-
import nextflow.ast.NextflowDSLImpl
5857
import nextflow.ast.TaskCmdXform
5958
import nextflow.ast.TaskTemplateVarsXform
6059
import nextflow.cloud.CloudSpotTerminationException
@@ -310,7 +309,7 @@ class TaskProcessor {
310309
this.config = config
311310
this.taskBody = taskBody
312311
if( taskBody.isShell )
313-
log.warn "Process ${name} > the `shell` block is deprecated, use `script` instead"
312+
log.warn1 "The `shell` process section is deprecated -- use the `script` section instead"
314313
this.name = name
315314
this.maxForks = config.maxForks && config.maxForks>0 ? config.maxForks as int : 0
316315
this.forksCount = maxForks ? new LongAdder() : null
@@ -2350,7 +2349,7 @@ class TaskProcessor {
23502349
protected boolean checkWhenGuard(TaskRun task) {
23512350

23522351
try {
2353-
def pass = task.config.getGuard(NextflowDSLImpl.PROCESS_WHEN)
2352+
def pass = task.config.getWhenGuard()
23542353
if( pass ) {
23552354
return true
23562355
}

modules/nextflow/src/main/groovy/nextflow/script/IncludeDef.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ class IncludeDef {
8080
}
8181

8282
IncludeDef params(Map args) {
83-
log.warn "Include with `params()` is deprecated -- pass params as a workflow or process input instead"
83+
log.warn1 "Include with `params()` is deprecated -- pass params as a workflow or process input instead"
8484
this.params = args != null ? new HashMap(args) : null
8585
return this
8686
}
8787

8888
IncludeDef addParams(Map args) {
89-
log.warn "Include with `addParams()` is deprecated -- pass params as a workflow or process input instead"
89+
log.warn1 "Include with `addParams()` is deprecated -- pass params as a workflow or process input instead"
9090
this.addedParams = args
9191
return this
9292
}

modules/nextflow/src/test/groovy/nextflow/processor/TaskConfigTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,20 +409,20 @@ class TaskConfigTest extends Specification {
409409
config.put('when', closure)
410410

411411
when:
412-
config.getGuard('when')
412+
config.getWhenGuard()
413413
then:
414414
FailedGuardException ex = thrown()
415415
ex.source == '{closure source code}'
416416

417417
when:
418418
config.context = [x: 'Hello', count: 1]
419419
then:
420-
config.getGuard('when')
420+
config.getWhenGuard()
421421

422422
when:
423423
config.context = [x: 'Hello', count: 3]
424424
then:
425-
!config.getGuard('when')
425+
!config.getWhenGuard()
426426
}
427427

428428
def 'should create ext config properties' () {

0 commit comments

Comments
 (0)