branch:&baselinestart_at:preparesteps:...branch:&cnnstart_at:trainsteps:...dag:description:|This example demonstrates the use of the Parallel step.parallel step takes a mapping of branches which are pipelines themselves.start_at:parallel_stepsteps:parallel_step:type:parallelnext:successbranches:baseline:*baselinecnn:*cnn
Execution
The pipelines of the parallel branch should not execute during the definition of parallel step.
In case, you want to execute the individual branches in isolation, use a flag to control it.
eg: the functions get_baseline and get_cnn can take a argument execute which is defaulted to True.
During the composition of parallel step, pass in execute as False.
A branch of a parallel step is considered success only if the success step is reached at the end.
The steps of the pipeline can fail and be handled by on failure and
redirected to success if that is the desired behavior.
The parallel step is considered successful only if all the branches of the step have terminated successfully.
"""This example demonstrates the use of the Parallel step.The branches of the parallel step are themselves pipelines and can be definedas shown in 02-sequential/traversal.py.WARNING, the function returning the pipeline should not executedduring the definition of the branch in parallel steps.Run this pipeline as: python examples/06-parallel/parallel.py"""fromexamples.common.functionsimporthellofromrunnableimportNotebookTask,Parallel,Pipeline,PythonTask,ShellTask,Stubdeftraversal():""" Use the pattern of using "execute" to control the execution of the pipeline. The same pipeline can be run independently from the command line. WARNING: If the execution is not controlled by "execute", the pipeline will be executed even during the definition of the branch in parallel steps. """stub_task=Stub(name="hello stub")python_task=PythonTask(name="hello python",function=hello,)shell_task=ShellTask(name="hello shell",command="echo 'Hello World!'",)notebook_task=NotebookTask(name="hello notebook",notebook="examples/common/simple_notebook.ipynb",terminate_with_success=True,)# The pipeline has a mix of tasks.# The order of execution follows the order of the tasks in the list.pipeline=Pipeline(steps=[stub_task,python_task,shell_task,notebook_task])returnpipelinedefmain():parallel_step=Parallel(name="parallel_step",terminate_with_success=True,branches={"branch1":traversal(),"branch2":traversal()},)pipeline=Pipeline(steps=[parallel_step])pipeline.execute()returnpipelineif__name__=="__main__":main()
branch:&branchdescription:|Use this pattern to define repeatable branchThis pipeline is the same as the one defined in examples/02-sequential/traversal.yamlstart_at:hello stubsteps:hello stub:type:stubnext:hello pythonhello python:type:taskcommand_type:pythoncommand:examples.common.functions.hello# dotted path to the function.next:hello shellhello shell:type:taskcommand_type:shellcommand:echo "Hello World!"# Command to runnext:hello notebookhello notebook:type:taskcommand_type:notebookcommand:examples/common/simple_notebook.ipynb# The path is relative to the root of the project.next:successdag:description:|This example demonstrates the use of the Parallel step.parallel step takes a mapping of branches which are pipelines themselves.Run this pipeline as:runnable execute -f examples/06-parallel/parallel.yamlstart_at:parallel_stepsteps:parallel_step:type:parallelnext:successbranches:branch1:*branchbranch2:*branch