Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions xarray/backends/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,21 @@ def guess_engine(
def get_backend(engine: str | type[BackendEntrypoint]) -> BackendEntrypoint:
"""Select open_dataset method based on current engine."""
if isinstance(engine, str):
engines = list_engines()
if engine not in engines:
raise ValueError(
f"unrecognized engine '{engine}' must be one of your download engines: {list(engines)}. "
"To install additional dependencies, see:\n"
"https://docs.xarray.dev/en/stable/user-guide/io.html \n"
"https://docs.xarray.dev/en/stable/getting-started-guide/installing.html"
)
backend = engines[engine]
if engine in BACKEND_ENTRYPOINTS:
# fast path for built-in engines
backend_cls = BACKEND_ENTRYPOINTS[engine][1]
set_missing_parameters({engine: backend_cls})
backend = backend_cls()
else:
engines = list_engines()
if engine not in engines:
raise ValueError(
f"unrecognized engine '{engine}' must be one of your download engines: {list(engines)}. "
"To install additional dependencies, see:\n"
"https://docs.xarray.dev/en/stable/user-guide/io.html \n"
"https://docs.xarray.dev/en/stable/getting-started-guide/installing.html"
)
backend = engines[engine]
elif issubclass(engine, BackendEntrypoint):
backend = engine()
else:
Expand Down
Loading