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

Avoid unnecessary copy to intermediate store #150

Merged
merged 3 commits into from
Feb 22, 2024

Conversation

ghiggi
Copy link
Contributor

@ghiggi ghiggi commented Feb 22, 2024

Hi @rabernat !

I guess I find a case where rechunker unnecessary create copies to the intermediate store.
It's a small fix but it avoid wasting computations when the rechunking can be done without intermediate copies to disk.

Here below a reproducible example of when he could occur:

import numpy as np
import dask.utils 
from rechunker.algorithm import rechunking_plan

dtype = np.dtypes.Float32DType()
itemsize = dtype.itemsize

shape = (1000, 2000, 2000)
source_chunks = (1, 2000, 2000) 
target_chunks = (1000, 4, 4)


max_mem = dask.utils.parse_bytes("20 GB")


read_chunks, int_chunks, write_chunks = rechunking_plan(
    shape=shape,
    source_chunks=source_chunks,
    target_chunks=target_chunks,
    itemsize=itemsize,
    max_mem=max_mem,
    consolidate_reads=False,
)

print(read_chunks)
print(int_chunks)
print(write_chunks)

@rabernat
Copy link
Member

Thanks for this! Please add a test.

Copy link

codecov bot commented Feb 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ba7efc0) 70.03% compared to head (bddeb19) 96.12%.
Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master     #150       +/-   ##
===========================================
+ Coverage   70.03%   96.12%   +26.09%     
===========================================
  Files          11       11               
  Lines         554      568       +14     
  Branches      106      113        +7     
===========================================
+ Hits          388      546      +158     
+ Misses        149       14      -135     
+ Partials       17        8        -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ghiggi
Copy link
Contributor Author

ghiggi commented Feb 22, 2024

@rabernat done ;)

@rabernat
Copy link
Member

Great thank you. I don't know why the doc build is failing. Everything else looks good.

@rabernat rabernat merged commit a22f556 into pangeo-data:master Feb 22, 2024
8 of 9 checks passed
@ghiggi
Copy link
Contributor Author

ghiggi commented May 22, 2024

Hey @rabernat. Sorry to bother you. Would be possible to make a new package release with this PR included? Let me know if I can help in some way ;)

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.

2 participants