-
Notifications
You must be signed in to change notification settings - Fork 21
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
fix(memh5): fix a bug where shared datasets weren't actually shared #239
Conversation
f6021e3
to
897e85b
Compare
897e85b
to
c3dc714
Compare
714b167
to
19d5c0c
Compare
19d5c0c
to
196849f
Compare
fe5dfdb
to
fcd3cc1
Compare
I have just been looking through this one again and reflecting on what the behaviour should be. It's not clear to me at what level a shared dataset should be shared. Really the only purpose of it is to save on memory, so anything that does that is fine. I'm not sure about shared datasets maintaining that through redistribution though, it also might be good to allow shared selections but that has its own implications. |
I think that it's valid for a user to expect that a shared dataset would remain shared through a redistribution, since that's a common operation and it defeats the purpose of memory savings if we lose those savings the moment we redistribute. Selection is tricky since it would effectively have to replace the memdataset within the group with a new one with the selections applied, so I'm not sure how that would work without modifying the way memdatasets are referenced by the group (i.e., rather than the shared dataset just pointing to the same object, it would somehow have to point to a reference in the group tree which in turn references a dataset object, so if the dataset object changed the tree reference would still be the same thing). Unless you just mean applying selections during the copy, which has the potential to be tricky as well and probably wouldn't be used enough to be worth the effort (right now someone could just make the selection then make a shared copy, which would work fine) |
fcd3cc1
to
b84ce8a
Compare
b84ce8a
to
d923852
Compare
d923852
to
8b8a462
Compare
8b8a462
to
0603c2e
Compare
0603c2e
to
098847e
Compare
098847e
to
8c4ff16
Compare
8c4ff16
to
b3d7415
Compare
b3d7415
to
45ea205
Compare
45ea205
to
6a4ec97
Compare
6a4ec97
to
074fdeb
Compare
@ketiltrout I've updated this to simplify the copy pathways and address the
|
@ketiltrout I also removed an extra byte order check, which was required for a now-fixed mpi4py bug. |
48b5022
to
fddebde
Compare
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.
Yeah, this looks a lot better! I've made a few suggestions for your docstring.
One potential thing I've though of:
In the case when g2
is a file, instead of ignoring shared
, another option would be to raise a ValueError
on a non-empty value. I don't know if that's better or worse than what you've implemented.
ValueError
could help users find catch where they've maybe misconstrued their call to deep_group_copy
, but the downside is it forces any call to deep_group_copy
to be type-aware (i.e. of the type g2
), which may be a worse problem.
fddebde
to
144b655
Compare
I've decided to meet in the middle and add a warning. I don't really think we would want this to fail entirely, but it's worth letting the user know that something is happening that they didn't expect |
Yeah, that's a good compromise. |
Previously, 'deep_group_copy' would, by default, copy the 'MemDataset' object of each dataset, but would continue to point to the same underlying data array. This led to confusing behaviour where data would end up only partially shared between two groups. These changes restrict copying to one of two pathways: full deep copy or full sharing of the 'MemDataset' object and all its attributes. Sharing is explicitly disabled when copying from memory to disk.
This was originally required to fix a bug in mpi4py/mpi4py#177 This bug has now been fixed in mpi4py/mpi4py#179
144b655
to
b7bc6e3
Compare
This PR makes the
shared
argument inMemDiskGroup
actually share theMemDataset
object and not just the underlying data array. Based on the idea of shared datasets being maintained through operations such as redistribution, axis downselection is not allowed for shared datasets.It's important to note that the default behaviour of
memh5.deep_group_copy
is (and has been since inception) to only make a shallow copy of theMemDataset
- i.e., the underlying array is actually shared. It doesn't matter when using this method to copy from disk -> memory or memory-> disk, but it does have implications when copying memory -> memory. This probably shouldn't be the default behaviour, but we would have to be extremely careful if making any changes to avoid breaking anything.I've also updated the docstring for
deep_group_copy
to make note of the copy behaviour.This lets us remove the
.copy
method indraco.ContainerBase
as it will properly replicate that behaviour (see radiocosmology/draco#231)Also, add an option to skip specific datasets when copying.