hi, maybe I’m tired today, but I can’t figure out if I can set / change the context variable inside of the Flow block.
Marko Herkaliuk
11/22/2021, 5:43 PM
why do i need this. I have state_handler for notification in slack when flow is failed. and i want have sm like this
Copy code
msg = (
f"Hey <@{prefect.context.flow_owner}>\n"
f"Run `{prefect.context.flow_run_name}` of flow `{prefect.context.flow_name}` "
f"entered `FAILED` state with message `{state.message}`."
f"See {prefect.context.flow_run_link} for more details."
)
for personal notification. And I want move this handler in our lib and don’t write this handler in every file
k
Kevin Kho
11/22/2021, 6:04 PM
Hey @Marko Herkaliuk, the context is not really meant to be mutated like this. I think it will work sometimes, but I don’t think you can do this in the Flow block. It has to be in a task because the Flow block is not deferred, while tasks are.
@Marko Herkaliuk the state handler can be defined in some custom module, and the context values will still be filled based on runtime values - so you can move it to your custom library
Anna Geller
11/22/2021, 6:12 PM
last point: flow_run_link could be constructed this way:
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.