-
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
[Bug]: DTR validation assumes table is set and raises warning aggressively #962
Comments
In principle, any type can be a root, the only restriction, I believe is that the |
That being said, this is the logic that at least However, having an explicit variable to indicate whether a container is the root would be useful. I don't think such a change to the API would affect many users, but it would likely affect a lot of tests in HDMF (and possibly in PyNWB). |
I like the idea of passing it in to the constructor. That is effectively how LinkML uses their Also, the root object doesn't have a name on disk. The name is set to "root" for the root container in memory on read. On write, the name of the root container is currently ignored and just happens to be set to "root" in the case of NWBFile.
So ZarrIO will not currently work correctly when writing/reading a DynamicTable or other Container named something else? |
@oruebel At least in HDF5, the name of the root container is not written. Does Zarr write the root container name to disk? |
Same thing in Zarr. But bott ZarrIO and HDF5IO define |
What happened?
See catalystneuro/ndx-photometry#8
Using HDMF 3.7.0, when a table T1 containing a
DynamicTableRegion
R is added to another container T2, HDMF checks whetherDynamicTableRegion
R references a table that shares an ancestor with T2 to warn the user that the referenced table hasn't been added to the file hierarchy.This check assumes that R.table has been set, which is not always the case on initialization. An error is raised when it is not yet set. We should check for that case.
Also when T1 is added to T2, it is not always the case that R.table should have always been added to an ancestor of T2. The warning seems premature and aggressively requires a particular order of operations that I think is awkward. See my changes in https://github.com/NeurodataWithoutBorders/pynwb/pull/1778/files . For example, to create objects in PyNWB before adding them to an
NWBFile
, you have to do something like:instead of, which used to work without a warning and feels more natural.
I think we should relax this check so that it only runs when adding objects to the top-level File object. To accommodate that, we could either create a new class for
HdmfFile
that another class likeNWBFile
can inherit from, or add a new class variable__is_root_type
on Container that indicates whether the class represents a top-level File object thatNWBFile
and any other top-level class from an HDMF extension can set to True. Option 1 supports code reuse but there's no code to put inHdmfFile
. Option 2 is more flexible and avoids edge cases that can occur when generating classes with multiple inheritance, so I prefer Option 2.Steps to Reproduce
Traceback
No response
Operating System
macOS
Python Executable
Conda
Python Version
3.11
Package Versions
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: