https://flyte.org logo
f

Frank Shen

10/10/2022, 7:00 PM
Hello, I am new to Flyte. I’ve setup flyte locally and started the demo cluster. I created a launch plan below. How do I register it and activate it so that it will show up in the UI? The found the documentation not clear about LP registration. Thank yiou!
Copy code
from flytekit import LaunchPlan, current_context, task, workflow

@task
def square(val: int) -> int:
    return val * val

@workflow
def my_wf(val: int) -> int:
    result = square(val=val)
    return result

default_lp = LaunchPlan.get_default_launch_plan(current_context(), my_wf)
square_3 = default_lp(val=3)
Hi @Kevin Su, Do you have any advices?
k

Kevin Su

10/10/2022, 9:14 PM
If you want to create a new launch plan, you can use
LaunchPlan.get_or_create
.check this doc
f

Frank Shen

10/10/2022, 9:53 PM
Thanks @Kevin Su. I changed the method to LaunchPlan.get_or_create() in the script. But how do I register the launch plan and then make it available in the system / UI?
Which command will do that?
k

Kevin Su

10/10/2022, 9:56 PM
pyflyte register example.py
. it will register your LP.
f

Frank Shen

10/10/2022, 10:28 PM
I registered the LP and can see the LP in UI. However, there is no execution and I cannot kick off a run manually from UI.
And I am confused about the
Copy code
kickoff_time_input_arg="kickoff_time"
in
Copy code
schedule=CronSchedule(
        schedule="*/1 * * * *",  
        kickoff_time_input_arg="kickoff_time",
    )
How do I create new execution?
k

Kevin Su

10/10/2022, 10:33 PM
launch workflow button
f

Frank Shen

10/10/2022, 10:49 PM
Thanks. However, I don’t observe the 1 minute cron schedule is being followed.
It only ran once.
flyte-sandbox
k

Kevin Su

10/10/2022, 11:07 PM
sorry, flyte scheduler isn’t enabled in demo cluster. could you try
flytectl sandbox start
instead
f

Frank Shen

10/10/2022, 11:09 PM
Thank you @Kevin Su!
s

Samhita Alla

10/11/2022, 4:28 AM
@Kevin Su, flyte scheduler should work on demo. I tried running it a few days ago.
@Frank Shen, what are the commands you ran to register and schedule your launch plan?
f

Frank Shen

10/11/2022, 5:00 PM
Hi @Samhita Alla, thank you for reaching out. my code to create the LP is like
Copy code
@workflow
def my_wf(
    # kickoff_time: datetime, 
    val: int
    ) -> int:
    # print(f"datetime run: {kickoff_time}")
    result = square(val=val)
    return result

schedule = CronSchedule(
    schedule="*/1 * * * *",
    # kickoff_time_input_arg="kickoff_time"
)

lp = LaunchPlan.get_or_create(
    workflow=my_wf, name="lp_test_1", schedule = schedule, default_inputs={"val": 3}
)
To register I used
Copy code
pyflyte register lp-test-1.py
However, there is no executions.
I tried sandbox cluster and it looks the same.
s

Samhita Alla

10/12/2022, 6:09 AM
I think you missed activating the launch plan:
Copy code
flytectl update launchplan -p flytesnacks -d development <lp-name> --version <version> --activate
f

Frank Shen

10/12/2022, 4:20 PM
Hi @Samhita Alla, Yea, it worked after activating the launch plan. Thank you so much!