Skip to content

Commit

Permalink
Merge pull request #56 from emmcauley/em_feat_54_nf_test_output
Browse files Browse the repository at this point in the history
feat: add nf_test_output to ignoreParams
  • Loading branch information
nvnieuwk authored Sep 23, 2024
2 parents d06b8c7 + 92961ae commit f7c282e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
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

0 comments on commit f7c282e

Please sign in to comment.