Skip to content

Commit

Permalink
fixed dask prefix naming (pydata#1411)
Browse files Browse the repository at this point in the history
* fixed dask prefix naming

* fixed tests

* fixed token

* added whats new
  • Loading branch information
rabernat authored and shoyer committed May 22, 2017
1 parent 028454d commit d802484
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
3 changes: 3 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ Enhancements
By `Chun-Wei Yuan <https://github.com/chunweiyuan>`_ and
`Kyle Heuton <https://github.com/kheuton>`_.

- Rename the dask arrays created by `open_dataset` to match new dask conventions
(:issue:`1343`). By `Ryan Abernathey <https://github.com/rabernat>`_.

- Enhanced tests suite by use of ``@network`` decorator, which is
controlled via ``--run-network-tests`` command line argument
to ``py.test`` (:issue:`1393`).
Expand Down
14 changes: 8 additions & 6 deletions xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,17 @@ def maybe_decode_store(store, lock=False):
else:
raise

# if passed an actual file path, augment the token with
# the file modification time
if (isinstance(filename_or_obj, basestring) and
not is_remote_uri(filename_or_obj)):
file_arg = os.path.getmtime(filename_or_obj)
mtime = os.path.getmtime(filename_or_obj)
else:
file_arg = filename_or_obj
token = tokenize(file_arg, group, decode_cf, mask_and_scale,
decode_times, concat_characters, decode_coords,
engine, chunks, drop_variables)
name_prefix = '%s:%s/' % (filename_or_obj, group or '')
mtime = None
token = tokenize(filename_or_obj, mtime, group, decode_cf,
mask_and_scale, decode_times, concat_characters,
decode_coords, engine, chunks, drop_variables)
name_prefix = 'open_dataset-%s' % token
ds2 = ds.chunk(chunks, name_prefix=name_prefix, token=token,
lock=lock)
ds2._file_obj = ds._file_obj
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ def test_deterministic_names(self):
for k, v in ds.data_vars.items())
for var_name, dask_name in original_names.items():
self.assertIn(var_name, dask_name)
self.assertIn(tmp, dask_name)
self.assertEqual(dask_name[:13], 'open_dataset-')
self.assertEqual(original_names, repeat_names)

def test_dataarray_compute(self):
Expand Down

0 comments on commit d802484

Please sign in to comment.