Thread
#prefect-community
    Robin

    Robin

    1 year ago
    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?
    Kyle Moon-Wright

    Kyle Moon-Wright

    1 year ago
    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.
    Robin

    Robin

    1 year ago
    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 🙂
    Kyle Moon-Wright

    Kyle Moon-Wright

    1 year ago
    Noted! Thanks for the feedback.