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

Incompatibility with xarray>=0.16 #312

Closed
TomAugspurger opened this issue Oct 27, 2020 · 4 comments
Closed

Incompatibility with xarray>=0.16 #312

TomAugspurger opened this issue Oct 27, 2020 · 4 comments
Milestone

Comments

@TomAugspurger
Copy link

With siphon 0.8.0 and a call with use_xarray=True, I see an ImportError inside siphon:

In [56]: import siphon.cdmr.xarray_support
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-56-2438b4811c5c> in <module>
----> 1 import siphon.cdmr.xarray_support

~/miniconda3/envs/pangeo-forge-37/lib/python3.7/site-packages/siphon/cdmr/xarray_support.py in <module>
      7 from xarray.backends.common import AbstractDataStore, BackendArray
      8 from xarray.core import indexing
----> 9 from xarray.core.utils import FrozenOrderedDict
     10
     11 from . import Dataset

ImportError: cannot import name 'FrozenOrderedDict' from 'xarray.core.utils' (/Users/taugspurger/miniconda3/envs/pangeo-forge-37/lib/python3.7/site-packages/xarray/core/utils.py)

From http://xarray.pydata.org/en/stable/faq.html#what-parts-of-xarray-are-considered-public-api, xarray considers xarray.core to be private, so libraries probably shouldn't be importing from it.

Full example:

In [59]: from siphon.catalog import TDSCatalog
    ...:

In [60]: ds = TDSCatalog("https://geoport.usgs.esipfed.org/thredds/catalog/coawst_4/use/fmrc/catalog.xml").datasets[0].remote_access(use_xarray=True)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-60-8d35c9e831d1> in <module>
----> 1 ds = TDSCatalog("https://geoport.usgs.esipfed.org/thredds/catalog/coawst_4/use/fmrc/catalog.xml").datasets[0].remote_access(use_xarray=True)

~/miniconda3/envs/pangeo-forge-37/lib/python3.7/site-packages/siphon/catalog.py in remote_access(self, service, use_xarray)
    620             raise ValueError(service + ' is not a valid service for remote_access')
    621
--> 622         return self.access_with_service(service, use_xarray)
    623
    624     def subset(self, service=None):

~/miniconda3/envs/pangeo-forge-37/lib/python3.7/site-packages/siphon/catalog.py in access_with_service(self, service, use_xarray)
    672         if service == 'CdmRemote':
    673             if use_xarray:
--> 674                 from .cdmr.xarray_support import CDMRemoteStore
    675                 try:
    676                     import xarray as xr

~/miniconda3/envs/pangeo-forge-37/lib/python3.7/site-packages/siphon/cdmr/xarray_support.py in <module>
      7 from xarray.backends.common import AbstractDataStore, BackendArray
      8 from xarray.core import indexing
----> 9 from xarray.core.utils import FrozenOrderedDict
     10
     11 from . import Dataset

ImportError: cannot import name 'FrozenOrderedDict' from 'xarray.core.utils' (/Users/taugspurger/miniconda3/envs/pangeo-forge-37/lib/python3.7/site-packages/xarray/core/utils.py)
@dopplershift dopplershift added this to the 0.9 milestone Oct 29, 2020
@dopplershift
Copy link
Member

Ugh, thanks for reporting. Definitely need to address and get a 0.9 out the door.

@RemiSahl
Copy link

RemiSahl commented Mar 2, 2021

Maybe something similar to what psyplot is doing could work ?
https://psyplot.readthedocs.io/en/latest/_modules/psyplot/gdal_store.html

try:
    from xarray.core.utils import FrozenOrderedDict
except ImportError:
    FrozenOrderedDict = dict

@dopplershift
Copy link
Member

It's actually likely we do like MetPy, and bump our minimum supported xarray version and change the code to:

from xarray.core.utils import FrozenDict

@dopplershift
Copy link
Member

Looks like this was actually already done in #291 , but just not released yet.

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

No branches or pull requests

3 participants