Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Engine is no longer inferred for filenames not ending in ".nc" #5295

Closed
shoyer opened this issue May 12, 2021 · 0 comments · Fixed by #5296
Closed

Engine is no longer inferred for filenames not ending in ".nc" #5295

shoyer opened this issue May 12, 2021 · 0 comments · Fixed by #5296
Labels

Comments

@shoyer
Copy link
Member

shoyer commented May 12, 2021

This works with xarray=0.17.0:

import xarray
xarray.Dataset({'x': [1, 2, 3]}).to_netcdf('tmp')
xarray.open_dataset('tmp')

On xarray 0.18.0, it fails:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-20e128a730aa> in <module>()
      2 
      3 xarray.Dataset({'x': [1, 2, 3]}).to_netcdf('tmp')
----> 4 xarray.open_dataset('tmp')

/usr/local/lib/python3.7/dist-packages/xarray/backends/api.py in open_dataset(filename_or_obj, engine, chunks, cache, decode_cf, mask_and_scale, decode_times, decode_timedelta, use_cftime, concat_characters, decode_coords, drop_variables, backend_kwargs, *args, **kwargs)
    483 
    484     if engine is None:
--> 485         engine = plugins.guess_engine(filename_or_obj)
    486 
    487     backend = plugins.get_backend(engine)

/usr/local/lib/python3.7/dist-packages/xarray/backends/plugins.py in guess_engine(store_spec)
    110             warnings.warn(f"{engine!r} fails while guessing", RuntimeWarning)
    111 
--> 112     raise ValueError("cannot guess the engine, try passing one explicitly")
    113 
    114 

ValueError: cannot guess the engine, try passing one explicitly

I'm not entirely sure what changed. My guess is that we used to fall-back to trying to use SciPy, but don't do that anymore. A potential fix would be reading strings as filenames in xarray.backends.utils.read_magic_number.

Related: #5291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants