question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

You can't manually enforce the order of local and plugin-based hooks

See original GitHub issue

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

  • kedro 0.18.3
  • Python 3.9.14

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
foxalecommented, Oct 17, 2022

Awesome. I guess that solves most cases (including mine), with the exception of those that require different orders for different hook functions.

1reaction
noklamcommented, Oct 17, 2022

@foxale I think this is supported already, although we don’t have docs to spill this out clearly.

  • In general, I think the order should not matter, they should operate independently. Auto-registered hooks shouldn’t need to be aware of the existence of other plugins - this would be the common case.
  • In special cases you need the fine grain control of order - you can import these hooks into your project directly and disable the automatic one.
# 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rules of Hooks - React
Hooks are JavaScript functions, but you need to follow two rules when using them. We provide a linter plugin to enforce these rules...
Read more >
The last guide to the useEffect Hook you'll ever need
Understanding how the useEffect Hook works, and why it requires a wholesale shift in mindset, is essential to writing modern React code.
Read more >
The WordPress Hooks Bootcamp: How to Use Actions, Filters ...
Learn WordPress Hooks in depth. Master Actions, Filters, and Custom Hooks by creating your own extensible plugin. Level up your WordPress ...
Read more >
Packer.nvim - GitHub
A use-package inspired plugin manager for Neovim. ... If you are on Windows 10, you need developer mode enabled in order to use...
Read more >
Git Hooks | Atlassian Git Tutorial
Hooks can reside in either local or server-side repositories, and they are ... own local hooks, so you can't use them as a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found