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

Use the Zarr's new getitems() API #131

Merged
merged 23 commits into from
Jun 21, 2023

Conversation

madsbk
Copy link
Member

@madsbk madsbk commented Sep 13, 2022

By using the new API in zarr-developers/zarr-python#1131, we do not have to guess whether to read into host or device memory. That is, no more filtering of specify keys like:

 if os.path.basename(fn) in [ 
     zarr.storage.array_meta_key, 
     zarr.storage.group_meta_key, 
     zarr.storage.attrs_key, 
 ]: 

Notice, this PR is on hold until Zarr v2.15 is released

Closes #119

UPDATE: Zarr v2.15 has been released

@madsbk madsbk added improvement Improves an existing functionality non-breaking Introduces a non-breaking change labels Sep 13, 2022
@madsbk madsbk changed the base branch from branch-22.10 to branch-22.12 October 12, 2022 11:36
@jakirkham jakirkham deleted the branch rapidsai:branch-23.08 January 4, 2023 21:49
@jakirkham jakirkham closed this Jan 4, 2023
@jakirkham jakirkham reopened this Jan 4, 2023
@jakirkham jakirkham changed the base branch from branch-22.12 to branch-23.02 January 4, 2023 21:51
@madsbk madsbk changed the base branch from branch-23.02 to branch-23.04 February 2, 2023 13:48
@madsbk madsbk changed the base branch from branch-23.04 to branch-23.06 April 17, 2023 06:55
@madsbk madsbk mentioned this pull request Apr 18, 2023
@madsbk madsbk force-pushed the zarr_getitems branch 2 times, most recently from aca8ed9 to dd82a5e Compare April 20, 2023 12:44
@madsbk madsbk closed this Apr 26, 2023
@madsbk madsbk deleted the zarr_getitems branch April 26, 2023 11:01
@madsbk madsbk restored the zarr_getitems branch April 26, 2023 11:03
@madsbk madsbk reopened this Apr 26, 2023
@madsbk madsbk mentioned this pull request Apr 28, 2023
@madsbk madsbk marked this pull request as ready for review June 19, 2023 12:55
@madsbk madsbk requested review from jakirkham and wence- June 19, 2023 12:55
Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

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

Thanks @madsbk, I think we can do a little bit of cleanup, to avoid repeating ourselves with the minimum supported version.

python/benchmarks/single-node-io.py Outdated Show resolved Hide resolved
python/kvikio/zarr.py Outdated Show resolved Hide resolved
python/kvikio/zarr.py Outdated Show resolved Hide resolved
python/kvikio/zarr.py Outdated Show resolved Hide resolved
python/kvikio/zarr.py Show resolved Hide resolved
python/tests/test_zarr.py Outdated Show resolved Hide resolved
python/tests/test_zarr.py Outdated Show resolved Hide resolved
python/tests/test_zarr.py Outdated Show resolved Hide resolved
python/tests/test_zarr.py Show resolved Hide resolved
Comment on lines 96 to 98
finally:
for f in files:
f.close()
Copy link
Contributor

Choose a reason for hiding this comment

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

The idiomatic way to do this is...

import contextlib

...
with contextlib.ExitStack() as stack:
    for key in keys:
        f = stack.enter_context(kvikio.CuFile(filepath, "r"))
        ret[key] = ..
        io_results.append((f.pread(ret[key]), nbytes)
   for fut, nbytes in io_results:
        nbytes_read = fut.get()
        ...

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll note that both the new code (and my proposed approach) leave dangling futures if the block produces an exception anywhere. I guess that is fine because that propagates and the program is hosed at that point anyway?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that is ok

@madsbk madsbk requested a review from a team as a code owner June 20, 2023 12:29
@madsbk madsbk requested a review from a team June 20, 2023 12:29
@madsbk madsbk requested a review from a team as a code owner June 20, 2023 12:29
@madsbk madsbk requested a review from wence- June 20, 2023 14:34
@madsbk
Copy link
Member Author

madsbk commented Jun 20, 2023

Thanks @wence-, I think I have addressed all of your issues.

Copy link
Contributor

@wence- wence- left a comment

Choose a reason for hiding this comment

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

Thanks Mads.

@madsbk
Copy link
Member Author

madsbk commented Jun 21, 2023

/merge

@wence-
Copy link
Contributor

wence- commented Jun 21, 2023

I think we need to wait for the other codeowners to approve too.

@rapids-bot rapids-bot bot merged commit 56d48ef into rapidsai:branch-23.08 Jun 21, 2023
25 checks passed
@jakirkham
Copy link
Member

Thanks all! 🙏

Great work 🥳

@madsbk madsbk deleted the zarr_getitems branch June 23, 2023 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improves an existing functionality non-breaking Introduces a non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter out Zarr's consolidated metadata (.zmetadata)
4 participants