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

Add BidsValidator Plugin #291

Merged
merged 13 commits into from
Jun 23, 2023
Merged

Add BidsValidator Plugin #291

merged 13 commits into from
Jun 23, 2023

Conversation

kaitj
Copy link
Contributor

@kaitj kaitj commented May 9, 2023

Proposed changes

A second attempt at implementing bids validation (see #222). This time, implementing as a snakebids plugin (resuing some of the code from the previous attempt). The plugin tries to perform validation using the bids-validator unless skipped by the user (--skip_bids_validation). If the validation fails, an InvalidBidsError is thrown, otherwise validation is performed by default using pybids with a warning informing the user.

As noted in #222:

Drawing some inspiration from fmriprep, a temporary config file is generated for the system call in (_validate_bids_dir) which includes files to ignore during this validation. Was also wondering if we want to limit the validation to the subject data themselves rather than a full dataset (e.g. ignore participants.tsv, dataset_description.json)?

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you are unsure about any of the choices, don't hesitate to ask!

  • Changes have been tested to ensure that fix is effective or that a feature works.
  • Changes pass the unit tests
  • I have included necessary documentation or comments (as necessary)
  • Any dependent changes have been merged and published

Notes

All PRs will undergo the unit testing before being reviewed. You may be requested to explain or make additional changes before the PR is accepted.

@kaitj kaitj added the enhancement New feature or request label May 9, 2023
@github-actions github-actions bot requested review from akhanf, pvandyken and tkkuehn May 9, 2023 12:59
@kaitj kaitj linked an issue May 9, 2023 that may be closed by this pull request
@kaitj kaitj mentioned this pull request May 9, 2023
7 tasks
snakebids/core/input_generation.py Outdated Show resolved Hide resolved
snakebids/plugins/validate.py Outdated Show resolved Hide resolved
snakebids/plugins/validate.py Outdated Show resolved Hide resolved
snakebids/plugins/validate.py Outdated Show resolved Hide resolved
snakebids/plugins/validate.py Outdated Show resolved Hide resolved
snakebids/plugins/validate.py Outdated Show resolved Hide resolved
snakebids/tests/test_validate_plugin.py Outdated Show resolved Hide resolved
snakebids/tests/test_validate_plugin.py Outdated Show resolved Hide resolved
docs/running_snakebids/overview.md Outdated Show resolved Hide resolved
snakebids/core/input_generation.py Outdated Show resolved Hide resolved
Copy link
Contributor

@tkkuehn tkkuehn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, just a few typos and one suggestion for a potential enhancement to the plugin

docs/bids_app/plugins.md Outdated Show resolved Hide resolved
docs/bids_app/plugins.md Outdated Show resolved Hide resolved
docs/bids_app/plugins.md Outdated Show resolved Hide resolved
docs/bids_app/plugins.md Outdated Show resolved Hide resolved
docs/bids_app/plugins.md Outdated Show resolved Hide resolved
docs/running_snakebids/overview.md Outdated Show resolved Hide resolved
snakebids/plugins/validator.py Outdated Show resolved Hide resolved
snakebids/plugins/validator.py Outdated Show resolved Hide resolved
snakebids/tests/test_validate_plugin.py Outdated Show resolved Hide resolved
@kaitj
Copy link
Contributor Author

kaitj commented May 12, 2023

The one check that is failing seems to have occurred when there was some GitHub downtime the other day. I’ve reran this a couple of times since and that error is still there.

Copy link
Contributor

@tkkuehn tkkuehn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it is not at all clear to me what's going on with that workflow failure, I think we can probably just merge and address it in a separate PR if it sticks around

@kaitj kaitj requested a review from pvandyken May 19, 2023 16:13
@kaitj
Copy link
Contributor Author

kaitj commented May 19, 2023

Looks like making a new push fixed that workflow failure.

@pvandyken
Copy link
Contributor

@kaitj, are you still working on this one, or am I good to take another look?

@kaitj
Copy link
Contributor Author

kaitj commented May 19, 2023

@kaitj, are you still working on this one, or am I good to take another look?

Should be good for another look.

Copy link
Contributor

@pvandyken pvandyken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies again for the delay, I left some comments

docs/bids_app/plugins.md Outdated Show resolved Hide resolved
docs/bids_app/plugins.md Outdated Show resolved Hide resolved
snakebids/tests/helpers.py Outdated Show resolved Hide resolved
snakebids/tests/test_generate_inputs.py Outdated Show resolved Hide resolved
snakebids/tests/test_validate_plugin.py Show resolved Hide resolved
@kaitj kaitj requested a review from pvandyken June 7, 2023 15:58
Copy link
Contributor

@pvandyken pvandyken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for another round of comments, I think I just reviewed this too late last night

docs/running_snakebids/overview.md Outdated Show resolved Hide resolved
docs/running_snakebids/overview.md Outdated Show resolved Hide resolved
snakebids/core/input_generation.py Outdated Show resolved Hide resolved
snakebids/plugins/validator.py Show resolved Hide resolved
snakebids/plugins/validator.py Show resolved Hide resolved
snakebids/plugins/validator.py Show resolved Hide resolved
@kaitj kaitj force-pushed the bids-plugin branch 3 times, most recently from 2bde868 to 8ba03a7 Compare June 8, 2023 19:58
@kaitj kaitj requested a review from pvandyken June 8, 2023 20:02
Copy link
Contributor

@pvandyken pvandyken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left one comment RE documentation, but I'd be okay with deferring to a future issue if you'd rather not do it here, I'll leave it up to you

snakebids/plugins/validator.py Outdated Show resolved Hide resolved
kaitj added 3 commits June 22, 2023 13:26
- add validation via node.js Bids-Validator
- add information about use of validation and plugins to the
documentation
- ignore validation on existing test cases
- create test cases for BidsValidator plugin
- make validate=False default behaviour
- fix bug with subprocess call for bids-validator
- use a namespaced config key (e.g. plugins.validator.param)
- update documentation for namespaced key example
kaitj added 9 commits June 22, 2023 13:26
- validate with pybids if bids-validation is to be performed (regardless
of ability to use bids-validator
- update overview to include link to plugins page for using / creating
plugins
- revamp plugins doc to split use and creation of plugins
  - using plugins demonstrates how to add a plugin to the snakebids app
with distributed validator as example
  - creating plugins updated from function to callable class
  - highlights recommended practices for inheriting from
SnakebidsPluginError for errors and namespaced keys for config
- fix doc and cookiecutter typos / grammar
- rename validate.py -> validator.py for consistency
- remove app assignment (self.app -> app)
- remove logger from validator testing
- clarify '...callable class...' -> '...function or callable class...'
- fix spelling
@kaitj kaitj force-pushed the bids-plugin branch 2 times, most recently from 61edbbc to d733c9f Compare June 22, 2023 17:37
- remove mention of uncommenting lines
- rephrased "Enable by default..." to "Boilerplate starts with the
validator plugin enabled..." in the overview doc
- focused docstring of validation using pybids in `generate_inputs()`
- associte pybids validate logic to plugins.validator.skip
(--skip-bids-validation), which will make it simpler for downstream devs
  - left plugins.validator.success in as it can still be used for more
complex logic if desired
- instantiate validator plugin in boilerplate
- moved docstring under `__call__`
- replaced `__init__` with attr
- remove logic comments in Snakefile
- replace individual #noqa: PLR0913 calls to ignore under ruff
configuration
@kaitj kaitj mentioned this pull request Jun 22, 2023
@kaitj kaitj merged commit e3f6da8 into khanlab:main Jun 23, 2023
@kaitj kaitj deleted the bids-plugin branch June 23, 2023 12:02
@kaitj kaitj changed the title Bids-validator plugin Add BidsValidator Plugin Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integrate bids validator by default into snake bids
3 participants