Hi, when a certain task has completed successfully...
# ask-community
m
Hi, when a certain task has completed successfully, I'd like to trigger another deployment from within a flow. Is it possible to use something like .submit(wait_for=task) as you can do with tasks? when running a deployment in a flow?
Copy code
from prefect import flow
from prefect_kubernetes import run_namespaced_job
from prefect.deployments import run_deployment
@task(name="task1")
def task1():
    print("task1")

@task(name="task2")
def task2():
   print("task2")

@flow(task_runner=DaskTaskRunner())
def myflow():
    task1_result = task1.submit()
    task2_result = task2.submit(wait_for=task1_result)
    
    task3_result = run_deployment(<flowname/deploymentname>) # Can I make this deployment run wait for task2 to complete?
j
Hi Mich. You could use a state change hook - in particular a task’s
on_completion
hook. Check out the docs here.