Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ignore configs not working #78

Merged
merged 1 commit into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading