Skip to content
This repository was archived by the owner on Aug 20, 2024. It is now read-only.

Commit c802dff

Browse files
authored
Merge branch 'master' into empty-params
2 parents 32573e3 + 781511f commit c802dff

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Add parameters defined on the top level of the schema and within the definitions section as expected params ([#79](https://github.com/nextflow-io/nf-validation/pull/79))
88
- Fix error when a parameter is not present in the schema and evaluates to false ([#89](https://github.com/nextflow-io/nf-validation/pull/89))
9+
- Changed the `schema_filename` option of `fromSamplesheet` to `parameters_schema` to make this option more clear to the user ([#91](https://github.com/nextflow-io/nf-validation/pull/91))
910

1011
## Version 0.3.1
1112

docs/samplesheets/fromSamplesheet.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ The path specified in the `schema` key determines the JSON used for validation o
2323

2424
When using the `.fromSamplesheet` channel factory, some additional optional arguments can be used:
2525

26-
- `schema_filename`: File name for the pipeline parameters schema. (Default: `nextflow_schema.json`)
26+
- `parameters_schema`: File name for the pipeline parameters schema. (Default: `nextflow_schema.json`)
2727
- `skip_duplicate_check`: Skip the checking for duplicates. Can also be skipped with the `--validationSkipDuplicateCheck` parameter. (Default: `false`)
2828

2929
```groovy
@@ -33,7 +33,7 @@ Channel.fromSamplesheet('input')
3333
```groovy
3434
Channel.fromSamplesheet(
3535
'input',
36-
schema_filename: 'custom_nextflow_schema.json',
36+
parameters_schema: 'custom_nextflow_schema.json',
3737
skip_duplicate_check: false
3838
)
3939
```

plugins/nf-validation/src/main/nextflow/validation/SchemaValidator.groovy

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class SchemaValidator extends PluginExtensionPoint {
155155
def Map params = session.params
156156

157157
// Set defaults for optional inputs
158-
def String schemaFilename = options?.containsKey('schema_filename') ? options.schema_filename as String : 'nextflow_schema.json'
158+
def String schemaFilename = options?.containsKey('parameters_schema') ? options.parameters_schema as String : 'nextflow_schema.json'
159159
def Boolean skipDuplicateCheck = options?.containsKey('skip_duplicate_check') ? options.skip_duplicate_check as Boolean : params.validationSkipDuplicateCheck ? params.validationSkipDuplicateCheck as Boolean : false
160160

161161
def slurper = new JsonSlurper()
@@ -167,10 +167,14 @@ class SchemaValidator extends PluginExtensionPoint {
167167
throw new SchemaValidationException("", [])
168168
}
169169
def Path schemaFile = null
170-
if (samplesheetValue != null && samplesheetValue.containsKey('schema')) {
170+
if (samplesheetValue == null) {
171+
log.error "Parameter '--$samplesheetParam' was not found in the schema ($schemaFilename). Unable to create a channel from it."
172+
throw new SchemaValidationException("", [])
173+
}
174+
else if (samplesheetValue.containsKey('schema')) {
171175
schemaFile = Path.of(getSchemaPath(baseDir, samplesheetValue['schema'].toString()))
172176
} else {
173-
log.error "Parameter '--$samplesheetParam' does not contain a schema. Unable to create a channel from it."
177+
log.error "Parameter '--$samplesheetParam' does not contain a schema in the parameter schema ($schemaFilename). Unable to create a channel from it."
174178
throw new SchemaValidationException("", [])
175179
}
176180

plugins/nf-validation/src/test/nextflow/validation/SamplesheetConverterTest.groovy

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class SamplesheetConverterTest extends Dsl2Spec{
6464
params.input = 'src/testResources/correct.csv'
6565
6666
workflow {
67-
Channel.fromSamplesheet("input", schema_filename:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view().first().map {println(it[0].getClass())}
67+
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view().first().map {println(it[0].getClass())}
6868
}
6969
'''
7070

@@ -90,7 +90,7 @@ class SamplesheetConverterTest extends Dsl2Spec{
9090
params.input = 'src/testResources/correct.csv'
9191
9292
workflow {
93-
Channel.fromSamplesheet("input", schema_filename:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
93+
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
9494
}
9595
'''
9696

@@ -116,7 +116,7 @@ class SamplesheetConverterTest extends Dsl2Spec{
116116
params.input = 'src/testResources/correct.csv'
117117
118118
workflow {
119-
Channel.fromSamplesheet("input", schema_filename:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
119+
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
120120
}
121121
'''
122122

@@ -142,7 +142,7 @@ class SamplesheetConverterTest extends Dsl2Spec{
142142
params.input = 'src/testResources/extraFields.csv'
143143
144144
workflow {
145-
Channel.fromSamplesheet("input", schema_filename:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
145+
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
146146
}
147147
'''
148148

@@ -169,7 +169,7 @@ class SamplesheetConverterTest extends Dsl2Spec{
169169
params.input = 'src/testResources/no_meta.csv'
170170
171171
workflow {
172-
Channel.fromSamplesheet("input", schema_filename:"src/testResources/nextflow_schema_with_samplesheet_no_meta.json").view()
172+
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_no_meta.json").view()
173173
}
174174
'''
175175

@@ -193,7 +193,7 @@ class SamplesheetConverterTest extends Dsl2Spec{
193193
params.input = 'src/testResources/errors.csv'
194194
195195
workflow {
196-
Channel.fromSamplesheet("input", schema_filename:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
196+
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
197197
}
198198
'''
199199

@@ -222,7 +222,7 @@ class SamplesheetConverterTest extends Dsl2Spec{
222222
params.input = 'src/testResources/errorsBeforeConversion.csv'
223223
224224
workflow {
225-
Channel.fromSamplesheet("input", schema_filename:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
225+
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
226226
}
227227
'''
228228

@@ -259,7 +259,7 @@ class SamplesheetConverterTest extends Dsl2Spec{
259259
params.input = 'src/testResources/duplicate.csv'
260260
261261
workflow {
262-
Channel.fromSamplesheet("input", schema_filename:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
262+
Channel.fromSamplesheet("input", parameters_schema:"src/testResources/nextflow_schema_with_samplesheet_converter.json").view()
263263
}
264264
'''
265265

0 commit comments

Comments
 (0)