Skip to content

Commit 5fcb6f5

Browse files
authored
Expanduser (~) for open_dataset with dask (#6710)
1 parent 27f47d1 commit 5fcb6f5

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

doc/whats-new.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ Bug fixes
4747
pandas when decoding times outside the range that can be represented with
4848
nanosecond-precision values (:issue:`6716`, :pull:`6717`).
4949
By `Spencer Clark <https://github.com/spencerkclark>`_.
50+
- :py:meth:`open_dataset` with dask and ``~`` in the path now resolves the home directory
51+
instead of raising an error. (:issue:`6707`, :pull:`6710`)
52+
By `Michael Niklas <https://github.com/headtr1ck>`_.
5053

5154
Documentation
5255
~~~~~~~~~~~~~

xarray/backends/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ def _get_mtime(filename_or_obj):
224224
path = None
225225

226226
if path and not is_remote_uri(path):
227-
mtime = os.path.getmtime(filename_or_obj)
227+
mtime = os.path.getmtime(os.path.expanduser(filename_or_obj))
228228

229229
return mtime
230230

xarray/backends/rasterio_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ def open_rasterio(
412412

413413
# augment the token with the file modification time
414414
try:
415-
mtime = os.path.getmtime(filename)
415+
mtime = os.path.getmtime(os.path.expanduser(filename))
416416
except OSError:
417417
# the filename is probably an s3 bucket rather than a regular file
418418
mtime = None

0 commit comments

Comments
 (0)