You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Revamp Dask Array creation logic to be fully blockwise #105
When dask/dask#7417 gets in, it may both break the current dask-array-creation hacks, and open the door for a much, much simpler approach: just use da.from_array.
We didn't use da.from_array originally and went through all the current rigamarole because from_array generates a low-level graph, which can be enormous (and slow) for the large datasets we load. But once from_array uses Blockwise, it will be far simpler and more efficient.
We'll just switch to having an array-like class that wraps the asset table and other parameters, and whose __getitem__ basically calls fetch_raster_window. However, it's likely worth thinking about just combining all this into the Reader protocol in some way.
This will also make it easier to do #62 (and may even inadvertently solve it).
Thinking about this a bit more, we may want to stick with the current approach (or a form of it).
Currently, we make one initial array of (time, band)—this is the "asset table". Each asset (file) is its own chunk. We map a function over this opening each file.
Then we make an array of (y, x) containing the slice needed to do a windowed read to cover that spatial area. This is currently low-level, but could easily become blockwise using a BlockwiseDep like this.
When you broadcast those two arrays together, you get the (time, band, y, x) final array.
The nice things are:
The Reader (rio Dataset) for each file is a separate dask key. This is reasonable—Datasets are not lightweight things to move around.
Opening each Dataset gets its own task.
Reading from the dataset depends on the dataset's key (as opposed to implicitly opening the dataset). This means Dask will prefer to schedule reads from a given Dataset onto workers that already have that dataset open.
Without this, I'd worry that we'd basically end up re-opening every dataset on every worker.
If we used from_array with a giant array-like object, we'd kind of be saying that opening any particular file, at any particular coordinates, had equal cost. Opening two different files at the same coordinates appear to be equivalent to opening the same file at two different coordinates—clearly not true.
Activity
gjoseph92 commentedon Dec 17, 2021
Thinking about this a bit more, we may want to stick with the current approach (or a form of it).
Currently, we make one initial array of
(time, band)—this is the "asset table". Each asset (file) is its own chunk. We map a function over this opening each file.Then we make an array of
(y, x)containing thesliceneeded to do a windowed read to cover that spatial area. This is currently low-level, but could easily become blockwise using a BlockwiseDep like this.When you broadcast those two arrays together, you get the
(time, band, y, x)final array.The nice things are:
The
Reader(rio Dataset) for each file is a separate dask key. This is reasonable—Datasets are not lightweight things to move around.Opening each Dataset gets its own task.
Reading from the dataset depends on the dataset's key (as opposed to implicitly opening the dataset). This means Dask will prefer to schedule reads from a given Dataset onto workers that already have that dataset open.
Without this, I'd worry that we'd basically end up re-opening every dataset on every worker.
If we used
from_arraywith a giant array-like object, we'd kind of be saying that opening any particular file, at any particular coordinates, had equal cost. Opening two different files at the same coordinates appear to be equivalent to opening the same file at two different coordinates—clearly not true.gjoseph92 commentedon Feb 2, 2022
Addressed in #116