sparse-pizza-79993
03/11/2024, 10:49 AMfaint-rocket-14513
03/11/2024, 10:49 AMLaunchPlan
feature. Launch plans in Flyte allow you to specify default values for your workflow's inputs. These defaults can then be overridden at the time of execution if needed. Here's a basic example of how you can define a workflow with parameters, create a launch plan with default values, and how those values can be overridden at runtime: 1. Define Your Workflow with Parameters: First, define your workflow in Flyte, specifying input parameters. from flytekit import task, workflow @task def my_task(a: int) -> int: return a + 5 @workflow def my_workflow(a: int) -> int: return my_task(a=a)
2. Create a Launch Plan with Default Values: Next, create a launch plan for your workflow, specifying default values for the parameters. from flytekit import LaunchPlan my_workflow_lp = LaunchPlan.create( "my_workflow_launch_plan", my_workflow, default_inputs={"a": 10} )
In this example, the default value for the parameter a
is set to 10
. This means that if the workflow is executed using this launch plan and no value is provided for a
, it will default to 10
. 3. Override Default Values at Runtime: When executing the workflow, you can override the default values specified in the launch plan. This can be done via the Flyte console or through the command line using flytectl
. For example, to override the default value using flytectl
, you would use the following command: flytectl create execution --project my_project --domain development --lpName my_workflow_launch_plan --inputs '{"a": 20}'
This command overrides the default value of a
with 20
for this particular execution. It's important to note that while you can set default values for workflow inputs using launch plans, the ability to dynamically set default values (e.g., using the current date as a default value) is not directly supported. However, you can achieve dynamic behavior by setting the values programmatically within your workflow or tasks based on the conditions or logic you define.sparse-pizza-79993
03/11/2024, 10:50 AMsparse-pizza-79993
03/11/2024, 10:52 AM