Skip to content

Parser expects graph wrapped #75

@clausmichele

Description

@clausmichele

@GeraldIr I noticed an issue with the changes you did here:
2023.10.5...2023.10.6

After the changes, with release 2023.10.6, when a process graph contains fit_curve or predict_curve, it expects to be wrapped with a "process_graph" key, which is not the case when creating process graphs with the Python Client.

I found this bug while trying to use fit_curve locally. Here is where the graph is being parsed: https://github.com/Open-EO/openeo-python-client/blob/522edb7ffad4a14f27536a060eac551010d8312a/openeo/local/connection.py#L275

This sample code works with 2023.10.5 and no more with 2023.10.6:

import openeo
from openeo.rest.datacube import PGNode, THIS
from openeo.processes import sin, cos
import math

backend = "openeo.cloud"
conn = openeo.connect(backend)
conn = conn.authenticate_oidc()

def fit_process(bbox):
    spatial_extent  = {'west':bbox[0],'east':bbox[2],'south':bbox[1],'north':bbox[3]}
    temporal_extent = ["2016-09-01", "2018-09-01"] 
    collection      = 'boa_sentinel_2'
    bands           = ["B02", "B03", "B04", "B05", "B08"] 

    l2a_bands = conn.load_collection(collection,spatial_extent=spatial_extent,bands=bands,temporal_extent=temporal_extent)

    l2a_bands_clipped = l2a_bands.apply(lambda x: x.clip(0,5000))

    def fitFunction(x, parameters):
        t = 2 * math.pi / 31557600 * x
        return parameters[0] + parameters[1] * cos(t) + parameters[2] * sin(t)

    curve_fitting = l2a_bands_clipped.fit_curve(
        parameters=[1,1,1],
        dimension="t",
        function=fitFunction
    )
    fitted_parameters = curve_fitting.save_result(format="NetCDF", options={"tile_grid":"time-series"})
    return fitted_parameters

bbox = [11.65, 46.3, 11.7, 46.35]
fitted_parameters = fit_process(bbox)

from openeo_pg_parser_networkx import OpenEOProcessGraph
OpenEOProcessGraph(fitted_parameters.flat_graph())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions