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

Support HighLevelGraphs #2603

Merged
merged 4 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,9 @@ def __dask_graph__(self):
def __dask_keys__(self):
return self._to_temp_dataset().__dask_keys__()

def __dask_layers__(self):
return self._to_temp_dataset().__dask_layers__()

@property
def __dask_optimize__(self):
return self._to_temp_dataset().__dask_optimize__
Expand Down
13 changes: 11 additions & 2 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,23 @@ def __dask_graph__(self):
if not graphs:
return None
else:
from dask import sharedict
return sharedict.merge(*graphs.values())
try:
from dask.highlevelgraph import HighLevelGraph
return HighLevelGraph.merge(*graphs.values())
except ImportError:
from dask import sharedict
return sharedict.merge(*graphs.values())


def __dask_keys__(self):
import dask
return [v.__dask_keys__() for v in self.variables.values()
if dask.is_dask_collection(v)]

def __dask_layers__(self):
return sum([v.__dask_layers__() for v in self.variables.values() if
dask.is_dask_collection(v)], [])
Copy link
Member

Choose a reason for hiding this comment

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

I think you need to add a local import dask here since dask isn't a hard dependency. This suggests there isn't any coverage for this new method -- is there any easy way to add that?


@property
def __dask_optimize__(self):
import dask.array as da
Expand Down
3 changes: 3 additions & 0 deletions xarray/core/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ def __dask_graph__(self):
def __dask_keys__(self):
return self._data.__dask_keys__()

def __dask_layers__(self):
return self._data.__dask_layers__()

@property
def __dask_optimize__(self):
return self._data.__dask_optimize__
Expand Down