https://prefect.io logo
Title
s

Sunjay

11/08/2022, 4:13 PM
Can we set a task to success state, ie. based on a condition execute a task else set it to success and trigger the downstream?
1
t

Taylor Curran

11/08/2022, 4:45 PM
You should be able to change state using our API: I'm not sure if this is the right command, but I would start looking around here: https://docs.prefect.io/api-ref/prefect/client/?h=state#prefect.client.schemas.State.to_state_create
j

Jeff Hale

11/08/2022, 6:41 PM
You can set change the state, but generally, you shouldn’t need to, Sunjay, as mentioned in my response to this question in your other thread.
s

Sunjay

11/09/2022, 8:56 AM
Hi @Jeff Hale and @Taylor Curran Thank you so much for your assistance.
if conditions == 'Foo":
a =task1()
else:
"set task1() state to success"
b= task2() # task 2 wait for the completed state of task1
So this is what I want to achieve in essence. I just wanted to know how to set the task1 state to completed as it can be skipped in case it doesnt meet a certain condition but the downstream job depends on the success state of the task1 using wait_for parameter.