<@U06RKAMK0UC> How do you create a custom Launch P...
# ask-ai
b
@ancient-wolf-19325 How do you create a custom Launch Plan for a workflow which runs once everyday
j
To create a custom Launch Plan for a workflow that runs once every day, you can use the
LaunchPlan
and
CronSchedule
classes from Flyte. Here's a basic example:
Copy code
from flytekit import LaunchPlan, CronSchedule
from workflows.example import my_workflow

daily_launch_plan = LaunchPlan.get_or_create(
    name="daily_launch_plan",
    workflow=my_workflow,
    schedule=CronSchedule(schedule="0 0 * * *"),  # This cron expression runs the workflow daily at midnight
    default_inputs={"input_name": "default_value"},  # Replace with actual default inputs
)
This code sets up a Launch Plan that schedules the workflow to run daily at midnight. Would you like more detail? Sources: - Running and Scheduling Workflows - Schedules 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
b
@ancient-wolf-19325 How do you register a launch plan
j
To register a launch plan in Flyte, you can use the
pyflyte register
command. Ensure that your launch plan is defined in a Python module, and then execute the following command:
Copy code
pyflyte register --project <project_name> --domain <domain_name> --version <version> <path_to_python_module>
This command registers all workflows, tasks, and launch plans defined in the specified Python module. Would you like more detail? Sources: - Scheduling a Launch Plan 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
b
@ancient-wolf-19325 how do you register a LaunchPLan using FlyteRemote interface
j
To register a Launch Plan using the
FlyteRemote
interface, you can follow these steps: 1. Initialize FlyteRemote: Set up the
FlyteRemote
object with the appropriate configuration. 2. Fetch or Create Launch Plan: Use
LaunchPlan.get_or_create()
to define your launch plan. 3. Register Launch Plan: Use the
register_launch_plan
method of
FlyteRemote
. Here's an example:
Copy code
from flytekit import LaunchPlan, CronSchedule
from flytekit.remote import FlyteRemote
from flytekit.configuration import Config

# Initialize FlyteRemote
remote = FlyteRemote(
    config=Config.for_endpoint(endpoint="<http://flyte.example.net|flyte.example.net>"),
    default_project="flytesnacks",
    default_domain="development",
)

# Define the launch plan
launch_plan = LaunchPlan.get_or_create(
    name="daily_launch_plan",
    workflow=my_workflow,
    schedule=CronSchedule(schedule="0 0 * * *"),  # Daily at midnight
)

# Register the launch plan
remote.register_launch_plan(
    entity=launch_plan,
    project="flytesnacks",
    domain="development",
    version="v1"
)
Would you like more detail? Sources: - Running Launch Plans 👍 1 button 👎 0 button 💡 Hint: Mention @ancient-wolf-19325 in the thread for followups.