diff --git a/cookbook/core/flyte_basics/lp.py b/cookbook/core/flyte_basics/lp.py index 756cada1c4..f442e1ce29 100644 --- a/cookbook/core/flyte_basics/lp.py +++ b/cookbook/core/flyte_basics/lp.py @@ -1,10 +1,8 @@ """ -.. _launch_plans: - Launch Plans ----------------------- +------------- -Launch plans bind a partial or complete list of inputs necessary to launch a workflow along +Launch plans bind a partial or complete list of inputs necessary to launch a workflow, along with optional run-time overrides such as notifications, schedules and more. Launch plan inputs must only assign inputs already defined in the reference workflow definition. """ @@ -12,10 +10,20 @@ import calendar # %% +# When To Use Launch Plans +# ######################## +# +# - For multiple schedules of a workflow with zero or more predefined inputs +# - To run a specific workflow but with a different set of notifications +# - To share a workflow with set inputs with another user, allowing the other user to simply kick off an execution +# - To share a workflow with another user, making sure that some inputs can be overridden if needed +# - To share a workflow with another user, ensuring that some inputs are not changed +# # Launch plans are the only means for invoking workflow executions. -# By default, a 'default' launch plan will be created during the serialization (and registration process), +# A 'default' launch plan will be created during the serialization (and registration process), # which will optionally bind any default workflow inputs and any default runtime options specified in the project # flytekit config (such as user role, etc). +# # The following example creates a default launch plan with no inputs during serialization. import datetime @@ -43,19 +51,19 @@ def my_wf(val: int) -> int: square_5 = my_lp(val=5) # %% -# In some cases you may want to **fix** launch plan inputs, such that they can't be overridden at execution call time. -my_fixed_lp = LaunchPlan.create("always_2_lp", my_wf, fixed_inputs={"val": 4}) +# It is possible to **fix** launch plan inputs, so that they can't be overridden at execution call time. +my_fixed_lp = LaunchPlan.get_or_create(name="always_2_lp", workflow=my_wf, fixed_inputs={"val": 4}) square_2 = my_fixed_lp() # error: # square_1 = my_fixed_lp(val=1) # %% -# Putting it all together +# Putting It All Together # ####################### # -# Default and fixed inputs can all be used in combination together to simplify individual executions -# or even programmatic ones. -# Let's take a look at a trivial example where we enthusiastically greet each day of the upcoming week: +# Default and fixed inputs can be used together to simplify individual executions +# and programmatic ones. +# Here is a simple example to greet each day of the upcoming week: @task