Designing workflow¶
Workflow¶
A workflow (also called as “pipeline”) consists of tasks and a task is realized by Operator.
MONAI Deploy App SDK has useful built-in operators you can reuse (the list of operators would keep growing with your contribution!).
If the built-in operators do not work for you, you can implement your operators. We will guide you throughout the sections in this document.
A workflow is a form of a graph which is usually a Directed Acyclic Graph (DAG).
One-operator workflow¶
The simplest form of the workflow would be a one-operator workflow.
Above graph shows an Operator (named MyOperator
) that load file from the input_path
in the local file system (DISK
type), process the file, and write the processed data into output_path
in the local file system (DISK
type).
In the workflow description, DISK
means a Storage Type.
If the input or the output data is supposed in memory, you can use IN_MEMORY
type.
Linear workflow¶
Let’s see another workflow example whose operators are connected linearly.
In this example, Task1 accepts its input (path) from the disk, and the processed data is set to output1
of Task1 in memory.
The memory object (output1
) is passed to Task2 as an input (input2
).
Similarly, output2
of Task2 is passed to Task3 as input3
and the final result would be saved in a file in the folder where output3
is referring.
Data Type and Domain Object¶
In addition to the Storage Type, each input or output of an operator has another property – Data Type
.
Data Type specifies a Type Hint of an input/output of an operator and the type of value in the input/output is verified in execution time.
Data Type can be a type hint such as str
, Any
, Union
, List[Union[str, int]]
.
There are built-in data types that MONAI Deploy App SDK supports which are called Domain Objects
.
Domain Object classes inherits Domain class and they provides a useful set of standard input/output data types such as DataPath, Image, DicomStudy, and so on.
Those domain object classes are controllable by the SDK so can be optimized further in the future.
The full list of Domain Object classes are available here.
Note
The functionality of mapping DataPath to the input and output of root and leaf operator(s) is absent starting with Release V0.6 of this App SDK, due to the move to rely on Holoscan SDK. It is planned to be re-introduced at a later time. For the time being, the application's input and output folders are passed to the root and leaf operators' constructor, as needed.
Among those classes, DataPath data type is special.
If an operator in the workflow graph is a root node (a node with no incoming edges) and its input’s
(<data type>, <storage type>) == (DataPath, DISK)
, the input path given by the user during the execution would be mapped into the input of the operator.If an operator in the workflow graph is a leaf node (a node with no outgoing edges) and its output’s
(<data type>, <storage type>) == (DataPath, DISK)
, the output path given by the user during the execution would be mapped into the output of the operator.
In A linear workflow
example above, if the workflow is processing the image data, operators’ input/output specification would look like this:
Task1
Task2
Task3
Note that input1
and output3
are DataPath type with IOType.DISK. Those paths are mapped into input and output paths given by the user during the execution.
Note
The above workflow graph is the same as a Simple Image Processing App. Please look at the tutorial to see how such an application can be made with MONAI Deploy App SDK.
Complex Workflows¶
Multiple inputs and outputs¶
You can design a complex workflow like below that some operators have multi-inputs or multi-outputs.