Hi, I try to write some tests for kedro pipeline a...
# questions
Hi, I try to write some tests for kedro pipeline and include some hooks in it. I started from example:https://docs.kedro.org/en/stable/development/automated_testing.html#create-an-example-test There
is called, upon which I call
, and then try to run some pipeline with:
SequentialRunner(is_async=True).run(model_pipeline, catalog, hook_manager)
However it does not work, the hook does not get called. Any ideas what am I missing?
CustHook has some hooks defined, like
where I
assert False
to notice it being executed, but it's skipped
Can you show
Yea I was debugging and got to the answer: I forgot to add @hook_impl decorators after I inherited from other class when overriding hook methods
Thanks to this journey I got to see in detail how pluggy hook registering mechanisms work xD
👍🏼 1
yeah I was suspecting it's
Let us know if you spot anything! the test documentation is relatively new
I'm ashamed of asking question about it 😞
nah no worries, I make the same mistakes 100 times
everytime I create a hook I do a print to make sure it is actually running
There are hook validation for invalid @hook_impl, maybe it could also validate if there is no hook method registered
keep asking!
@Nok Lam Chan do you think it’s possible for us to catch that sort error for the user?
https://github.com/kedro-org/kedro/issues/2862 The original implementation does not cover this but I think it should be feasible.
❤️ 1
feels like a really good thing to fix so people don’t need to read pluggy internals to extend kedro 🤔
👍 1
cc @Juan Luis
I saw that you can override function that detects whether function is a hook or not, we could provide a version that does not need @hook_impl or gives you a warning if the function is called like a registered hook but misses @hook_impl
also bonus question in my testing with hooks topic: so after/before node created hooks get called fine with sequential runner, but hooks like
does not get called by class
and I don't know what actually calls
hook - in my test I had to call those 2 manually to make the hook behave - is there a better way to use some kedro internal objects that do the hook calling for me?
Session.load_context() is my bet, do you mind open a new thread or issue for this question? I think this is a good question and deserves some attention