Join the Kedro community

M
M
M
D
M

Storing a python object throughout the entire kedro lifecycle

Is there a way to store a python object and make it available throughout the entire kedro lifecycle or a run.

So i want some way to generate an uuid before the pipeline starts which can be done with the help of hooks but how do i make it available throughput all the hook implementations and probably the nodes also.

L
V
N
4 comments

I'd say use the hook, and add to after_context_created

Alternatively, you could set it up in the settings and import it from there

Thanks for responding. Can you give me some example . In case of after_context_created , i can call the function and generate the uuid but where can i store it ,to access it in other hooks ?

I'd say avoid cross hook communication. Hooks are mean to be a way to extend Kedro and work as a standalone plugin.

You can create the id and save it as an attribute so it available within the same hook. Passing a hook info to node is not recommended since you couple your hook to node and it becomes part of the implementation

Add a reply
Sign up and join the conversation on Slack
Join