hdmf
hdmf copied to clipboard
Difference in validation errors depending on order of GroupBuilder children
Description
With the current method for matching builders against specs for the children of a GroupBuilder, it is possible for the validation errors to differ depending on the order of the child builders.
Eg:
- A group spec has two required unnamed child datasets of types A and B (ordered in that way), where dataset B inherits from A
- A group builder has two child datasets: 'a' of type A, and 'b' of type B
- If the order of the child dataset builders is ['a', 'b'], then 'a' satisfies spec A first, and then 'b' gets assigned to spec B. So no validation errors are returned
- If the order of the child dataset builders is ['b', 'a'], then 'b' satisfies spec A first (since B inherits from A), and then 'a' cannot satisfy B. So a validation error is raised.
Steps to Reproduce
Compare these two unit tests: https://github.com/hdmf-dev/hdmf/blob/45dee5c0da076fa7bedea3ba63d1f6c8d7585c88/tests/unit/validator_tests/test_validate.py#L797-L808 https://github.com/hdmf-dev/hdmf/blob/45dee5c0da076fa7bedea3ba63d1f6c8d7585c88/tests/unit/validator_tests/test_validate.py#L811-L823
Note: the second test should be enabled once this issue is resolved.
Environment
Python Executable: Python
Python Version: Python 3.8
Operating System: Linux
HDMF Version: 2.4.0
Checklist
- [x] Have you ensured the bug was not already reported ?
- [x] Have you included a brief and descriptive title?
- [x] Have you included a clear description of the problem you are trying to solve?
- [x] Have you included a minimal code snippet that reproduces the issue you are encountering?
- [x] Have you checked our Contributing document?