Skip to content

Commit 1c64182

Browse files
authored
Merge pull request #63 from nextflow-io/fix/unique
Fix `uniqueEntries` on empty optional values
2 parents 2e164ec + d1eb89d commit 1c64182

File tree

6 files changed

+42
-5
lines changed

6 files changed

+42
-5
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
## Bug fixes
66

77
1. The directory `nf_test_output` is now an ignored parameter during validation to support use of both `nf_test` and `nf_schema`.
8+
2. `uniqueEntries` will now skip unique checks when all values in the requested array properties are empty. This had to be implemented to allow optional values to work with the `uniqueEntries` check. Partially filled in array properties will still fail (and that's how it's meant to be). Be sure to use `oneOf` to properly configure all possible combinations in case this causes some issues.
9+
3. Improved the error messages produced by `uniqueEntries`.
10+
11+
## Documentation
12+
13+
1. Fix some faults in the docs
814

915
# Version 2.1.1
1016

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Declare the plugin in your Nextflow pipeline configuration file:
2525

2626
```groovy title="nextflow.config"
2727
plugins {
28-
28+
2929
}
3030
```
3131

plugins/nf-schema/src/main/nextflow/validation/CustomEvaluators/UniqueEntriesEvaluator.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class UniqueEntriesEvaluator implements Evaluator {
4343
.findAll { k,v -> uniqueEntries.contains(k) }
4444
.collectEntries { k,v -> [k, v.asString()] }
4545
for (uniqueNode : uniques) {
46-
if(filteredNodes.equals(uniqueNode)) {
47-
return Evaluator.Result.failure("Entry ${count}: Detected non-unique combination of the following fields: ${uniqueEntries}" as String)
46+
if(filteredNodes.equals(uniqueNode) && filteredNodes != [:]) {
47+
return Evaluator.Result.failure("Entry ${count}: Detected duplicate entries: ${filteredNodes}" as String)
4848
}
4949
}
5050
uniques.add(filteredNodes)
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Manifest-Version: 1.0
22
Plugin-Id: nf-schema
3-
Plugin-Version: 2.1.1
3+
Plugin-Version: 2.1.2
44
Plugin-Class: nextflow.validation.ValidationPlugin
55
Plugin-Provider: nextflow
66
Plugin-Requires: >=23.10.0

plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy

+26-1
Original file line numberDiff line numberDiff line change
@@ -990,12 +990,37 @@ class ValidateParametersTest extends Dsl2Spec{
990990
error.message == '''The following invalid input values have been detected:
991991
992992
* --input (src/testResources/samplesheet_non_unique.csv): Validation of file failed:
993-
-> Entry 3: Detected non-unique combination of the following fields: [sample, fastq_1]
993+
-> Entry 3: Detected duplicate entries: [fastq_1:test2_fastq1.fastq.gz, sample:test_2]
994994
995995
'''
996996
!stdout
997997
}
998998

999+
def 'should not fail because of non-unique empty entries' () {
1000+
given:
1001+
def schema = Path.of('src/testResources/nextflow_schema_with_samplesheet_uniqueEntries.json').toAbsolutePath().toString()
1002+
def SCRIPT = """
1003+
params.input = "src/testResources/samplesheet_non_unique_empty.csv"
1004+
include { validateParameters } from 'plugin/nf-schema'
1005+
1006+
validateParameters(parameters_schema: '$schema')
1007+
"""
1008+
1009+
when:
1010+
def config = ["validation": [
1011+
"monochromeLogs": true
1012+
]]
1013+
def result = new MockScriptRunner(config).setScript(SCRIPT).execute()
1014+
def stdout = capture
1015+
.toString()
1016+
.readLines()
1017+
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }
1018+
1019+
then:
1020+
noExceptionThrown()
1021+
!stdout
1022+
}
1023+
9991024
def 'should validate nested params - pass' () {
10001025
given:
10011026
def SCRIPT = """
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
sample,fastq_1,fastq_2,strandedness
2+
test_1,test1_fastq1.fastq.gz,test1_fastq2.fastq.gz,forward
3+
test_2,,,unstranded
4+
test_3,test2_fastq1.fastq.gz,,forward
5+
,,,forward
6+
,,,unstranded

0 commit comments

Comments
 (0)