WIP: Switch for application connections
This MR proposes a mechanism to easily switch between in-memory and on-disk application connections.
The goal is to facilitate the development of OTB processing chains in Python.
Classes and files
With the function
Application::ConnectImage(), a specific kind of connection has been implemented in
InputImageParameter (the InputImageListParameter is also supported), it contains:
- a key for the OutputImageParameter to connect
- a boolean to set the connection mode: in-memory / on-disk
It allows to build a kind of application pipeline, where we can propagate calls from the last application to the upstream applications. The method
Application::Execute() has been modified to propagate
Execute() calls. It follows a simple procedure:
- Discover the list of upstream applications
Execute()on each of them
- Handle the input images that have a connection:
- in-memory mode: pass the image pointer from upstream application to InputImageParameter and disable the OutputImageParameter where it comes from
- on-disk mode: pass the filename from upstream application to InputImageParameter and enable the OutputImageParameter where it comes from
WriteOutput()on each upstream application
- Call our own
This removes the need to call
Execute() after each upstream application, we just call
ExecuteAndWriteOutput() on the latest application.
Application::PropagateConnectMode(bool) has been added to switch between the in-memory (default) and on-disk modes.
Here is a snippet of what we can do in Python:
# in-memory app1 = otb.Registry.CreateApplication("Smoothing") app2 = otb.Registry.CreateApplication("Smoothing") app1.IN = input_image app2.ConnectImage("in", app1, "out") app2.OUT = output_image app2.ExecuteAndWriteOutput()
# on-disk app1 = otb.Registry.CreateApplication("Smoothing") app2 = otb.Registry.CreateApplication("Smoothing") app1.IN = input_image app1.OUT = temp_image app2.ConnectImage("in", app1, "out") app2.OUT = output_image app2.PropagateConnectMode(False) app2.ExecuteAndWriteOutput()
pyTvConnectApplications has been updated to demonstrate the new features.
TODO: the Python CookBook recipe needs to be updated
- further work is needed to add protection with complex connections (diamonds, check for loops, ...)
- the function
Application::ConnectImage()can be renamed to
CompositeApplication::Connect()has been renamed to
- the on-disk mode should be overriden by in-memory when no temporary filename has been given in the output image.
The copyright owner is COPYRIGHT OWNER (OR OWNER'S AGENT) and has signed the ORFEO ToolBox Contributor License Agreement.
Check before merging:
- All discussions are resolved
- At least 2
👍votes from core developers, no 👎vote.
- The feature branch is (reasonably) up-to-date with the base branch
- Dashboard is green
- Copyright owner has signed the ORFEO ToolBox Contributor License Agreement