CLIMADA-project / climada_python

Python (3.8+) version of CLIMADA
GNU General Public License v3.0
321 stars 125 forks source link

Unittest climada.engine.test.test_impact fails #949

Closed agcclimate closed 1 month ago

agcclimate commented 1 month ago

Describe the bug I followed the simple installation instructions for Windows using miniforge prompt. After activating the cliamda environment, the unittest fails, showing the following error: TypeError: descriptor 'call' for 'type' objects doesn't apply to a 'property' object

To Reproduce Steps to reproduce the behavior/error:

  1. mamba create -n climada_env -c conda-forge climada
  2. mamba activate climada_env
  3. python -m unittest climada.engine.test.test_impact

Code example:

(climada_env) C:\Users\agarciac>python -m unittest climada.engine.test.test_impact
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\unittest\__main__.py", line 18, in <module>
    main(module=None)
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\unittest\main.py", line 101, in __init__
    self.parseArgs(argv)
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\unittest\main.py", line 150, in parseArgs
    self.createTests()
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\unittest\main.py", line 161, in createTests
    self.test = self.testLoader.loadTestsFromNames(self.testNames,
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\unittest\loader.py", line 232, in loadTestsFromNames
    suites = [self.loadTestsFromName(name, module) for name in names]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\unittest\loader.py", line 232, in <listcomp>
    suites = [self.loadTestsFromName(name, module) for name in names]
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\unittest\loader.py", line 162, in loadTestsFromName
    module = __import__(module_name)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\climada\__init__.py", line 24, in <module>
    from .util.config import CONFIG
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\climada\util\__init__.py", line 26, in <module>
    from .coordinates import *
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\climada\util\coordinates.py", line 33, in <module>
    import dask.dataframe as dd
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\__init__.py", line 98, in <module>
    from dask.dataframe import backends, dispatch, rolling
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\backends.py", line 15, in <module>
    from dask.dataframe.core import DataFrame, Index, Scalar, Series, _Frame
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\core.py", line 36, in <module>
    from dask.dataframe import methods
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\methods.py", line 34, in <module>
    from dask.dataframe.utils import is_dataframe_like, is_index_like, is_series_like
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\utils.py", line 20, in <module>
    from dask.dataframe import (  # noqa: F401 register pandas extension types
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\_dtypes.py", line 9, in <module>
    from dask.dataframe.extensions import make_array_nonempty, make_scalar
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\extensions.py", line 8, in <module>
    from dask.dataframe.accessor import (
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\accessor.py", line 126, in <module>
    class DatetimeAccessor(Accessor):
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\accessor.py", line 81, in __init_subclass__
    _bind_property(cls, pd_cls, attr, min_version)
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\dataframe\accessor.py", line 35, in _bind_property
    setattr(cls, attr, property(derived_from(pd_cls, version=min_version)(func)))
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\utils.py", line 981, in wrapper
    method.__doc__ = _derived_from(
                     ^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\utils.py", line 934, in _derived_from
    method_args = get_named_args(method)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\site-packages\dask\utils.py", line 695, in get_named_args
    s = inspect.signature(func)
        ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\inspect.py", line 3263, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\inspect.py", line 3011, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\inspect.py", line 2599, in _signature_from_callable
    call = _descriptor_get(call, obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\agarciac\.conda\envs\climada_env\Lib\inspect.py", line 2432, in _descriptor_get
    return get(descriptor, obj, type(obj))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: descriptor '__call__' for 'type' objects doesn't apply to a 'property' object

Expected behavior The test should pass and display an "Ok!"

Screenshots

Climada Version: 5.0.0

System Information (please complete the following information):

Additional context Add any other context about the problem here.

spjuhel commented 1 month ago

Could you specify the full python version? Is it >=3.11.9 ?

spjuhel commented 1 month ago

This is very probably the same problem as in #943, and related to https://github.com/dask/dask/issues/11038

The current best course of action would be to downgrade python to < 3.11.9, assuming you are on >= 3.11.9.

Please confirm this solves your problem and close the issue if that is the case.

alessioic commented 1 month ago

I have the same issue. I downgraded Python to 3.11.8, but the problem persists.

spjuhel commented 1 month ago

Ok, I will try to reproduce and see what works on my side, in the meantime:

Did you a) use a fresh python 3.11.8 environment or b) update an already existing one?

If b) could you try a)? And if a) could you try with python 3.10?

Could you also tell me whether you use conda or mamba and which version you use? As well as your operating system?

spjuhel commented 1 month ago

Ok so, running the following installs python 3.11.6 (Trying with 3.11.8 fails to solve dependencies with gdal) and works on my side (Ubuntu 22.04 - mamba 1.5.5 - conda 23.11.0)

mamba create -n climada_env -c conda-forge "python<3.11.9" climada
mamba activate climada_env
python -m unittest climada.engine.test.test_impact
alessioic commented 1 month ago

Great! It works. Many thanks

agcclimate commented 1 month ago

It also works on my end. I uninstalled python without noticing the version but I assume it had to do with it. Many thanks!