Skip to content

Commit

Permalink
Merge pull request #63 from nextflow-io/fix/unique
Browse files Browse the repository at this point in the history
Fix `uniqueEntries` on empty optional values
  • Loading branch information
nvnieuwk authored Oct 18, 2024
2 parents 2e164ec + d1eb89d commit 1c64182
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
## Bug fixes

1. The directory `nf_test_output` is now an ignored parameter during validation to support use of both `nf_test` and `nf_schema`.
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.
3. Improved the error messages produced by `uniqueEntries`.

## Documentation

1. Fix some faults in the docs

# Version 2.1.1

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Declare the plugin in your Nextflow pipeline configuration file:

```groovy title="nextflow.config"
plugins {
id '[email protected].1'
id '[email protected].2'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ class UniqueEntriesEvaluator implements Evaluator {
.findAll { k,v -> uniqueEntries.contains(k) }
.collectEntries { k,v -> [k, v.asString()] }
for (uniqueNode : uniques) {
if(filteredNodes.equals(uniqueNode)) {
return Evaluator.Result.failure("Entry ${count}: Detected non-unique combination of the following fields: ${uniqueEntries}" as String)
if(filteredNodes.equals(uniqueNode) && filteredNodes != [:]) {
return Evaluator.Result.failure("Entry ${count}: Detected duplicate entries: ${filteredNodes}" as String)
}
}
uniques.add(filteredNodes)
Expand Down
2 changes: 1 addition & 1 deletion plugins/nf-schema/src/resources/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Manifest-Version: 1.0
Plugin-Id: nf-schema
Plugin-Version: 2.1.1
Plugin-Version: 2.1.2
Plugin-Class: nextflow.validation.ValidationPlugin
Plugin-Provider: nextflow
Plugin-Requires: >=23.10.0
Original file line number Diff line number Diff line change
Expand Up @@ -990,12 +990,37 @@ class ValidateParametersTest extends Dsl2Spec{
error.message == '''The following invalid input values have been detected:
* --input (src/testResources/samplesheet_non_unique.csv): Validation of file failed:
-> Entry 3: Detected non-unique combination of the following fields: [sample, fastq_1]
-> Entry 3: Detected duplicate entries: [fastq_1:test2_fastq1.fastq.gz, sample:test_2]
'''
!stdout
}

def 'should not fail because of non-unique empty entries' () {
given:
def schema = Path.of('src/testResources/nextflow_schema_with_samplesheet_uniqueEntries.json').toAbsolutePath().toString()
def SCRIPT = """
params.input = "src/testResources/samplesheet_non_unique_empty.csv"
include { validateParameters } from 'plugin/nf-schema'
validateParameters(parameters_schema: '$schema')
"""

when:
def config = ["validation": [
"monochromeLogs": true
]]
def result = new MockScriptRunner(config).setScript(SCRIPT).execute()
def stdout = capture
.toString()
.readLines()
.findResults {it.contains('WARN nextflow.validation.SchemaValidator') || it.startsWith('* --') ? it : null }

then:
noExceptionThrown()
!stdout
}

def 'should validate nested params - pass' () {
given:
def SCRIPT = """
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
sample,fastq_1,fastq_2,strandedness
test_1,test1_fastq1.fastq.gz,test1_fastq2.fastq.gz,forward
test_2,,,unstranded
test_3,test2_fastq1.fastq.gz,,forward
,,,forward
,,,unstranded

0 comments on commit 1c64182

Please sign in to comment.