-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix distributed writes #1793
fix distributed writes #1793
Changes from 5 commits
63abe7f
1952173
dd4bfcf
5c7f94c
9e70a3a
ec67a54
2a4faa4
5497ad1
c2f5bb8
5344fe8
7cbd2e5
49366bf
323f17b
81f7610
199538e
d2050e7
76675de
9ac0327
05e7d54
1672968
a667615
2c0a7e8
6bcadfe
aba6bdc
5702c67
a06b683
efe8308
6ef31aa
00156c3
3dcfac5
29edaa7
61ee5a8
91f3c6a
5cb91ba
2b97d4f
2dc514f
eff0161
5290484
c855284
3c2ffbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,11 @@ def __init__(self, variable_name, datastore): | |
dtype = np.dtype('O') | ||
self.dtype = dtype | ||
|
||
def __setitem__(self, key, value): | ||
with self.datastore.ensure_open(autoclose=True): | ||
data = self.get_array() | ||
data[key] = value | ||
|
||
def get_array(self): | ||
self.datastore.assert_open() | ||
return self.datastore.ds.variables[self.variable_name] | ||
|
@@ -376,7 +381,9 @@ def prepare_variable(self, name, variable, check_encoding=False, | |
# OrderedDict as the input to setncatts | ||
nc4_var.setncattr(k, v) | ||
|
||
return nc4_var, variable.data | ||
target = NetCDF4ArrayWrapper(name, self) | ||
|
||
return target, variable.data | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jhamman There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @fujiisoup - it is used in line 405 ( |
||
|
||
def sync(self): | ||
with self.ensure_open(autoclose=True): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,11 @@ def __getitem__(self, key): | |
copy = self.datastore.ds.use_mmap | ||
return np.array(data, dtype=self.dtype, copy=copy) | ||
|
||
def __setitem__(self, key, value): | ||
with self.datastore.ensure_open(autoclose=True): | ||
data = self.get_array() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be (This manifests itself in writing a netcdf file with a time dimension of length 0. Xarray then crashes when attempting to a decode a length 0 time variable, which is an unrelated bug.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @shoyer - this appears to fix the scipy issue. |
||
data[key] = value | ||
|
||
|
||
def _open_scipy_netcdf(filename, mode, mmap, version): | ||
import scipy.io | ||
|
@@ -202,7 +207,10 @@ def prepare_variable(self, name, variable, check_encoding=False, | |
for k, v in iteritems(variable.attrs): | ||
self._validate_attr_key(k) | ||
setattr(scipy_var, k, v) | ||
return scipy_var, data | ||
|
||
target = ScipyArrayWrapper(name, self) | ||
|
||
return target, data | ||
|
||
def sync(self): | ||
with self.ensure_open(autoclose=True): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shoyer, is this what you were describing in #1464 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this looks right to me.