Call one workflow from within another to enable modular, reusable pipeline composition.
Flyte lets you call a workflow from inside another workflow, creating a subworkflow. The distinction from launch plans is conceptual: launch plans are “pass by pointer” (they trigger a separate execution) while subworkflows are “pass by value” (the entire graph is inlined into the parent).
When you use a launch plan inside a workflow, Flyte triggers a new, independent execution with its own execution ID. These are called external workflows.
from flytekit import LaunchPlan# Create a launch plan from the existing workflowslope_intercept_lp = LaunchPlan.get_or_create( slope_intercept_wf, name="slope_intercept_lp",)@workflowdef nested_regression_line_lp( x: typing.List[int] = [-3, 0, 3], y: typing.List[int] = [7, 4, -2], val: int = 5,) -> float: # Triggers a separate execution — a new execution ID is created m, b = slope_intercept_lp(x=x, y=y) return calc_y(x=val, slope=m, intercept=b)
In the Flyte console, the launch plan execution shows a different execution ID than the parent workflow.
If your deployment uses multiple Kubernetes clusters, external workflows via launch plans can distribute workloads across clusters — each external execution can run on a different cluster.
Run locally:
if __name__ == "__main__": print(nested_regression_line_lp())