What do you want from the session? The answer this...
# beginners-need-help
d
What do you want from the session? The answer this question will likely be lifecycle hooks
c
I want the session_id
d
So is that not equivalent to the
run_id
here?
c
Yes, I guess that is the same
d
This change is very intentional because it makes state very difficult manage in single vs multi-process mode
In general hooks are the right way to access library objects like the catalog at run time
c
I could also read that was the reason you removed it
d
if you find yourself having to make a node aware of the lifecycle then my guess is that you need a hook
We tend to think of nodes as pure python functions without side effects
c
Okay, I understand the reasoning
d
💪
c
Sometimes it is just nice to mark e.g. a plot with a run_id
you can use that to pass it to the node as a dataset if you really want
c
Super thanks 👍
d
it's a little clunky as you'll need to map it override an existing dataset
but it will work
the other option is to set an env var at the start of a pipeline run and then read that in your logic
c
arh yes - how do you do that?
d
so in you
before_pipeline_run
hook you do
os.environ['KEDRO_RUN_ID']
and then retrieve it with
os.environ.get('KEDRO_RUN_ID')
and then wrap the 'getter' in a
plot_runid()
method so you dont write it over and over
c
Okay, using the pipeline hook. Nice
d
👍
c
Sorry, I got it to work now with a sequencialrunner, but what do you mean with "then wrap the 'getter' in a plot_runid() method so you dont write it over and over"?
d
so wrap your plotting logic in a function
adds the labels for you
c
The plotting functionality is placed in a custom dataset - basically passing the plotly.go.Figure object to a custom dataset that saves it as json, html and png
d
ah so you can define this in the custom dataset
so you don't have to write it over and over
c
yes - this way I have a version on the plot. I just want to add the version as text in the plot as well. Good to know when sharing between co-workers
d
💪