Hi all - question: is it possible to have the colo...
# prefect-ui
m
Hi all - question: is it possible to have the colour of a task change to a different colour based on task outcome? For example: I'm using try/except for the download tasks shown. Let's say "direct_download-1" fails. I don't want the whole flow to stop, I just want the UI color to change so I know that that task did not successfully complete. So it might end up looking something like this (colour changes to yellow or some other color):
1
I should mention that I'm using 2.14.12.
c
Each task/subflow is colored according to the state that is is in or finished with. If a task fails it will show up red on the graph.
m
Yes, thanks Craig, that is what I've understood as well. What I've also understood is that if a task fails then the whole flow stops. I want a task to be able to fail, but the flow keeps on going, provided of course that subsequenct tasks are not reliant on the failed task.
c
Hmm I don’t think so but I’m not positive. Hopefully someone else has a better answer for you. You might want to try posting in #CL09KU1K7 since this isn’t really a ui question. I think this is more about flow and task execution and states.
n
hi @Mike Loose - you might be looking for
return_state
Copy code
In [2]: from prefect import flow, task

In [3]: @task
   ...: def good():
   ...:     return True
   ...:

In [4]: @task
   ...: def bad():
   ...:     raise ValueError
   ...:

In [5]: @flow
   ...: def work():
   ...:     good()
   ...:     bad(return_state=True)
   ...:     good()

In [6]: work()
where the flow finishes is failed and the failed task is red, but the failure of that task would not interrupt the completion of the flow. if you wanted to avoid the raised error resulting in a
Failed
flow run, you'd just have to
return
a non
None
value from the flow e.g.
Copy code
In [5]: @flow
   ...: def work():
   ...:     good()
   ...:     bad(return_state=True)
   ...:     return good()
otherwise you're totally free to
try
/
except
such errors to avoid the flow failing
🙌 1
thank you 1
m
Thanks @Nate, I will give it a go!
Worked like a charm! Thanks again - exactly what I was wanted to achieve.
👍 1
🙌 1
n
catjam