def test_debug_udf():
    """
    Shows how to run your UDF locally for testing. This method uses the same code as the backend, and can be used to check validity of your UDF.
    https://open-eo.github.io/openeo-python-client/udf.html#example-downloading-a-datacube-and-executing-an-udf-locally
    depends on composite.nc file created in earlier function!
    """

    DataCube.execute_local_udf(compositing_udf, 'masked.nc', fmt='netcdf')
 def test_run_local_udf_frommemory(self):
     from openeo_udf.api.datacube import DataCube
     dc=self.buildData()
     r=rest_DataCube.execute_local_udf(udfcode, dc)
     result=r.get_datacube_list()[0].get_array()
     exec(udfcode)
     ref=locals()["apply_datacube"](DataCube(dc.get_array().astype(numpy.float64).drop(labels='x').drop(labels='y')), {}).get_array()
     xarray.testing.assert_allclose(result,ref)
 def test_run_local_udf_fromfile(self):
     from openeo_udf.api.datacube import DataCube
     with TemporaryDirectory() as td:
         dc=self.buildData()
         tmpfile=os.path.join(td,'test_data')
         dc.to_file(tmpfile)
         r=rest_DataCube.execute_local_udf(udfcode, tmpfile)
         result=r.get_datacube_list()[0].get_array()
         exec(udfcode)
         ref=locals()["apply_datacube"](DataCube(dc.get_array().astype(numpy.float64).drop(labels='x').drop(labels='y')), {}).get_array()
         xarray.testing.assert_allclose(result,ref)
 def test_run_local_udf_none(self):
     r=rest_DataCube.execute_local_udf(udfcode)
     self.assertEqual(r,None)