Thread
#prefect-community
    m

    Matthias

    2 years ago
    Hi! Is there an easy way to make a task the last or first task of a flow explicitly?
    Dylan

    Dylan

    2 years ago
    Hi @Matthias! Check out: https://docs.prefect.io/api/latest/core/task.html#task-2 and the
    set_dependencies
    method
    You can explicitly set upstream and downstream deps for a given task
    I don’t think we have an idiom for saying “this is the first task”
    or “this is the last task”
    m

    Matthias

    2 years ago
    Alright, just wanted to make that sure. Thanks!
    Dylan

    Dylan

    2 years ago
    Let me know if I can expand or help further
    Anytime!
    Jeremiah

    Jeremiah

    2 years ago
    If you wanted to make ABSOLUTELY sure, you could do something like:
    all_other_tasks = flow.tasks.difference([t])
    t.set_dependencies(upstream_tasks=all_other_tasks, flow=flow)
    This would make
    t
    a downstream task of every other task, ensuring it runs last
    m

    Matthias

    2 years ago
    I even got it less messy by using tags and the
    get_tasks()
    Thanks!
    Jeremiah

    Jeremiah

    2 years ago
    :yes: