Skip to content

Subflow Task Runner Inheritance #12563

Answered by daviddwlee84
daviddwlee84 asked this question in Q&A
Discussion options

You must be logged in to vote

Inherit task runner from parent flow can be done like this

from prefect import flow
from prefect_ray.task_runners import RayTaskRunner
from prefect.context import FlowRunContext

@flow
def child_flow():
    # do something
    pass

@flow(task_runner=RayTaskRunner(), log_prints=True)
def parent_flow():
    print(f"Inherit parent flow task runner {FlowRunContext.get().task_runner}")
    child_flow.with_options(task_runner=FlowRunContext.get().task_runner)()

if __name__ == "__main__":
    parent_flow()

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by daviddwlee84
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant