diff --git a/CHANGELOG.md b/CHANGELOG.md index e0077117..384989da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index c55a34c6..77c46ea9 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Declare the plugin in your Nextflow pipeline configuration file: ```groovy title="nextflow.config" plugins { - id 'nf-schema@2.1.1' + id 'nf-schema@2.1.2' } ``` diff --git a/plugins/nf-schema/src/main/nextflow/validation/CustomEvaluators/UniqueEntriesEvaluator.groovy b/plugins/nf-schema/src/main/nextflow/validation/CustomEvaluators/UniqueEntriesEvaluator.groovy index 88a33e58..8d19df92 100644 --- a/plugins/nf-schema/src/main/nextflow/validation/CustomEvaluators/UniqueEntriesEvaluator.groovy +++ b/plugins/nf-schema/src/main/nextflow/validation/CustomEvaluators/UniqueEntriesEvaluator.groovy @@ -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) diff --git a/plugins/nf-schema/src/resources/META-INF/MANIFEST.MF b/plugins/nf-schema/src/resources/META-INF/MANIFEST.MF index fff7b0cf..cd4b1971 100644 --- a/plugins/nf-schema/src/resources/META-INF/MANIFEST.MF +++ b/plugins/nf-schema/src/resources/META-INF/MANIFEST.MF @@ -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 diff --git a/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy b/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy index 6627c2ae..8636ac07 100644 --- a/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy +++ b/plugins/nf-schema/src/test/nextflow/validation/ValidateParametersTest.groovy @@ -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 = """ diff --git a/plugins/nf-schema/src/testResources/samplesheet_non_unique_empty.csv b/plugins/nf-schema/src/testResources/samplesheet_non_unique_empty.csv new file mode 100644 index 00000000..0d2c57b0 --- /dev/null +++ b/plugins/nf-schema/src/testResources/samplesheet_non_unique_empty.csv @@ -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