Skip to content

Commit 33eafb3

Browse files
wroberts4William RobertsTomNicholas
authored
Fix reading from fsspec s3 xarray-contrib/datatree#130
* Fix pointer not at the start of the file error * whatsnew Co-authored-by: William Roberts <[email protected]> Co-authored-by: Tom Nicholas <[email protected]>
1 parent 8ac4cc1 commit 33eafb3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

datatree/io.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def open_datatree(filename_or_obj, engine=None, **kwargs) -> DataTree:
6363
def _open_datatree_netcdf(filename: str, **kwargs) -> DataTree:
6464
ncDataset = _get_nc_dataset_class(kwargs.get("engine", None))
6565

66+
ds = open_dataset(filename, **kwargs)
67+
tree_root = DataTree.from_dict({"/": ds})
6668
with ncDataset(filename, mode="r") as ncds:
67-
ds = open_dataset(filename, **kwargs)
68-
tree_root = DataTree.from_dict({"/": ds})
6969
for path in _iter_nc_groups(ncds):
7070
subgroup_ds = open_dataset(filename, group=path, **kwargs)
7171

docs/source/whats-new.rst

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ Documentation
4646
Internal Changes
4747
~~~~~~~~~~~~~~~~
4848

49+
- Avoid reading from same file twice with fsspec3 (:pull:`130`)
50+
By `William Roberts <https://github.com/wroberts4>`_.
51+
52+
4953
.. _whats-new.v0.0.9:
5054

5155
v0.0.9 (07/14/2022)

0 commit comments

Comments
 (0)