-
Notifications
You must be signed in to change notification settings - Fork 910
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
You can't manually enforce the order of local and plugin-based hooks #1939
Comments
Hi @foxale, hooks have been designed to run in the LIFO of registration (see https://kedro.readthedocs.io/en/stable/hooks/introduction.html#registering-your-hook-implementations-with-kedro). How would you envision being able to assign priory rules? Per Hook class or at the hook function level? |
Yes, I saw that before — but from what I understood and observed, there are separate queues for local hooks vs. plugin-based hooks. You can influence the registration order indirectly and directly with hook function annotations. I would want to decide, that |
kedro/kedro/framework/session/session.py Lines 110 to 113 in d019eda
I believe this is how Kedro works currently (in-order)
For 2., I am not sure if they operate in a specific order - maybe it's ordered by the name but whatever it is, it's not by our design. I think I had some discussion with @AntonyMilneQB about this before - there wasn't any clear conclusion. How does The |
Thanks for the context @noklam! I checked One way would be implement a mechanism to put hooks in order on
Side note: that could actually be used to enrich Side note 2: that could fix #1935 as well. |
@foxale I think this is supported already, although we don't have docs to spill this out clearly.
# settings.py
from kedro_mlflow.hooks import MLflowHooks # I make these import up but you get the point
DISABLE_HOOKS_FOR_PLUGINS = ("kedro-mlflow",)
HOOKS = (MLflowHook(), YourHook(),) # This is always a LIFO queue - in fact the LIFO order is inherit from `pytest` already One thing we may consider is to do the auto-register hook before the project hooks, but this is up for discussion. |
Awesome. I guess that solves most cases (including mine), with the exception of those that require different orders for different hook functions. |
Closing this issue as the problem is solved. Feel free to re-open and continue discussing if you encounter further issues with this! |
Description & Context
Some hooks come from plugins (like
kedro-mlflow
), whereas some may come from local hooks (like those). Currently, if many plugins and local hooks implement e.g.after_pipeline_run
, there is no way to manually enforce order in which all those functions will be invoked.This causes problems such as this one.
Also, while writing this post I realized another problem, which is using the name "hook" for both hook functions (e.g.
after_pipeline_run
hook function) and hook classes (e.g.DataCatalogHook
class)Steps to Reproduce
Available in the linked post above.
Expected Result
I assume we should be able enforce the order of hooks, assign them some priority or rules.
Your Environment
The text was updated successfully, but these errors were encountered: