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

Validate parameters against schema at pipeline runtime #426

Closed
ewels opened this issue Oct 15, 2019 · 7 comments
Closed

Validate parameters against schema at pipeline runtime #426

ewels opened this issue Oct 15, 2019 · 7 comments
Assignees
Labels
template nf-core pipeline/component template
Milestone

Comments

@ewels
Copy link
Member

ewels commented Oct 15, 2019

Now that we have a JSON Schema file describing parameters, we should be able to check that all supplied params are expected and valid (correct variable type, one of allowed choices, matching given regex etc) when a pipeline is launched.

This will likely need to go hand-in-hand with templating and linting for the nextflow_schema.json file, as most params are probably still not present there. We may also need one of these files for the shared configs.

I made a quick start on a draft function here - will make a PR when it gets a little further, but discussion on the concept is welcome 🤗

@ewels ewels added the template nf-core pipeline/component template label Oct 15, 2019
@ewels
Copy link
Member Author

ewels commented Oct 16, 2019

x-ref nf-core/hlatyping#61, which is also working with the parameters.settings.json file.

@ewels
Copy link
Member Author

ewels commented Jun 23, 2020

Updated original issue text for new JSON schema approach. Linting is now in place, so this is ready to go ahead.

@ewels ewels added this to the 1.10 milestone Jun 23, 2020
@ewels ewels changed the title Validate parameters at pipeline runtime Validate parameters against schema at pipeline runtime Jun 23, 2020
@ewels ewels modified the milestones: 1.10, JSON Schema Jun 23, 2020
@ewels ewels modified the milestones: JSON Schema, 1.10 Jul 6, 2020
@ewels
Copy link
Member Author

ewels commented Jul 7, 2020

This Java library looks pretty nice for doing validation: https://github.com/everit-org/json-schema

Should be able to use Groovy Grape to import dependencies, as done by @apeltzer in eager here.

@ewels ewels modified the milestones: 1.10, 1.11 Jul 13, 2020
@jfy133
Copy link
Member

jfy133 commented Oct 22, 2020

If it helps, to access all CLI called params by the user, within nextflow itself, could use

log.info("workflow params")
log.info("${params}")

to compare against the schema.

@ewels
Copy link
Member Author

ewels commented Oct 22, 2020

Yup - unexpected params would be great 👍🏻 Need to be a little careful with this as there are quite a lot of genuine reasons for people to specify params which are not in the schema (eg. HPC cluster options etc etc). So can't fail / warn too noisily.

Suggestion for this would be to check and hard-fail for params that match core nextflow flags (see #604) and give a quiet warning about others. Could even try to be clever and compare unexpected params against the schema and give a louder warning if it is a close match?

NB. that it would be nice to have some way to disable these warnings. Maybe a param?? 😆

@KevinMenden
Copy link
Contributor

Okay so I made a draft of a validation check here:
nf-core/cageseq#38

Will have to test this much more. And it also depends on parameters being properly specified in the Schema, of course.

@ewels ewels linked a pull request Dec 16, 2020 that will close this issue
2 tasks
@KevinMenden KevinMenden self-assigned this Jan 4, 2021
@ewels
Copy link
Member Author

ewels commented Feb 17, 2021

Implemented in #852

@ewels ewels closed this as completed Feb 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
template nf-core pipeline/component template
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants