Skip to content

Commit

Permalink
Merge pull request #78 from nextflow-io/fix/defaultIgnoreParams
Browse files Browse the repository at this point in the history
fix ignore configs not working
  • Loading branch information
nvnieuwk authored Dec 3, 2024
2 parents 51069b9 + 8ef771b commit 803c1ae
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 5 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# nextflow-io/nf-schema: Changelog

# Version 2.3.0
# Version 2.2.1

## Bug fixes

1. Fixed a bug in `paramsSummaryMap()` related to the processing of workflow config files.
2. Fixed a bug where `validation.defaultIgnoreParams` and `validation.ignoreParams` would not actually ignore the parameter validation.

# Version 2.2.0 - Kitakata

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,12 @@ class SchemaValidator extends PluginExtensionPoint {
// Validate
List<String> validationErrors = validator.validate(paramsJSON, schema_string)
this.errors.addAll(validationErrors)
if (this.hasErrors()) {
def msg = "${colors.red}The following invalid input values have been detected:\n\n" + errors.join('\n').trim() + "\n${colors.reset}\n"
def List<String> modifiedIgnoreParams = config.ignoreParams.collect { param -> "* --${param}" as String }
def List<String> filteredErrors = errors.findAll { error ->
return modifiedIgnoreParams.find { param -> error.startsWith(param) } == null
}
if (filteredErrors.size() > 0) {
def msg = "${colors.red}The following invalid input values have been detected:\n\n" + filteredErrors.join('\n').trim() + "\n${colors.reset}\n"
log.error("Validation of pipeline parameters failed!")
throw new SchemaValidationException(msg, this.getErrors())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ class ValidationConfig {
}
ignoreParams += config.defaultIgnoreParams ?: []
ignoreParams += 'nf_test_output' //ignore `nf_test_output` directory when using nf-test

}
}
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.2.0
Plugin-Version: 2.2.1
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 @@ -483,6 +483,33 @@ class ValidateParametersTest extends Dsl2Spec{
!stdout
}

def 'should ignore wrong expected params' () {
given:
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()
def SCRIPT = """
params.input = 1
params.outdir = 2
include { validateParameters } from 'plugin/nf-schema'
validateParameters(parameters_schema: '$schema')
"""

when:
def config = ["validation": [
"ignoreParams": ['input'],
"defaultIgnoreParams": ['outdir']
]]
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 fail for unexpected param' () {
given:
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()
Expand Down

0 comments on commit 803c1ae

Please sign in to comment.