Open scottyhq opened 2 months ago
thanks for reporting this ! indeed this xarray pinning is not satisfactory
the error was raised in CI tests and later reported by some users that's why we found that a temporary solution was to pin xarray to <2024.03, not really to check on the netCDF4 availability in the environnement, it is a priori there in CI tests
let me double check if I can reproduce the error in an env where I'm sure netCDF4 is available
and we have the next release coming up soon (v0.1.17), surely before the end of September xarray pinning should be removed at this point
@scottyhq
I can reproduce the error using the following environnement file:
That lead to these librairies:
hence including xarray 2024.7.0, scipy 1.14.1 and netCDF4 1.7.1
the classic argopy data fetching command :
import argopy
argopy.DataFetcher().float(6902746).to_xarray()
Returns the following traceback:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/gmaze/git/github/euroargodev/argopy/argopy/fetchers.py", line 490, in to_xarray
xds = self.postproccessor(xds)
File "/Users/gmaze/git/github/euroargodev/argopy/argopy/fetchers.py", line 356, in postprocessing
xds = self.fetcher.filter_data_mode(xds)
File "/Users/gmaze/git/github/euroargodev/argopy/argopy/data_fetchers/erddap_data.py", line 834, in filter_data_mode
ds = ds.argo.filter_data_mode(errors="ignore", **kwargs)
File "/Users/gmaze/git/github/euroargodev/argopy/argopy/xarray.py", line 754, in filter_data_mode
argo_r, argo_a, argo_d = ds_split_datamode(ds)
File "/Users/gmaze/git/github/euroargodev/argopy/argopy/xarray.py", line 646, in ds_split_datamode
argo_r = safe_where_eq(xds, "DATA_MODE", "R")
File "/Users/gmaze/git/github/euroargodev/argopy/argopy/xarray.py", line 617, in safe_where_eq
return xds.where(xds[key] == value, drop=True)
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/common.py", line 1212, in where
return ops.where_method(self, cond, other)
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/ops.py", line 179, in where_method
return apply_ufunc(
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/computation.py", line 1255, in apply_ufunc
return apply_dataset_vfunc(
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/computation.py", line 523, in apply_dataset_vfunc
list_of_coords, list_of_indexes = build_output_coords_and_indexes(
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/computation.py", line 252, in build_output_coords_and_indexes
merged_vars, merged_indexes = merge_coordinates_without_align(
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/merge.py", line 413, in merge_coordinates_without_align
merged_coords, merged_indexes = merge_collected(
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/merge.py", line 290, in merge_collected
merged_vars[name] = unique_variable(
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/merge.py", line 123, in unique_variable
out = out.set_dims(dim_lengths)
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/util/deprecation_helpers.py", line 140, in wrapper
return func(*args, **kwargs)
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/variable.py", line 1377, in set_dims
expanded_data = self.data
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/variable.py", line 449, in data
return self._data.get_duck_array()
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/indexing.py", line 837, in get_duck_array
self._ensure_cached()
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/indexing.py", line 831, in _ensure_cached
self.array = as_indexable(self.array.get_duck_array())
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/indexing.py", line 788, in get_duck_array
return self.array.get_duck_array()
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/indexing.py", line 647, in get_duck_array
array = apply_indexer(self.array, self.key)
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/indexing.py", line 1028, in apply_indexer
return indexable.oindex[indexer]
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/core/indexing.py", line 368, in __getitem__
return self.getter(key)
File "/Users/gmaze/miniconda3/envs/argopy-xarray-unpinned/lib/python3.10/site-packages/xarray/coding/variables.py", line 72, in _oindex_get
return type(self)(self.array.oindex[key], self.func, self.dtype)
AttributeError: 'ScipyArrayWrapper' object has no attribute 'oindex'
It's a xarray.Dataset.where
statement that raises the issue
I added a nighlty test to monitor this issue: https://github.com/euroargodev/argopy/actions/workflows/pytests-upstream-xarray.yml
We're trying to support argopy alongside other packages in the pangeo docker image (https://github.com/pangeo-data/pangeo-docker-images/pull/577)
But v0.1.16 pins xarray to <2024.03 https://github.com/euroargodev/argopy/issues/373#issuecomment-2312421966
My understanding of the linked upstream issue https://github.com/pydata/xarray/issues/8909 is that the
ScipyArrayWrapper' object has no attribute 'oindex'
error arises for the specific case of overwriting a netCDF file in an environment withscipy
installed but withoutnetCDF4
... But argopy does listnetCDF4
as a dependency. So @gmaze could you please provide a bit more context around where the problem is seen for argopy? Cheers!