Skip to content

open_datatree not accepting backend-specific keyword arguments #9135

Closed
@kmnhan

Description

@kmnhan

What happened?

Following #9014, open_datatree no longer passes on backend-specific keyword arguments. For instance, I have a few HDF5 datasets with unassociated dimension scales, and those require phony_dims='sort' or phony_dims='access' to be opened. Now, the keyword arguments are passed onto StoreBackendEntrypoint.open_dataset instead of H5netcdfBackendEntrypoint.open_dataset which results in a TypeError.

What did you expect to happen?

open_datatree methods of backends should pass backend-specific keyword arguments to H5NetCDFStore.open or the like.

Minimal Complete Verifiable Example

import h5py
from xarray.backends.api import open_datatree

file = h5py.File("./test.h5", "w")
data = file.create_dataset("dataset", shape=(10, 20, 30), dtype="float32")
file.close()

try:
    open_datatree("./test.h5")  # this is normal
except ValueError as e:
    print(e, "\n")
# variable '/dataset' has no dimension scale associated with axis 0.
# Use phony_dims='sort' for sorted naming or phony_dims='access' for per access naming.

try:
    open_datatree("./test.h5", phony_dims="sort")  # used to work, now raises TypeError
except TypeError as e:
    print(e)
# StoreBackendEntrypoint.open_dataset() got an unexpected keyword argument 'phony_dims'

MVCE confirmation

  • Minimal example — the example is as focused as reasonably possible to demonstrate the underlying issue in xarray.
  • Complete example — the example is self-contained, including all data and the text of any traceback.
  • Verifiable example — the example copy & pastes into an IPython prompt or Binder notebook, returning the result.
  • New issue — a search of GitHub Issues suggests this is not a duplicate.
  • Recent environment — the issue occurs with the latest version of xarray and its dependencies.

Relevant log output

No response

Anything else we need to know?

No response

Environment

INSTALLED VERSIONS

commit: None
python: 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:13:44) [Clang 16.0.6 ]
python-bits: 64
OS: Darwin
OS-release: 23.5.0
machine: arm64
processor: arm
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: ('en_US', 'UTF-8')
libhdf5: 1.14.3
libnetcdf: None

xarray: 2024.6.0
pandas: 2.2.2
numpy: 2.0.0
scipy: None
netCDF4: None
pydap: None
h5netcdf: 1.3.0
h5py: 3.11.0
zarr: None
cftime: None
nc_time_axis: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
fsspec: None
cupy: None
pint: None
sparse: None
flox: None
numpy_groupies: None
setuptools: 70.0.0
pip: 24.0
conda: None
pytest: None
mypy: None
IPython: None
sphinx: None
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtopic-DataTreeRelated to the implementation of a DataTree class

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions