I have some launch plan and scheduling questions. ...
# ask-the-community
a
I have some launch plan and scheduling questions. I seem to not be following the docs very well. Here’s an example launch plan that I’m trying to create. In my mind, I’m thinking that running this should create a new launch plan (or launchplan version if one with the given name doesn’t exist), and set it up to run on the given schedule. However, when I do so, I don’t see the cron schedule show up, nothing shows up when I filter to “Scheduled”, and none of the given default_inputs or fixed_inputs are showing up in the UI. If I try with a name of a launch plan that doesn’t exist yet, nothing seems to happen at all. The only thing that seems to be doing anything is either activating an existing launchplan using the flytekit “remote” logic, or activating it with
pyflyte register … --activate-launchplans
Launch plan creation in python
Copy code
launch_plan = LaunchPlan.create(
        name=launch_plan_name,
        workflow=<workflow function>,
        default_inputs={
            "default_input1": "input_value",
            ...
        },
        schedule=CronSchedule(schedule="0 21 * * 1"), # 9 PM each Monday
    )
Is this code alone supposed to create the launch plan? I also tried running ``pyflyte register … --activate-launchplan` after, but it seemed to just activate the existing one, which doesn’t have the schedule or the inputs. I also tried this:
Copy code
remote = FlyteRemote(
        config=Config.auto(),
        default_project="flytesnacks",
        default_domain="development",
    )
    launchplan_id = remote.fetch_launch_plan(
        name=launch_plan_name,
    ).id
    remote.client.update_launch_plan(launchplan_id, "ACTIVE")
But that had the same effect, where it seems to “activate” the existing launchplan, but with no schedule and no inputs. Here’s the schedule section, which makes it look like its not really scheduled (and i tried scheduling every minute and nothing started). And the launchplan page has no default values (it just says “scalar”) and no fixed inputs: “This launch plan has no fixed inputs”. I’m sorry if I’m totally misunderstanding the docs. My goal in the end is to create several different launch plans for the same workflow, where each has a few differing inputs, and different schedules. Thank you!
s
@Andrew i just tried registering a launch plan and it works for me. you need to define a launch plan in your code, and thereby, activate it.
a
Could you share the code you used to register the launch plan? Is the first piece of code I shared all you need? Or is there more that I’m missing? Edit: Ahhhh.. I think I figured it out. I didn’t realize the
LaunchPlan.get_or_create
call was supposed to just adjacent to the workflow function? I had it under
if __name__ is "__main__"
, but it looks like I got it by just not putting it under anything and then running
pyflyte register path/to/workflow.py --activate-launchplans
if that sounds right