-
Notifications
You must be signed in to change notification settings - Fork 26
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
Validation finds unexpected elements #542
Validation finds unexpected elements #542
Conversation
* Ref hdmf-dev#288 * Starting a new PR but taking appropriate changes from the above PR * Ref NeurodataWithoutBorders/pynwb#942 * GroupValidator returns ExtraFieldWarning for extra groups, datasets, and links * Includes unit tests covering the new warning * Attribute validation WIP
* Ref hdmf-dev#288 * Starting a new PR but taking appropriate changes from the above PR * Ref NeurodataWithoutBorders/pynwb#942 * Temporary solution for handling reserved attributes, will be fixed in later commit * Includes unit tests for attribute validation
…ation type issue * Ref hdmf-dev#288 * Starting a new PR but taking appropriate changes from the above PR * Ref NeurodataWithoutBorders/pynwb#942 * Validator now skips validation of reserved attributes provided by the spec * Discovered and resolved an issue where the validator was validating a group child based on the parent groups spec instead of the actual type of the builder. This is important when an inheriting class has additional attributes. * Added a regression test case for this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks great, thanks for taking this on. A few change requests. There's only one real issue (See SpecMatch object). The rest are trivial docstring request.
@ajtritt thanks for the review! Good suggestions. In working through this, I began wondering if it could be beneficial to introduce an
If you think this could potentially be beneficial, I can create an issue to discuss in more detail |
…_unexpected_elements
@ajtritt @rly I merged in changes from dev, but unfortunately now we have failing tests. The cause seems to be due to a combination of three things:
I think the ideal solution is to make the ValidatorMap be aware of multiple namespaces, but I think that is probably better as a separate issue, do you both agree? Until that issue is complete, how would you feel about adjusting |
Nice job hunting down the source of the issue.
Yes, I think that is a great idea. |
I was, but it is not yet ready. If you want, you can take a stab at it, but I won't be able to get to it until at least a week post-hackathon. |
* Responding to: hdmf-dev#542 (comment) * Create severity level constants for warnings and errors
I updated the H5RoundTripMixin to only fail on validation errors and warn on validation warnings
I'm not entirely certain the warning inside the unit test is valuable and might add noise, so let me know if you'd prefer without the warning and I'll update. |
I see that many pynwb tests failed due to the new validation warning. Most of them look like they'll be fixed by adding As a longer-term strategy (once we fix validation of multiple namespaces), do we want tests to fail on validator warnings or only on errors? |
Do you have some examples about pynwb validation warnings due to this PR here? |
@t-b the errors I was referring to are from the There were many errors happening because the validator was not recognizing There are a few remaining pynwb tests failing, but most don't appear to have anything to do with this PR. There are 4 failing tests related to extra field warnings, all of them from the integration tests in
The schema for Should specs that only define If not, then I think either Do you agree with my evaluation? |
…by inheriting specs * Ref NeurodataWithoutBorders/pynwb#942 * Ref NeurodataWithoutBorders/pynwb#1178
Okay, question answered ;)
Yes I agree. Specifically I would say to
No. This is also my understanding when rereading https://schema-language.readthedocs.io/en/latest/specification_language_description.html#group-specification-keys. I don't know what the fallout from changing something deep like that is though. If we fix that I think we want to complain already when parsing the spec YAML files. @rly Any thoughts? |
Ok, then assuming the spec for
That way we can be unblocked from including the new warnings in hdmf and pynwb and discuss how to fix the spec separately.
This seems like a great idea to me! |
@dsleiter Sounds good! The failing pynwb tests are validating old NWB files without cached spec. So yes making the error currently encountered into a warning sounds like a good approach. EDIT: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, nice work!
Also try to trigger GH Action for codecov...
@dsleiter I'm reviewing this and so far so good. For this PR and the future, could you please enable GitHub Actions in your fork of HDMF if it is not already enabled? I know we've had a lot of back and forth regarding how to trigger CI on forks with varying success. I think doing this would allow the codecov CI run, but I am not 100% sure. I might still need to update the workflow or do something like what is mentioned here https://securitylab.github.com/research/github-actions-preventing-pwn-requests |
@dsleiter Oh, never mind. It looks like GitHub Actions does run and uploads to https://app.codecov.io/gh/agencyenterprise/hdmf and probably for security reasons, codecov does not comment in this PR and the checks are not shown here. I might look into this more, but it's not that important. |
Looks all good to me! Thanks @dsleiter! |
I'll look into this before we release the next version of nwb-schema. |
Thanks for the reviews and merge @ajtritt and @rly! @rly RE: codecov - nice to see that the github actions are working and the report is at least uploaded to our codecov. Looks like the comment on the PR is made by a codecov bot - do you have this github app configured for this repo? https://github.com/apps/codecov I will see if we can get it installed on agencyenterprise/hdmf, in which case maybe it'll post from our codecov to any of my PRs here. |
@dsleiter Yes, nice work. Especially thanks for picking it up where I left it. |
* Fix hdmf-dev#585 * Ref hdmf-dev#542 * Builder can now be validated against more than one spec in order to validate against additional fields added to inner data types * Also make validation Errors comparable as a way to remove duplicates that can sometimes be generated
…ecs (#609) * Validate builders against both top level data type specs and inner specs * Fix #585 * Ref #542 * Builder can now be validated against more than one spec in order to validate against additional fields added to inner data types * Also make validation Errors comparable as a way to remove duplicates that can sometimes be generated * Update changelog * Ref #585 * Fix pynwb validation errors related to reference and compound data types * Ref #585 * This is just a workaround for checking the data_type of BuilderH5ReferenceDataset and BuilderH5TableDataset objects * Plan to add unit tests after some discussion to validate the approach * Remove validator reference to H5-specific classes and add unit tests * use ReferenceResolver instead of referencing BuilderH5ReferenceDataset or BuilderH5TableDataset * Fix #585 * Update tests/unit/validator_tests/test_validate.py * Update tests/unit/validator_tests/test_validate.py Co-authored-by: Ryan Ly <[email protected]>
…ecs (#609) * Validate builders against both top level data type specs and inner specs * Fix #585 * Ref #542 * Builder can now be validated against more than one spec in order to validate against additional fields added to inner data types * Also make validation Errors comparable as a way to remove duplicates that can sometimes be generated * Update changelog * Ref #585 * Fix pynwb validation errors related to reference and compound data types * Ref #585 * This is just a workaround for checking the data_type of BuilderH5ReferenceDataset and BuilderH5TableDataset objects * Plan to add unit tests after some discussion to validate the approach * Remove validator reference to H5-specific classes and add unit tests * use ReferenceResolver instead of referencing BuilderH5ReferenceDataset or BuilderH5TableDataset * Fix #585 * Update tests/unit/validator_tests/test_validate.py * Update tests/unit/validator_tests/test_validate.py Co-authored-by: Ryan Ly <[email protected]>
Motivation
The validator now returns warnings on any extra fields that it finds.
docval
usage to the spec matching utility classes as discussed here: Ensure all specs are validated #526 (comment)How to test the behavior?
Simple example:
Review and run all new unit tests for full coverage.
Checklist
flake8
from the source directory.