https://flyte.org logo
#ask-the-community
Title
# ask-the-community
s

Sam Eckert

06/26/2023, 3:08 PM
When using
flytectl
, there are a few options around archiving/activating launchplans. I have been looking to move our wrapping code around launchplans to use
flytekit
, but I'm not seeing corresponding options. As far as I can tell, the
LaunchPlan.get_or_create
function just creates the object, but does not activate it. Am I missing something?
k

Kevin Su

06/26/2023, 4:04 PM
we don’t support archiving/activating LP for now. would you mind creating an issue for it. [flyte-core]
s

Sam Eckert

06/26/2023, 5:17 PM
For sure
s

Samhita Alla

06/27/2023, 5:30 AM
@Kevin Su, it should be possible to activate a launchplan with pyflyte, correct? https://github.com/flyteorg/flytekit/pull/1588
k

Kevin Su

06/27/2023, 5:37 AM
Sorry. I forgot we already support that. @Samhita Alla Thanks for the reminder. @Sam Eckert could you give it a try
s

Sam Eckert

06/27/2023, 5:41 AM
Correct me if I am wrong, but that would still require calling out to a CLI right? What’s the benefit of using pyflyte here instead of flytectl?
k

Kevin Su

06/27/2023, 5:48 AM
pyflyte can serialize the workflow, but flytectl can’t. if only want to serialize/register/run the workflow. you can just use pyflyte. if you want to use sandbox or update some resource (task resource, execution label, etc), you have to install flytectl
s

Samhita Alla

06/27/2023, 6:03 AM
Also if you want to activate the launch plan at the API level, you can use FlyteRemote. Take a look at the following code that activates a launch plan: https://github.com/flyteorg/flytekit/blob/3b064dca90de2d0d2d691e931aaadca56beb3a7f/flytekit/clis/sdk_in_container/launchplan.py#L61-L68.
s

Sam Eckert

06/27/2023, 2:29 PM
This should work! Thanks.
The only thing missing then is listing all of the active launchplan versions so we can disable them. In most cases it is probably sufficient to just get the most recent, but I'd be worried about edge cases. Fortunately, it looks like this is possible via https://github.com/flyteorg/flytekit/blob/master/flytekit/remote/remote.py#L386.
s

Samhita Alla

06/27/2023, 3:39 PM
You don't have to manually deactivate old launch plans. When you activate the new version of a launch plan, all the old ones will be automatically deactivated.
s

Sam Eckert

06/27/2023, 3:44 PM
Oh interesting. I think I ran the equivalent of
flytectl get launchplan -p flytesnacks -d development -o yaml  --filter.fieldSelector "state=1"
(from https://docs.flyte.org/projects/flytectl/en/latest/gen/flytectl_get_launchplan.html) but with a name parameter, and got multiple launchplans back. It is possible the name param was ignored and I accidentally disabled every launchplan across the project/domain...
s

Samhita Alla

06/27/2023, 3:49 PM
Oh multiple active launch plans?
s

Sam Eckert

06/27/2023, 3:55 PM
Yeah, thats what I was seeing. Let me test on my end to see if I can reproduce
I can't seem to repro. I'll update here if I am able to, but for now I'll just go on with the solution above. Thanks for the help!