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 memmap option to asdf.open #1667

Merged
merged 4 commits into from
Dec 18, 2023
Merged

Conversation

braingram
Copy link
Contributor

@braingram braingram commented Oct 24, 2023

This is the first in a sequence of changes to switch copy_arrays to memmap and to change the default to not memmap. I'm proposing that we do the following:

  • introduce memmap as a new argument to asdf.open (this PR) which when set, overrides copy_arrays. Introducing this first will allow libraries that use copy_arrays to switch to memmap. The documentation for memmap includes a warning that the default for this option will change in an upcoming version of asdf.
  • after asdf 3.1 is released, open another PR that deprecates copy_arrays with a warning that describing using memmap and that the default will change.
  • for asdf 4.0, remove copy_arrays and switch memmap to default to False

If the above plan is agreeable I will open issues to track the second and third changes and milestone them for 3.2 and 4.0 respectively.

devdeps failures are unrelated and addressed in: #1665

@braingram braingram requested a review from a team as a code owner October 24, 2023 20:19
@braingram braingram force-pushed the memmap_arrays branch 2 times, most recently from 405cf1c to 2e09f0f Compare October 24, 2023 20:24
@braingram braingram added this to the 3.1.0 milestone Oct 24, 2023
@braingram braingram force-pushed the memmap_arrays branch 3 times, most recently from 9a8346e to 28c99c4 Compare October 30, 2023 14:58
Copy link
Member

@zacharyburnett zacharyburnett left a comment

Choose a reason for hiding this comment

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

sorry to take so long to review this!

asdf/asdf.py Outdated
@@ -116,6 +117,14 @@ def __init__(
When `False`, when reading files, attempt to memmap underlying data
arrays when possible.

memmap_arrays : bool, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it more accurate to call this memmap_blocks? Or is it truly only arrays that are memory-mapped?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm. I think blocks is a better match as arrays can be inline (and not memapped). Thanks! I'll update this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On second thought, should we just make this memmap?

Copy link
Contributor Author

@braingram braingram Dec 11, 2023

Choose a reason for hiding this comment

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

I updated this PR to use memmap. I'm happy to discuss alternatives (like memmap_blocks) and don't feel strongly about the naming of this argument. I went with memmap for a few reasons:

  • it's shorter to type than memmap_blocks which still describing the basic option (memory mapping)
  • in case we come up with some new crazy way to memory map things (like the tree) the option should be forward compatible
  • although not a general goal of asdf, it does more closely match the astropy API for fits files

@braingram braingram changed the title add memmap_arrays option to asdf.open add memmap option to asdf.open Dec 11, 2023
@braingram braingram merged commit 45b1661 into asdf-format:main Dec 18, 2023
33 checks passed
@braingram braingram deleted the memmap_arrays branch December 18, 2023 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants