https://prefect.io logo
r

Robin

10/05/2020, 11:52 AM
Is there a possibility to access variables that were defined in tasks in the state handler? For example, in each task of a mapped task, I want to make a notification about the state change. And in that notication I would like to add a system id that is different for each task instance of the mapped task. Does somebody know how to access a variable from the task within the state handler?
k

Kyle Moon-Wright

10/05/2020, 3:34 PM
Hey @Robin, After testing this a bit, we can definitely respond to the result of a task using a state handler especially for failed mapped tasks (even the underlying context), but I don't think we have access to individual variables within that task because of the Hybrid Model. I believe we'd have to explicitly expose this variable to pass between task states to utilize the state handler in this way.
I think there's a way to accomplish this with a combination of logging, state signals, and a state handler, but that feels messy. I will continue to think about ways to accomplish this functionality in a clean way.
r

Robin

10/05/2020, 3:49 PM
OK, thanks for clarifying!
This has not a high prio atm, as I already implemented a work around within each task. However, it would be a great feature to be able to use the state handler for this in an intuitive way 🙂
k

Kyle Moon-Wright

10/05/2020, 4:15 PM
Noted! Thanks for the feedback.