glaes icon indicating copy to clipboard operation
glaes copied to clipboard

Numpy should be limited to 1.23.5

Open julian-belina opened this issue 1 year ago • 6 comments

The numpy version in environment.yml should be limited to numpy<=1.23.5. With numpy 1.24 i get the following error when running the tests:

----------------------------- Captured stderr call ----------------------------- pj_obj_create: Open of /home/runner/miniconda3/envs/test_env/share/proj failed ________________________ test_ExclusionCalculator_save _________________________

def test_ExclusionCalculator_save():

   ec = gl.ExclusionCalculator(aachenShape)

glaes/glaes/test/test_ExclusionCalculator.py:60:

glaes/glaes/core/ExclusionCalculator.py:238: in init s.maskPixels = s.region.mask.sum() ../../../miniconda3/envs/test_env/lib/python3.8/site-packages/geokit/core/regionmask.py:470: in mask self.buildMask() ../../../miniconda3/envs/test_env/lib/python3.8/site-packages/geokit/core/regionmask.py:457: in buildMask **kwargs).astype(np.bool)

attr = 'bool'

def __getattr__(attr):
    # Warn for expired attributes, and return a dummy function
    # that always raises an exception.
    import warnings
    try:
        msg = __expired_functions__[attr]
    except KeyError:
        pass
    else:
        warnings.warn(msg, DeprecationWarning, stacklevel=2)

        def _expired(*args, **kwds):
            raise RuntimeError(msg)

        return _expired

    # Emit warnings for deprecated attributes
    try:
        val, msg = __deprecated_attrs__[attr]
    except KeyError:
        pass
    else:
        warnings.warn(msg, DeprecationWarning, stacklevel=2)
        return val

    if attr in __future_scalars__:
        # And future warnings for those that will change, but also give
        # the AttributeError
        warnings.warn(
            f"In the future `np.{attr}` will be defined as the "
            "corresponding NumPy scalar.", FutureWarning, stacklevel=2)

    if attr in __former_attrs__:
       raise AttributeError(__former_attrs__[attr])

E AttributeError: module 'numpy' has no attribute 'bool'. E np.bool was a deprecated alias for the builtin bool. To avoid this error in existing code, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use np.bool_ here. E The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at: E https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

../../../miniconda3/envs/test_env/lib/python3.8/site-packages/numpy/init.py:305: AttributeError

julian-belina avatar Jan 18 '24 21:01 julian-belina

The conda forge package should be updated as well

julian-belina avatar Feb 14 '24 10:02 julian-belina

updated to which version? @julian-belina

tpelser avatar Feb 21 '24 10:02 tpelser

Numpy should be limitted to numpy<=1.23.5. This sould also be included in the coda-forge package.

julian-belina avatar Feb 21 '24 10:02 julian-belina

Issue with Numpy<1.4 is related to the dependency "Geokit". We will update the Glaes requirements to reflect this for now, once Geokit has been updated can remove this limitation.

tpelser avatar Feb 21 '24 10:02 tpelser

We will leave the issue open to inform as long as numpy is limited to <1.24 and remove it afterwards. Could you paste the respective geokit test error into a geokit github issue as well @julian-belina ?

chrisjwin avatar Feb 21 '24 10:02 chrisjwin

An issue has been opened on the geokit repository:

https://github.com/FZJ-IEK3-VSA/geokit/issues/9

julian-belina avatar Feb 22 '24 11:02 julian-belina

When installing via git clone: I am not sure whether this issue is fully resolved yet. The numpy issue with np.bool has been resolved in geokit version 1.4.0 But the current requirements.yml file states - conda-forge::geokit=1.3.0 However, after changing it to geokit version 1.4.0, I got many dependencies incompatibilities while creating the glaes environment. Thus I bumped numpy back to version 1.23.1 as in the previous fix, and now it works.

Disclaimer: I use glaes as part of the workflow of GeoH2-data-prep which might also cause the dependency incompatibilities

When glaes is installed via conda-forge channel, everyhting is fine.

juliusmeier avatar Jul 16 '24 13:07 juliusmeier

@juliusmeier I am not sure if I understand your installation proceedure completely. Which library are you trying to install via git clone, glaes, geokit or both?

In case you are trying to install both libraries via git clone, how do you exactly create your environment? Conda is lacking the ability to create an environment from two environment files.

In case you were trying to install the public version of glaes with geokit 1.40, this is currently not possible. They depend on diffrent versions of gdal that are not compatible with each other. It is planned to release a new glaes version but unfortunately there is no release date yet.

julian-belina avatar Jul 19 '24 15:07 julian-belina

@juliusmeier can you rather try to install the GLAES package using conda-forge? this is the current recommend method for installing and we are updating the readme to reflect this.

Using the conda manager of your choice (we recommend miniforge), you can create a new environment with glaes installed by using this command: conda create --name glaes -c conda-forge glaes

I personally recommend using a seperate environment for glaes, as this avoids any potential dependency issues. However, if you want to install into an existing environment which already contains other packages, you can activate the environment and install with: conda install -c conda-forge glaes

tpelser avatar Jul 23 '24 08:07 tpelser

@juliusmeier The best way to handle the dependencies for your repository would be to just add spider and glaes to the environment file of your repository GeoH2-data-prep before you create your environment from the file.

name: geoh2-data-prep
channels:
  - conda-forge
  - defaults
dependencies:
  - geopandas
  - rasterio
  - shapely
  - unidecode
  - pyyaml
  - glaes
  - spyder

julian-belina avatar Jul 23 '24 09:07 julian-belina

Thank you both for your help! I want to install glaes in its own environment. When I did it via git clone of the glaes repo and then used the requirements.yml file to create the environment, I ran into the issue which I described above. @julian-belina

I re-installed the glaes environment from scratch with conda create --name glaes -c conda-forge glaes and everything worked out perfectly without any fixes needed :) @tpelser

From my view, this issue is solved then.

juliusmeier avatar Jul 23 '24 11:07 juliusmeier