diff --git a/doc/api.rst b/doc/api.rst index 85ef46ca6ba..103f3984512 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -36,6 +36,7 @@ Top-level functions dot polyval map_blocks + show_backends show_versions set_options get_options diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 0da34df2c1a..8f2c2da47b5 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -21,7 +21,8 @@ v.2024.11.1 (unreleased) New Features ~~~~~~~~~~~~ - +- Add :py:func:`~xarray.show_backends` alias for :py:func:`~xarray.backends.list_engines` (:issue:`6577`, :pull:`xxx`). + By `Nick Hodgskin `_. Breaking changes ~~~~~~~~~~~~~~~~ diff --git a/xarray/__init__.py b/xarray/__init__.py index 634f67a61a2..9e3ab68c59f 100644 --- a/xarray/__init__.py +++ b/xarray/__init__.py @@ -51,6 +51,7 @@ TreeIsomorphismError, group_subtrees, ) +from xarray.backends.plugins import show_backends from xarray.core.variable import IndexVariable, Variable, as_variable from xarray.namedarray.core import NamedArray from xarray.util.print_versions import show_versions @@ -108,6 +109,7 @@ "register_datatree_accessor", "save_mfdataset", "set_options", + "show_backends", "show_versions", "unify_chunks", "where", diff --git a/xarray/backends/plugins.py b/xarray/backends/plugins.py index 555538c2562..c4e09b5939f 100644 --- a/xarray/backends/plugins.py +++ b/xarray/backends/plugins.py @@ -132,6 +132,19 @@ def list_engines() -> dict[str, BackendEntrypoint]: return build_engines(entrypoints) +def show_backends() -> dict[str, BackendEntrypoint]: + """ + Return a dictionary of available engines and their BackendEntrypoint objects. + + This function is an alias for ``xarray.backends.list_engines``. + + Returns + ------- + dictionary + """ + return list_engines() + + def refresh_engines() -> None: """Refreshes the backend engines based on installed packages.""" list_engines.cache_clear() diff --git a/xarray/tests/test_plugins.py b/xarray/tests/test_plugins.py index 2b321ba8dfc..b5492c64c72 100644 --- a/xarray/tests/test_plugins.py +++ b/xarray/tests/test_plugins.py @@ -275,6 +275,12 @@ def test_list_engines() -> None: assert ("zarr" in engines) == has_zarr assert "store" in engines +def test_show_engines() -> None: + from xarray import show_backends + from xarray.backends import list_engines + + assert show_backends() == list_engines() + def test_refresh_engines() -> None: from xarray.backends import list_engines, refresh_engines