https://kedro.org/ logo
#questions
Title
# questions
e

Elior Cohen

03/20/2024, 11:16 AM
Is there a way to access the session ID or any other pipeline-execution identifier from within the nodes of a pipeline?
👀 1
m

marrrcin

03/20/2024, 11:21 AM
You can generate your own ID using hooks early in the lifecycle and then inject it into all nodes in
before_node_run
. Alternatively - use mlflow run id, if you're using mlflow.
e

Elior Cohen

03/20/2024, 11:22 AM
The first sounds like a neat solution - so I understand the
KedroSession
cannot be/is not available to the pipeline and nodes upon execution?
j

Juan Luis

03/20/2024, 11:25 AM
node functions don't know anything about Kedro, they're regular functions that take dataframes and produce dataframes. so much so that you could reuse them in a non-Kedro context without changes. hence the way to achieve what you want is by using hooks as @marrrcin suggests
n

Nok Lam Chan

03/20/2024, 11:34 AM
If you know what your id should be, or have the flexibility to generate your own. It will be simpler to register a customer resolver and simply treat that session id as a parameter so it is immediate available for nodes
e

Elior Cohen

03/20/2024, 11:34 AM
totally understand the independence of nodes
I was referring to something like
KedroSession.get_current_session()
something liek that that I can use within nodes, to get the session data
m

marrrcin

03/20/2024, 11:37 AM
So the question is - why do you need that? 😉
👍🏼 1
e

Elior Cohen

03/24/2024, 11:27 AM
@marrrcin sorry for late reply I wanted that because I need to carry a string for teleemtry purposes over nodes. So I have some kind of a session ID, and traces go underneath that session ID. From a business perspective ,the session is the same throughout the execution of the pipeline. This Session ID is what I was trying to set