Skip to content
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

Document more advanced hook use cases #2690

Open
Tracked by #3014
astrojuanlu opened this issue Jun 15, 2023 · 8 comments
Open
Tracked by #3014

Document more advanced hook use cases #2690

astrojuanlu opened this issue Jun 15, 2023 · 8 comments
Labels
Component: Documentation 📄 Issue/PR for markdown and API documentation good first issue Good first issues for beginners Issue: Feature Request New feature or improvement to existing feature

Comments

@astrojuanlu
Copy link
Member

astrojuanlu commented Jun 15, 2023

Description

Hooks are stateful objects, which enables users to, for example, store the context in the after_context_created hook and use it later in a hook that doesn't receive it:

class SomeHook:
    @hook_spec
    def after_context_created(self, context):
       ...
       self.my_azure_config = xxx

    @hook_spec
    def before_pipeline_run(self, pipeline):
       do_something_about_my_pipeline(pipeline, self.my_azure_config)

(code sample by @antonymilne )

We should better document this.

Context

Follow up from gh-506 and other discussions, see for example https://www.linen.dev/s/kedro/t/12112601/does-anyone-know-if-there-is-a-reason-why-we-could-not-pass-#4e36a67f-36d3-4354-a3d5-4347a59ef28f

This is very useful when migrating projects from older versions of Kedro, customize pipeline execution, and more.

@astrojuanlu astrojuanlu added Component: Documentation 📄 Issue/PR for markdown and API documentation Issue: Feature Request New feature or improvement to existing feature labels Jun 15, 2023
@noklam
Copy link
Contributor

noklam commented Jun 15, 2023

I thought I have created a ticket for this but I didnt. Thanks for creating this!

@noklam
Copy link
Contributor

noklam commented Jun 19, 2023

We need to explain WHY user need to do this, and examples of how to do it.

@noklam
Copy link
Contributor

noklam commented Jun 23, 2023

https://github.com/Galileo-Galilei/kedro-mlflow/blob/845ad919c9dbd020e948e8adc2e0f9064de1ef68/kedro_mlflow/framework/hooks/mlflow_hook.py#L50-L63 is a good example. This get asked in the intermediate training, so maybe we can create an example that showcase this.

@astrojuanlu

This comment was marked as off-topic.

@inigohidalgo
Copy link
Contributor

I've seen a couple of references to before_pipeline_created, both here and in discord, is this a hook which is available? I can't find reference to it anywhere in the docs.

@astrojuanlu
Copy link
Member Author

Hmmm actually, I'm not sure it ever existed, maybe it's a typo? Does before_pipeline_run or after_catalog_created suit your needs?

@inigohidalgo
Copy link
Contributor

It does, but it was introduced in 0.18.1 and I am on an earlier version. Granted, I am building the hooks to ease our transition to 0.18+, but if there was a hook already implemented which offered a similar API to test the functionality without needing to actually upgrade our project it would've been quicker to test.

Thanks

@astrojuanlu
Copy link
Member Author

Hooks were introduced in 0.16.0 (cc75a1c), and a few of them later on. Here's the list of hooks in 0.16.6 for example

https://docs.kedro.org/en/0.16.6/07_extend_kedro/04_hooks.html#execution-timeline-hooks

@noklam noklam added the good first issue Good first issues for beginners label Apr 9, 2024
@gitgud5000 gitgud5000 mentioned this issue May 14, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Documentation 📄 Issue/PR for markdown and API documentation good first issue Good first issues for beginners Issue: Feature Request New feature or improvement to existing feature
Projects
Status: No status
Development

No branches or pull requests

4 participants