Hi! No rush on this, but let’s say we have a funct...
# ask-community
d
Hi! No rush on this, but let’s say we have a function task that’s been retried twice already, and it succeeds on the third retry. Is there any way for us to “access” that
nth_retry
data? Does prefect internally maintain that state that we can access? Or in
prefect.context
? Thank you!
k
Hey @Danny Vilela, what piece of data are you trying to access? Like the error?
d
Hey Kevin! Not necessarily the error, but rather some way (directly or otherwise) that can tell me “here’s how many times this tasked has failed prior (if at all)“. I imagine this could be arranged as some sort of global counter, but ideally there’s a more Prefect-compatible approach.
I think this page tells me that what I want might be found under
prefect.context.task_run_count
? https://docs.prefect.io/api/latest/utilities/context.html
k
Yep! I think that is what you’re looking for.