-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
after_context_created
not the first hook to run, but is fixed when kedro-telemetry
is uninstalled
#2492
Comments
after_context_created
not the first hook to run, but is fixed when kedro-telemetry is uninstalledafter_context_created
not the first hook to run, but is fixed when kedro-telemetry
is uninstalled
@melvinkokxw Thanks for reporting this. In a kedro run, the catalog is created by the context so context hook is the earliest triggered hook. Can you share more how's your hook look like and do you still see the same issue when removed telemetry? |
@noklam Here is the hook I'm using: class MLFlowHooks:
"""
Initialise MLFlow and log useful tracking info automatically
"""
@hook_impl
def after_context_created(self, context):
"""Loads MLFlow catalog and parameters if MLFlow is enabled
Args:
context: Kedro context
"""
if not self.mlflow_enabled:
return
context.config_loader["parameters"] = {
**context.config_loader["parameters"],
**context.config_loader["mlflow_parameters"],
}
context.config_loader["catalog"] = {
**context.config_loader["catalog"],
**context.config_loader["mlflow_catalog"],
}
@hook_impl
def after_catalog_created(self, feed_dict):
"""
Check if MLFLow is enabled
Args:
feed_dict: Kedro feed dict
Returns:
"""
parameters = feed_dict["parameters"]
# MLFlow enabled?
self.mlflow_enabled = parameters.get("mlflow_enabled", False) When I removed |
Some debugging:
kedro/kedro/framework/session/session.py Lines 275 to 277 in 3439e72
kedro/kedro/framework/context/context.py Lines 295 to 302 in 3439e72
Note that However, kedro/kedro/framework/cli/cli.py Lines 134 to 145 in 3439e72
Working on gh-1942 to better understand what's happening. |
I think this was answer in slack but I can't find the thread now. |
|
@melvinkokxw I am closing this for now. The short answer to this is the execution orders are not clear when you have multiple hooks exist. In this case, What happens roughly
So your hook isn't really the "first hook". We need to document this better but this is not a bug. Related issues: |
This goes a bit deeper into the design of |
Description
after_context_created
should be the earliest hook triggered (as per Kedro's documentation) butafter_catalog_created
is triggered before it.When I uninstalled
kedro-telemetry
(to fix a separate issue), the hooks are triggered in the expected order.Raising the bug here instead of the
kedro-plugins
repo as I cannot confirm ifkedro-telemetry
causes the bugContext
I was doing a
kedro run
and trying to read parameters in a hook, expecting theafter_context_created
hook to be triggered first. Instead,after_catalog_created
was triggered before it.Steps to Reproduce
settings.py
kedro run
Expected Result
after_context_created
hook should be the earliest hook to be triggeredActual Result
after_catalog_created
is triggered before theafter_context_created
hookYour Environment
Include as many relevant details about the environment in which you experienced the bug:
pip show kedro
orkedro -V
): 0.18.7python -V
): 3.8.16settings.py
looks like this:The text was updated successfully, but these errors were encountered: