gorgeous-beach-23305
07/27/2023, 12:47 PMfrom flytekit import CronSchedule, LaunchPlan # noqa: E402
# creates a launch plan that runs every minute.
cron_lp = LaunchPlan.get_or_create(
name="my_cron_scheduled_lp",
workflow=date_formatter_wf,
schedule=CronSchedule(
# Note that the ``kickoff_time_input_arg`` matches the workflow input we defined above: kickoff_time
# But in case you are using the AWS scheme of schedules and not using the native scheduler then switch over the schedule parameter with cron_expression
schedule="*/1 * * * *", # Following schedule runs every min
kickoff_time_input_arg="kickoff_time",
),
)
, this seems to be in a separate file, which makes sense, I would like to have all my launch plans in one file and import the required workflows from other files. And the second is this
from datetime import timedelta # noqa: E402
from flytekit import FixedRate, LaunchPlan # noqa: E402
@task
def be_positive(name: str) -> str:
return f"You're awesome, {name}"
@workflow
def positive_wf(name: str):
reminder = be_positive(name=name)
print(f"{reminder}")
fixed_rate_lp = LaunchPlan.get_or_create(
name="my_fixed_rate_lp",
workflow=positive_wf,
# Note that the workflow above doesn't accept any kickoff time arguments.
# We just omit the ``kickoff_time_input_arg`` from the FixedRate schedule invocation
schedule=FixedRate(duration=timedelta(minutes=10)),
fixed_inputs={"name": "you"},
)
where the LaunchPlan.get_or_create call sits below the workflow definition. My question for the second case is - will the launch plan get created when the workflow is registered? I know a default one gets created but I want to know about the one that is defined below the workflow. And for the first case where the launch plans are defined in a separate file, how do I execute the code in this file? Does it need to be inside a task and then I execute this task using pyflyte or is there a way to run the launch plan get_or_create code directly on pyflyte?gorgeous-beach-23305
07/27/2023, 2:25 PMgorgeous-beach-23305
07/27/2023, 5:03 PMflytectl update launchplan my_launch_plan --project sample-ml-project --domain development --version=r_x5ui6DR3iwNlqMGflQ_w== --activate
and I get the success message -
updated launchplan successfully on my_launch_plan
however, when I do
flytectl get launchplan -p sample-ml-project -d development my_launch_plan --latest
I get this -
-------------------------- ---------------- ------ ------- -------------------------------------------- -------- ---------
| VERSION | NAME | TYPE | STATE | SCHEDULE | INPUTS | OUTPUTS |
-------------------------- ---------------- ------ ------- -------------------------------------------- -------- ---------
| r_x5ui6DR3iwNlqMGflQ_w== | my_launch_plan | | | map[cronSchedule:map[schedule:*/5 * * * *] | | |
| | | | | kickoffTimeInputArg:start_time] | | |
that is, the type and state are empty. I believe the state should be "active". I can see on the UI that the workflow is associated with the launch plan, but it does not execute. Any idea what might be the issue? @freezing-airport-6809 sorry for the spam 🙂 can you please take a look when you get a chance? Thanks!freezing-airport-6809
glamorous-carpet-83516
07/27/2023, 6:57 PMglamorous-carpet-83516
07/27/2023, 11:04 PMWhen registering a launch plan this way, does the launch plan get associated with the latest version of the workflow alwaysit get associated with the workflow you used in the arg. (
workflow=date_formatter_wf
)
Is there a way to activate the launch plan when creating it or does it need to be done with flytectl once it is created?it should be activated by default
glamorous-carpet-83516
07/27/2023, 11:04 PMgorgeous-beach-23305
07/28/2023, 7:11 AMgorgeous-beach-23305
07/28/2023, 7:50 AMglamorous-carpet-83516
07/28/2023, 4:32 PMglamorous-carpet-83516
07/28/2023, 4:42 PM