<@U06RKAMK0UC> how do you fetch a launch plan whic...
# ask-ai
b
@ancient-wolf-19325 how do you fetch a launch plan which already exists on flyte
a
Reasoning Complete! 🤖 🔍 Searched knowledge base: I'll look up the official way to fetch an existing launch plan in Flyte so I can give you clear, step-by-step instructions. • Searching over 10 data sources from the following: File, Github File, Github Issue, Web • Found 49 documents that could be relevant from the following data sources: Github File, Github Issue, Github Pull Request. • Filtered down to the top 30 most relevant documents. ✍️ Generated answer: I've found step-by-step instructions for fetching an existing launch plan in Flyte using both the Python SDK and the CLI. You're ready to proceed!
To fetch a launch plan that already exists on Flyte, use the FlyteRemote client’s
fetch_launch_plan
method, specifying the project, domain, name, and optionally the version of the launch plan. For example:
Copy code
from flytekit.remote import FlyteRemote
from flytekit.configuration import Config

remote = FlyteRemote(
    config=Config.for_endpoint(endpoint="<http://flyte.example.net|flyte.example.net>"),
    default_project="flytesnacks",
    default_domain="development",
)

flyte_lp = remote.fetch_launch_plan(
    name="<http://workflows.example.wf|workflows.example.wf>", version="v1", project="flytesnacks", domain="development"
)
This retrieves the specified launch plan from the Flyte backend. If you omit the version, it fetches the latest version by default. Sources: - Running launch plans - flytekit.remote.remote.FlyteRemote.fetch_launch_plan 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
b
@ancient-wolf-19325 how do you fetch an active launch plan without specifying the version
a
Reasoning Complete! 🤖 🔍 Searched knowledge base: I'll look up the official Flyte documentation to confirm how to fetch an active launch plan without specifying the version, so you get the most accurate and up-to-date guidance. • Searching over 10 data sources from the following: File, Github File, Github Issue, Web • Found 48 documents that could be relevant from the following data sources: Github File, Github Issue. • Filtered down to the top 30 most relevant documents. ✍️ Generated answer: I've found the exact method you need to fetch the active launch plan in Flyte without specifying the version. You're ready to proceed!
To fetch the active launch plan without specifying the version, use the FlyteRemote client’s
fetch_active_launchplan
method, providing the project, domain, and name. This returns the currently active version for that launch plan:
Copy code
flyte_lp = remote.fetch_active_launchplan(
    project="flytesnacks",
    domain="development",
    name="<http://workflows.example.wf|workflows.example.wf>"
)
This method returns the active launch plan or
None
if none is active. You do not need to specify the version. Sources: - flytekit.remote.remote.FlyteRemote.fetch_active_launchplan 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
b
@ancient-wolf-19325 how can I define the domain based on current execution context while fetching the active launchplan
a
Reasoning Complete! 🤖 🔍 Searched knowledge base: I'll look up how you can automatically determine the domain from the current execution context in Flyte, so you don't have to hardcode it when fetching the active launch plan. • Searching over 10 data sources from the following: File, Github File, Github Issue, Web • Found 53 documents that could be relevant from the following data sources: Github File, Github Issue, Github Pull Request. • Filtered down to the top 30 most relevant documents. ✍️ Generated answer: I've found how you can programmatically get the current domain from the execution context in Flyte tasks or workflows, so you can use it when fetching the active launch plan.
It seems likely that you can access the current execution context’s domain using
flytekit.current_context().execution_id.domain
and use this value when calling
fetch_active_launchplan
. This approach allows you to dynamically set the domain based on the running context:
Copy code
from flytekit import current_context

domain = current_context().execution_id.domain
flyte_lp = remote.fetch_active_launchplan(
    project="flytesnacks",
    domain=domain,
    name="<http://workflows.example.wf|workflows.example.wf>"
)
However, this method works in Python tasks running on Kubernetes, but may not work in all plugin environments (e.g., Databricks), as noted in the discussions. Sources: - https://github.com/flyteorg/flytekit/blob/master/flytekit/remote/remote.py - https://github.com/flyteorg/flytesnacks/blob/master/examples/basics/basics/launch_plan.py 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
b
@ancient-wolf-19325 the launchPlan fetch cannot happen in a task because task cannot return a launch plan. Does the current_context only work inside a task
a
Reasoning Complete! 🤖 🔍 Searched knowledge base: I'll look up where flytekit.current_context() is available—whether it's only inside tasks, or also in workflows or other parts of Flyte—so you know exactly where you can use it. • Searching over 10 data sources from the following: File, Github File, Github Issue, Web • Found 52 documents that could be relevant from the following data sources: Github File, Github Issue, Github Pull Request. • Filtered down to the top 30 most relevant documents. ✍️ Generated answer: I've found that while current_context is most useful inside tasks for accessing runtime info, it can technically be called outside tasks too—though it may not contain meaningful execution data in those cases. Launch plan fetching should not be done inside tasks.
Yes,
flytekit.current_context()
is only meaningful inside a running Flyte task or workflow execution. It provides access to execution parameters and context, but is not intended for use outside of task/workflow execution. Fetching a launch plan (e.g., with
remote.fetch_launch_plan
) is typically done outside of tasks, such as in orchestration or client code, not within a task body. Sources: - https://github.com/flyteorg/flytesnacks/blob/master/examples/basics/basics/launch_plan.py 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.
b
@ancient-wolf-19325 if i want to invoke an external workflow from a workflow, I need to use a launch plan to invoke it. In order to fetch the launch plan, I need to specify the domain. I can use a task fetch domain and then create the launch plan, but I cannot return a launch plan from a task, nor can I call such a returned promise in a workflow. How can I call an external workflow from a parent workflow where the domain should change based on where the flyte workflow is running
a
Reasoning Complete! 🤖 🔍 Searched knowledge base: I'll look up Flyte's recommended way to dynamically call an external workflow from a parent workflow, especially when the domain needs to match the current execution context. • Searching over 10 data sources from the following: File, Github File, Github Issue, Web • Found 54 documents that could be relevant from the following data sources: Github File, Github Issue, Github Pull Request, Web Content. • Filtered down to the top 30 most relevant documents. ✍️ Generated answer: Based on Flyte's design, you can't dynamically choose which domain's LaunchPlan to call from within a workflow at runtime. All LaunchPlan references must be set when you define (register) the workflow, not while it's running. This means you can't fetch the domain in a task and then use it to select a LaunchPlan to call in the workflow. If you need to call different LaunchPlans based on the domain, you'll need to define separate workflows or use conditional logic at registration time, not at runtime.
My understanding is that, in Flyte, you cannot dynamically fetch or construct a launch plan at runtime within a task and then invoke it in a workflow, because tasks cannot return launch plans and workflows require launch plans to be statically defined at compile time. The domain for a launch plan reference must be known when the workflow is authored, not at runtime. This means you cannot dynamically set the domain for an external workflow invocation based on the current execution context within the workflow itself. The recommended approach is to define reference launch plans with explicit project, domain, name, and version at workflow definition time. If you need to invoke an external workflow in a different domain, you must create separate reference launch plans for each domain and select the appropriate one using workflow logic (e.g., conditionals), but the set of possible domains must be known in advance. There is no supported mechanism to dynamically fetch and invoke a launch plan with a runtime-determined domain from within a workflow. Sources: - https://github.com/flyteorg/flyte/issues/4249 👍 0 button 👎 0 button 💡 Hint: Mention @runllm in the thread for followups.