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

tom kurian

08/30/2023, 9:42 AM
Hey all I have one more doubt about Hooks. I have a use case where I am tracking the performance metric of nodes using the before and after-run hooks. I was able to implement the logic, and it's working fine as expected. Now, I need to ensure that it will execute only in certain environments (such as production environments like Databricks, Azure, AWS, and so on), and not on local runs.
d

datajoely

08/30/2023, 9:47 AM
so there are two options that come to mind: • You can use the
env
attribute of the hook spec so that when you do
kedro run --env prod
you can intercept this • The other more option is to maintain a list of environment variables present in those systems like
DATABRICKS_RUNTIME_VERSION
t

tom kurian

08/30/2023, 9:55 AM
but it is available only for pipeline hooks right !!!
d

datajoely

08/30/2023, 9:56 AM
the env attribute? which hooks are you using
t

tom kurian

08/30/2023, 9:56 AM
before and after node run
d

datajoely

08/30/2023, 9:56 AM
gotcha
image.png
🥳 1
the trick is to use class state