Hello, I am new to Flyte. I’ve setup flyte locally...
# ask-the-community
f
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
If you want to create a new launch plan, you can use
LaunchPlan.get_or_create
.check this doc
f
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
pyflyte register example.py
. it will register your LP.
f
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
launch workflow button
f
Thanks. However, I don’t observe the 1 minute cron schedule is being followed.
It only ran once.
flyte-sandbox
k
sorry, flyte scheduler isn’t enabled in demo cluster. could you try
flytectl sandbox start
instead
f
Thank you @Kevin Su!
s
@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
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
I think you missed activating the launch plan:
Copy code
flytectl update launchplan -p flytesnacks -d development <lp-name> --version <version> --activate
f
Hi @Samhita Alla, Yea, it worked after activating the launch plan. Thank you so much!
102 Views