Hey all: How to get session/context inside the node ?
✅ 1
n
Nok Lam Chan
11/01/2022, 11:13 AM
Hi @Allen Ma, why do you need to access context within a node?
a
Allen Ma
11/01/2022, 12:19 PM
hi @Nok Lam Chan I want to combine hook mechanism to dynamically pass some configuration information to node through context
n
Nok Lam Chan
11/01/2022, 1:17 PM
When you say dynamically, where is this configuration coming from? Is it from external files or nodes output?
a
Allen Ma
11/01/2022, 2:15 PM
From our metadata or config-center service
Or it could be the argument that was passed when we started our DAG,
e.g. airflow’s dag_run_conf
Hi @Nok Lam Chan Is it not supported now?
n
Nok Lam Chan
11/03/2022, 10:31 AM
I think there are better ways to do it. Session and context are higher level object and they are the containers for the parameters etc.
You don’t need session inside a node to do that, as you are awared that you can use hook.
For things like a config from airflow - I would probably use environment variable to solve this, simply write this into environment and communicate with the Kedro pipeline.
👍 1
Another option is using the after_context_created hook, where you can access the context, I don’t think you need to access the context within a node.