Sol Shenker
07/30/2025, 4:45 PM{
"$schema": "<https://json-schema.org/draft/2020-12/schema>",
"$id": "<file://nextflow_schema.json>",
"title": "Pipeline Parameters",
"type": "object",
"$defs": {
"strategy": {
"type": "object",
"default": "",
"properties": {
"mode": {
"type": "string",
"default": "mode2",
"enum": [
"mode2",
"mode1"
]
}
},
"required": [
"mode"
]
},
"mode2_input": {
"type": "object",
"default": "",
"properties": {
"mode2": {
"type": "string"
}
},
"required": [
"mode2"
]
},
"mode1_input": {
"type": "object",
"default": "",
"properties": {
"mode1": {
"type": "string"
}
},
"required": [
"mode1"
]
}
},
"oneOf": [
{
"allOf": [
{
"$ref": "#/$defs/mode2_input"
},
{
"properties": {
"mode1": {
"const": null
}
}
},
{
"properties": {
"mode": {
"const": "mode2"
}
}
}
]
},
{
"allOf": [
{
"$ref": "#/$defs/mode1_input"
},
{
"properties": {
"mode2": {
"const": null
}
}
},
{
"properties": {
"mode": {
"const": "mode1"
}
}
}
]
}
],
"allOf": [
{
"$ref": "#/$defs/strategy"
}
]
}
Are there any cleaner ways to specify this? When I run it with the correct arguments it validates, but then the arguments are wrong (e.g. --mode mode1 --mode2 mode2samplesheet ) the validation messages are a little confusing because it prints all the individual failures as a continuous list, despite them belonging to sub-cases of the oneOf clause.
It feels like it might be possible with dependentSchemas, but I'm not sure I can make those switch depending on the value of mode? (like with "const" above)Arthur
07/30/2025, 5:55 PMjsonschema library and it really doesn't have a way of knowing which conditional schema you made the error on.
It may seem obvious to the user, but how should the library/schema know if you entered the wrong mode options or you actually set the wrong mode and passed the correct options for the mode you meant to setSol Shenker
07/30/2025, 6:32 PMNicolas Vannieuwkerke
07/31/2025, 7:13 AMvalidateParameters function can take an optional argument called parameters_schema in which you can provide the path to a different schema. You could add some simple check in your pipeline to see what the mode is and pass the correct schema to the function that way. See the docs for more information: https://nextflow-io.github.io/nf-schema/latest/parameters/validation/#validateparametersSol Shenker
07/31/2025, 11:40 AMArthur
07/31/2025, 11:41 AMArthur
07/31/2025, 11:42 AMSol Shenker
07/31/2025, 12:22 PMArthur
07/31/2025, 12:26 PMjsonschema is primarily concerned with validation of data and less concerned/well-designed with regards to displaying it or generating it imo.
I too have thought it would be easy to implement certain tooling around the schema only to be stymied once I delved deeper.Sol Shenker
07/31/2025, 1:18 PMNicolas Vannieuwkerke
07/31/2025, 1:27 PMvalidate() function returns the raw errors if you are interestedArthur
07/31/2025, 1:28 PMArthur
07/31/2025, 1:29 PMSol Shenker
07/31/2025, 1:30 PMNicolas Vannieuwkerke
07/31/2025, 1:32 PMSol Shenker
07/31/2025, 1:33 PMNicolas Vannieuwkerke
07/31/2025, 1:36 PM