-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Writing directly to a netCDF file while using distributed #1464
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
Comments
Hmm. Can you try using scipy as an engine to write the netcdf file? Honestly I've barely used dask distributed. Possibly @mrocklin has ideas. |
It's failing to serialize something in the task graph, I'm not sure what (I'm also surprised that the except clause didn't trigger and log the input). My first guess is that there is an open netcdf file object floating around within the task graph. If so then we should endeavor to avoid doing this (or have some file object proxy that is (de)serializable. As a short-term workaround you might try starting a local cluster within the same process.
This might help you to avoid serialization issues. Generally we should resolve the issue regardless though. cc'ing @rabernat, who seems to have the most experience here. |
Presumably there is some object in the task graph that we don't know how to serialize. This can be fixed either in XArray, by not including such an object but recreating it each time or wrapping it, or in Dask, by learning how to (de)serialize it. |
I'm a little surprised that this doesn't work because I thought we made all our xarray datastore object pickle-able. The place to start is probably to write an integration test for this functionality. I notice now that our current tests only check reading netCDF files with dask-distributed: |
I did a little bit of digging here, using @mrocklin's The problem seems to be that the arrays that we add to the writer in xarray/xarray/backends/common.py Lines 221 to 232 in f83361c
What we need to instead is wrap these If anyone's curious, here's the traceback and code I used to debug this: |
We should probably also write some tests for saving datasets with |
I've been experimenting with
distributed
recently and have run into an issue when saving a result directly to a file using thenetcdf4
engine. I've found if I compute things before saving to a file (thus loading the result into memory before callingto_netcdf
) things work OK. I attached a minimum working example below.Can others reproduce this? Part of me thinks there must be something wrong with my setup, because I'm somewhat surprised something like this wouldn't have come up already (apologies in advance if that's the case).
If I load the data into memory first by invoking
compute()
things work OK:The text was updated successfully, but these errors were encountered: