WorldCereal / worldcereal-classification

This repository contains the classification module of the WorldCereal system.
https://esa-worldcereal.org/
MIT License
37 stars 4 forks source link

Jenkins builds failing on richdem #134

Closed kvantricht closed 2 months ago

kvantricht commented 3 months ago

It appears that Jenkins builds have started failing since the implementation of slope computation. Stacktrace shown below. What's the reason for this?

============================= test session starts ==============================
platform linux -- Python 3.10.13, pytest-8.3.2, pluggy-1.5.0
rootdir: /var/lib/jenkins/workspace/_worldcereal-classification_main
configfile: pytest.ini
plugins: depends-1.0.1
collected 6 items

tests/worldcerealtests/test_feature_extractor.py F                       [ 16%]
tests/worldcerealtests/test_seasons.py ....                              [ 83%]
tests/worldcerealtests/test_worldcereal.py .                             [100%]

=================================== FAILURES ===================================
_____________________________ test_dem_computation _____________________________

    def test_dem_computation():
        test_elevation = np.array([[1, 2, 3], [1, 2, 2], [65535, 2, 2]], dtype=np.uint16)

        array = xr.DataArray(
            test_elevation[None, :, :],
            dims=["bands", "y", "x"],
            coords={"bands": ["elevation"], "y": [0, 1, 2], "x": [0, 1, 2]},
        )

        extractor = PrestoFeatureExtractor()

        # In the UDF no_data is set to 65535
>       slope = extractor._compute_slope(array).values  # pylint: disable=protected-access

tests/worldcerealtests/test_feature_extractor.py:19: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
venv310/lib/python3.10/site-packages/worldcereal/openeo/feature_extractor.py:77: in _compute_slope
    slope = TerrainAttribute(dem_array, attrib="slope_riserun")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

dem = rdarray([[    1,     2,     3],
         [    1,     2,     2],
         [65535,     2,     2]], dtype=uint16)
attrib = 'slope_riserun', zscale = 1.0

    def TerrainAttribute(
      dem,
      attrib,
      zscale = 1.0
    ):
      """Calculates terrain attributes. A variety of methods are available.

         Args:
             dem    (rdarray):  An elevation model
             attrib (str):      Terrain attribute to calculate. (See below.)
             zscale (float):    How much to scale the z-axis by prior to calculation

         ======================= =========
         Method                  Reference
         ======================= =========
         slope_riserun           `Horn (1981)                   doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
         slope_percentage        `Horn (1981)                   doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
         slope_degrees           `Horn (1981)                   doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
         slope_radians           `Horn (1981)                   doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
         aspect                  `Horn (1981)                   doi: 10.1109/PROC.1981.11918 <http://dx.doi.org/10.1109/PROC.1981.11918>`_
         curvature               `Zevenbergen and Thorne (1987) doi: 10.1002/esp.3290120107  <http://dx.doi.org/10.1002/esp.3290120107>`_
         planform_curvature      `Zevenbergen and Thorne (1987) doi: 10.1002/esp.3290120107  <http://dx.doi.org/10.1002/esp.3290120107>`_
         profile_curvature       `Zevenbergen and Thorne (1987) doi: 10.1002/esp.3290120107  <http://dx.doi.org/10.1002/esp.3290120107>`_
         ======================= =========

         Returns:
             A raster of the indicated terrain attributes.
      """
      if type(dem) is not rdarray:
        raise Exception("A richdem.rdarray or numpy.ndarray is required!")

      terrain_attribs = {
        #"spi":                _richdem.TA_SPI,
        #"cti":                _richdem.TA_CTI,
>       "slope_riserun":      _richdem.TA_slope_riserun,
        "slope_percentage":   _richdem.TA_slope_percentage,
        "slope_degrees":      _richdem.TA_slope_degrees,
        "slope_radians":      _richdem.TA_slope_radians,
        "aspect":             _richdem.TA_aspect,
        "curvature":          _richdem.TA_curvature,
        "planform_curvature": _richdem.TA_planform_curvature,
        "profile_curvature":  _richdem.TA_profile_curvature,
      }
E     NameError: name '_richdem' is not defined

venv310/lib/python3.10/site-packages/richdem/__init__.py:720: NameError
----------------------------- Captured stdout call -----------------------------
COULD NOT LOAD RichDEM ENGINE! NOTHING WILL WORK!
kvantricht commented 2 months ago

No longer using richdem