diff --git a/docs/process.rst b/docs/process.rst index ba67598ad4..a6e137f112 100644 --- a/docs/process.rst +++ b/docs/process.rst @@ -632,11 +632,11 @@ section:: In the case an input `path` doesn't exist, the process will be aborted. If you want the process will be executed -independently if the file exists or not, you can set the attribute `allowNull` as true: +independently if the file exists or not, you can set the attribute `nullable` as true: process foo { input: - path x, stageAs: 'data.txt', allowNull:true from '/some/data/file.txt' + path x, stageAs: 'data.txt', nullable:true from '/some/data/file.txt' """ [[ -f data.txt ]] your_command --in data.txt || other_command @@ -1082,7 +1082,7 @@ followLinks When ``true`` target files are return in place of any matching s type Type of paths returned, either ``file``, ``dir`` or ``any`` (default: ``any``, or ``file`` if the specified file name pattern contains a `**` - double star - symbol) maxDepth Maximum number of directory levels to visit (default: `no limit`) includeInputs When ``true`` any input files matching an output file glob pattern are included. -allowNull When ``true`` emit a NullablePath instead to abort the process +nullable When ``true`` emit a NullablePath instead to abort the process ============== ===================== .. warning:: diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy index baff0e43fa..4d7938057a 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/TaskProcessor.groovy @@ -1501,7 +1501,7 @@ class TaskProcessor { def path = param.glob ? splitter.strip(filePattern) : filePattern def file = workDir.resolve(path) def exists = param.followLinks ? file.exists() : file.exists(LinkOption.NOFOLLOW_LINKS) - if( !exists && param.allowNull){ + if( !exists && param.nullable){ file = new NullablePath(path) exists = true } @@ -1691,9 +1691,9 @@ class TaskProcessor { return new FileHolder(source, result) } - protected Path normalizeToPath( obj, boolean allowNullable=false ) { + protected Path normalizeToPath( obj, boolean nullable=false ) { - if( obj instanceof NullablePath && !allowNullable) + if( obj instanceof NullablePath && !nullable) throw new ProcessUnrecoverableException("Path value cannot be null") if( obj instanceof Path ) @@ -1718,7 +1718,7 @@ class TaskProcessor { } protected List normalizeInputToFiles( Object obj, int count, boolean coerceToPath, FilePorter.Batch batch, - boolean allowNullable=false ) { + boolean nullable=false ) { Collection allItems = obj instanceof Collection ? obj : [obj] def len = allItems.size() @@ -1728,7 +1728,7 @@ class TaskProcessor { for( def item : allItems ) { if( item instanceof Path || coerceToPath ) { - def path = normalizeToPath(item, allowNullable) + def path = normalizeToPath(item, nullable) def target = executor.isForeignFile(path) ? batch.addToForeign(path) : path def holder = new FileHolder(target) files << holder @@ -1942,7 +1942,7 @@ class TaskProcessor { final param = entry.getKey() final val = entry.getValue() final fileParam = param as FileInParam - final normalized = normalizeInputToFiles(val, count, fileParam.isPathQualifier(), batch, fileParam.allowNull) + final normalized = normalizeInputToFiles(val, count, fileParam.isPathQualifier(), batch, fileParam.nullable) final resolved = expandWildcards( fileParam.getFilePattern(ctx), normalized ) ctx.put( param.name, singleItemOrList(resolved, task.type) ) count += resolved.size() diff --git a/modules/nextflow/src/main/groovy/nextflow/script/params/FileInParam.groovy b/modules/nextflow/src/main/groovy/nextflow/script/params/FileInParam.groovy index 905e773d52..33e14be7aa 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/params/FileInParam.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/params/FileInParam.groovy @@ -35,7 +35,7 @@ class FileInParam extends BaseInParam implements PathQualifier { private boolean pathQualifier - private boolean allowNull + private boolean nullable @Override String getTypeName() { pathQualifier ? 'path' : 'file' } @@ -156,12 +156,12 @@ class FileInParam extends BaseInParam implements PathQualifier { return this } - FileInParam setAllowNull(boolean value) { - this.allowNull = value + FileInParam setNullable(boolean value) { + this.nullable = value return this } - boolean isAllowNull() { - return allowNull + boolean isNullable() { + return nullable } } diff --git a/modules/nextflow/src/main/groovy/nextflow/script/params/FileOutParam.groovy b/modules/nextflow/src/main/groovy/nextflow/script/params/FileOutParam.groovy index 080b9546d7..e7f5b53456 100644 --- a/modules/nextflow/src/main/groovy/nextflow/script/params/FileOutParam.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/script/params/FileOutParam.groovy @@ -84,7 +84,7 @@ class FileOutParam extends BaseOutParam implements OutParam, OptionalParam, Path /** * When true, if file doesn't exist, emit a Nullable instead an exception */ - boolean allowNull = false + boolean nullable = false boolean glob = true diff --git a/modules/nextflow/src/test/groovy/nextflow/script/InputNullablePathTest.groovy b/modules/nextflow/src/test/groovy/nextflow/script/InputNullablePathTest.groovy index f9f6115d8f..63e13e5d4f 100644 --- a/modules/nextflow/src/test/groovy/nextflow/script/InputNullablePathTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/script/InputNullablePathTest.groovy @@ -17,7 +17,7 @@ import test.MockScriptRunner @IgnoreIf({System.getenv('NXF_INPUTNULLABLE')}) class InputNullablePathTest extends Dsl2Spec { - def 'should fails if allowNull is allowed as output but expected as input'() { + def 'should fails if nullable is allowed as output but expected as input'() { given: def session = new Session( executor: 'nope' ) { @Override @@ -34,7 +34,7 @@ class InputNullablePathTest extends Dsl2Spec { input: val id output: - path("output.txt", allowNull:true) + path("output.txt", nullable:true) exec: println id } diff --git a/modules/nextflow/src/test/groovy/nextflow/script/OutputNullablePathTest.groovy b/modules/nextflow/src/test/groovy/nextflow/script/OutputNullablePathTest.groovy index 51d6608943..085ae9f651 100644 --- a/modules/nextflow/src/test/groovy/nextflow/script/OutputNullablePathTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/script/OutputNullablePathTest.groovy @@ -12,7 +12,7 @@ import test.Dsl2Spec @IgnoreIf({System.getenv('NXF_INPUTNULLABLE')}) class OutputNullablePathTest extends Dsl2Spec { - def 'should fails if allowNull output is not set'() { + def 'should fails if nullable output is not set'() { given: def error = false def session = new Session( executor: 'nope' ) { diff --git a/modules/nextflow/src/test/groovy/nextflow/script/params/ParamsOutTest.groovy b/modules/nextflow/src/test/groovy/nextflow/script/params/ParamsOutTest.groovy index 74f9512dd3..8305e11193 100644 --- a/modules/nextflow/src/test/groovy/nextflow/script/params/ParamsOutTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/script/params/ParamsOutTest.groovy @@ -1152,7 +1152,7 @@ class ParamsOutTest extends Specification { glob: false, optional: false, includeInputs: false, - allowNull: true + nullable: true path y, maxDepth:5, @@ -1182,7 +1182,7 @@ class ParamsOutTest extends Specification { !out0.getGlob() !out0.getOptional() !out0.getIncludeInputs() - out0.isAllowNull() + out0.isNullable() and: out1.getMaxDepth() == 5 @@ -1193,7 +1193,7 @@ class ParamsOutTest extends Specification { out1.getGlob() out1.getOptional() out1.getIncludeInputs() - !out1.isAllowNull() + !out1.isNullable() } def 'should set file options' () { diff --git a/tests/input-nullablepath-fails.nf b/tests/input-nullablepath-fails.nf index ceae1455aa..09c1292e33 100644 --- a/tests/input-nullablepath-fails.nf +++ b/tests/input-nullablepath-fails.nf @@ -3,7 +3,7 @@ process test_process1 { input: val id output: - path("output.txt", allowNull:true) + path("output.txt", nullable:true) exec: println id }