https://kedro.org/ logo
#beginners-need-help
Title
# beginners-need-help
d

datajoely

02/11/2022, 1:30 PM
What do you want from the session? The answer this question will likely be lifecycle hooks
c

czix

02/11/2022, 1:31 PM
I want the session_id
d

datajoely

02/11/2022, 1:31 PM
So is that not equivalent to the
run_id
here?
c

czix

02/11/2022, 1:32 PM
Yes, I guess that is the same
d

datajoely

02/11/2022, 1:32 PM
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

czix

02/11/2022, 1:33 PM
I could also read that was the reason you removed it
d

datajoely

02/11/2022, 1:33 PM
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

czix

02/11/2022, 1:34 PM
Okay, I understand the reasoning
d

datajoely

02/11/2022, 1:34 PM
💪
c

czix

02/11/2022, 1:35 PM
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

czix

02/11/2022, 1:36 PM
Super thanks 👍
d

datajoely

02/11/2022, 1:36 PM
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

czix

02/11/2022, 1:37 PM
arh yes - how do you do that?
d

datajoely

02/11/2022, 1:39 PM
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

czix

02/11/2022, 1:40 PM
Okay, using the pipeline hook. Nice
d

datajoely

02/11/2022, 1:40 PM
👍
c

czix

02/11/2022, 2:41 PM
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

datajoely

02/11/2022, 2:42 PM
so wrap your plotting logic in a function
adds the labels for you
c

czix

02/11/2022, 2:44 PM
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

datajoely

02/11/2022, 2:44 PM
ah so you can define this in the custom dataset
so you don't have to write it over and over
c

czix

02/11/2022, 2:45 PM
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

datajoely

02/11/2022, 2:47 PM
💪