Can we set a task to success state, ie. based on a...
# prefect-community
s
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
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
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
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.