pySTEPS / pysteps

Python framework for short-term ensemble prediction systems.
https://pysteps.github.io/
BSD 3-Clause "New" or "Revised" License
466 stars 168 forks source link

CI with py38 fails on import with ValueError #249

Closed dnerini closed 2 years ago

dnerini commented 2 years ago

The error appeared sometimes in the past few days and doesn't seem to be related to any of our code changes, since it appears when re-running previously successful jobs: https://github.com/pySTEPS/pysteps/runs/4680236854?check_suite_focus=true

Full traceback

Run python fetch_pysteps_data.py
Traceback (most recent call last):
  File "fetch_pysteps_data.py", line 14, in <module>
    from pysteps.datasets import create_default_pystepsrc, download_pysteps_data
  File "/usr/share/miniconda/envs/test-environment/lib/python3.8/site-packages/pysteps/__init__.py", line 18, in <module>
    from . import motion
  File "/usr/share/miniconda/envs/test-environment/lib/python3.8/site-packages/pysteps/motion/__init__.py", line 4, in <module>
    from .interface import get_method
  File "/usr/share/miniconda/envs/test-environment/lib/python3.8/site-packages/pysteps/motion/interface.py", line 31, in <module>
    from pysteps.motion.proesmans import proesmans
  File "/usr/share/miniconda/envs/test-environment/lib/python3.8/site-packages/pysteps/motion/proesmans.py", line 18, in <module>
    from pysteps.motion._proesmans import _compute_advection_field
  File "pysteps/motion/_proesmans.pyx", line 1, in init pysteps.motion._proesmans
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject
Error: Process completed with exit code 1.

Steps to reproduce:

conda create -n pysteps-38 python=3.8 -c conda-forge
conda activate pysteps-38
conda install -c conda-forge cython numpy jsmin jsonschema matplotlib netCDF4 opencv pillow pyproj scipy dask
git clone https://github.com/pySTEPS/pysteps.git
cd pysteps/
pip install .
cd ..
python -c "import pysteps"
dnerini commented 2 years ago

upgrading to numpy==1.22.0 seems to solve the issue:

conda create -n pysteps-38 python=3.8 -c conda-forge
conda activate pysteps-38
conda install -c conda-forge cython numpy jsmin jsonschema matplotlib netCDF4 opencv pillow pyproj scipy dask
git clone https://github.com/pySTEPS/pysteps.git
cd pysteps/
pip install numpy --upgrade
pip install .
cd ..
python -c "import pysteps"

works!

The cause seems to be similar to what described here https://github.com/scikit-learn-contrib/hdbscan/issues/457#issuecomment-773671043 in that the pysteps build dependencies don't pin any version for numpy. In turns, this breaks the environment when the most recently available version in conda-forge is different from the one available from pypi, as it happened yesterday when numpy 1.22 was released on PyPI but not conda-forge.

dnerini commented 2 years ago

see #250.