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

feat: add nf_test_output to ignoreParams #56

Merged
merged 1 commit into from
Sep 23, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# nextflow-io/nf-schema: Changelog

# Version 2.1.2

## 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`.

# Version 2.1.1

## Bug fixes
Expand Down
1 change: 1 addition & 0 deletions docs/configuration/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ validation.showHiddenParams = <true|false> // default: false
## ignoreParams

This option can be used to turn off the validation for certain parameters. It takes a list of parameter names as input.
Currently, the parameter `nf_test_output` is added to `ignoreParams` by default.

```groovy
validation.ignoreParams = ["param1", "param2"] // default: []
Expand Down
4 changes: 4 additions & 0 deletions docs/parameters/validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ The function causes Nextflow to exit immediately with an error.
--8<-- "examples/validateParameters/pipeline/nextflow_schema.json"
```

## Ignoring Parameters

Users can turn off validation for specific parameters using `validation.ignoreParams`, which accepts a list of parameter names.

## Failing for unrecognized parameters

When parameters which are not specified in the JSON Schema are provided, the parameter validation function returns a `WARNING`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import groovy.transform.PackageScope
/**
* This class allows model an specific configuration, extracting values from a map and converting
*
* We anotate this class as @PackageScope to restrict the access of their methods only to class in the
* We annotate this class as @PackageScope to restrict the access of their methods only to class in the
* same package
*
* @author : nvnieuwk <[email protected]>
Expand Down Expand Up @@ -49,5 +49,7 @@ class ValidationConfig {
throw new SchemaValidationException("Config value 'validation.defaultIgnoreParams' should be a list of String values")
}
ignoreParams += config.defaultIgnoreParams ?: []
ignoreParams += 'nf_test_output' //ignore `nf_test_output` directory when using nf-test

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,31 @@ class ValidateParametersTest extends Dsl2Spec{
!stdout
}

def 'should ignore nf_test_output param' () {
given:
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()
def SCRIPT = """
params.input = 'src/testResources/correct.csv'
params.outdir = 'src/testResources/testDir'
params.nf_test_output = '/some/path'
include { validateParameters } from 'plugin/nf-schema'

validateParameters(parameters_schema: '$schema')
"""

when:
def config = [:]
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 ignore default unexpected param' () {
given:
def schema = Path.of('src/testResources/nextflow_schema.json').toAbsolutePath().toString()
Expand Down
Loading