Description
What happened:
In one of my CI runs somehow the entrypoints ended up being defined twice. Then, I discovered that the function remove_duplicates
which weeds out duplicate entrypoints were not updated.
What you expected to happen:
No bugs in remove_duplicates
function
Minimal Complete Verifiable Example:
# Put your MCVE code here
from xarray.backends.plugins import remove_duplicates
from importlib.metadata import entry_points
eps = entry_points().get('xarray.backends', ())
remove_duplicates(eps)
remove_duplicates(eps + eps)
<ipython-input-12-22df5e55614a>:1: DeprecationWarning: EntryPoints list interface is deprecated. Cast to list if needed.
remove_duplicates(eps + eps)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-12-22df5e55614a> in <module>
----> 1 remove_duplicates(eps + eps)
~/.pyenv/versions/3.9.7/envs/pymech/lib/python3.9/site-packages/xarray/backends/plugins.py in remove_duplicates(entrypoints)
27 matches_len = len(matches)
28 if matches_len > 1:
---> 29 selected_module_name = matches[0].module_name
30 all_module_names = [e.module_name for e in matches]
31 warnings.warn(
AttributeError: 'EntryPoint' object has no attribute 'module_name'
Anything else we need to know?:
Following v0.20.0 the entrypoints were discovered using importlib.metadata
/ importlib_metadata
, but it was broken for 3rd party backeds. In v0.20.1 after #5931 the backend detection was fixed, but remains to be thoroughly tested #5934. This bug might be rare, compared to #5930, so I would recommend having some tests in place before making the next release.
Environment:
Output of xr.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.9.7 (default, Nov 3 2021, 09:51:04)
[GCC 11.1.0]
python-bits: 64
OS: Linux
OS-release: 5.10.75-1-lts
machine: x86_64
processor:
byteorder: little
LC_ALL: None
LANG: C
LOCALE: (None, None)
libhdf5: 1.12.1
libnetcdf: None
xarray: 0.20.1
pandas: 1.3.4
numpy: 1.21.3
scipy: None
netCDF4: None
pydap: None
h5netcdf: 0.11.0
h5py: 3.5.0
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudoNetCDF: None
rasterio: 1.2.10
cfgrib: None
iris: None
bottleneck: None
dask: 2021.10.0
distributed: None
matplotlib: None
cartopy: None
seaborn: None
numbagg: None
fsspec: 2021.10.1
cupy: None
pint: None
sparse: None
setuptools: 57.4.0
pip: 21.3.1
conda: None
pytest: 6.2.5
IPython: 7.29.0
sphinx: 4.2.0