Skip to content

Summarize/serialize pyotb objects

pyotb objects could have a summarize() or to_string() method that prints a nice summary of the pipeline. Better, this stuff could be used for serializing an pyotb pipeline. Example below.

For instance say I have the following pipeline:

cal = pyotb.OpticalCalibration({"in": "input.tif", ...})
bm = pyotb.BandMathX({"il": [cal, "other_input.tif], ...})
ortho = pyotb.OrthoRectification({"io.in": bm, ...})

We could summarize the whole pipeline by doing ortho.summarize() or print(ortho.to_string()) that would display something like:

{
    {
    "Application": "Orthorectification",
    "Parameters":
        {
        "io.in": 
            {
            "Application": "BandMathX",
            "Parameters": 
                {
                "il": 
                    [
                    "other_input.tif",
                        {
                        "Application": "OpticalCalibration",
                        "Parameters": 
                            {
                            "in": "input.tif",
                            ...,
                            }
                         }
                     ],
                 ...,
                }
            },
        },
        ...,
    }
}

This stuff could be dumped to a json file. We could even re-instanciate the whole pipeline from the json file... but that is not the priority here. I am mostly thinking about something to track pipelines in process metadata, and to build some caching mechanisms (if you have a whole pipeline serialized, then you have a unique ID built from its apps and parameters, whatever the computing environment)