[KED-2143] Adding a ConfigLoader instance into hook specs params
See original GitHub issueDescription
When developping a kedro plugin, i regularly need to access to configs and potentielly some plugin-specific configs files. Since the plugin use hook mechanism, i no longer can bring whatever context attribute to my hook implemantation (except the parameters defined in the hook specs).
Context
Here in the kedro-mlflow plugin we were forced to redefine a ConfigLoader instance inside the plugin. That lead to incoherence between the context ConfigLoader property and the new Configloader created inside the hook.
Other plugins will need this functionality, i imagine a kedro-spark plugin that use hook mechanism and access a spark config file from project folder path (spark.yml), or a kedro-sas plugins that do the same thing (getting configs in order to create a parametrized session)
Possible Implementation
A possible implementation is to pass the context config_loader to the hook.
hook specs
@hook_spec
def before_pipeline_run(
self, run_params: Dict[str, Any], pipeline: Pipeline, catalog: DataCatalog, config_loader: ConfigLoader
) -> None:
context
hook_manager = get_hook_manager()
hook_manager.hook.before_pipeline_run( # pylint: disable=no-member
run_params=record_data, pipeline=filtered_pipeline, catalog=catalog, config_loader=self.config_loader
)
Issue Analytics
- State:
- Created 3 years ago
- Comments:17 (16 by maintainers)

Top Related StackOverflow Question
@Galileo-Galilei you are right assuming that
KedroSessionhas been designed to eventually become responsible for carryingKedroContext(and project data in general) which would make the use case that you’ve describe much less painful. Hence, as you have already noticed it has been made a singleton to ensure its accessibility from hooks, for example.However, this is still a work in progress and currently it’s not at the stage where we can officially announce it and freeze the design. The general idea is that
KedroSessionwill gradually take over the responsibility for the lifecycle events, whileKedroContextwill be treated as a “gatekeeper to the library components” (definition by @limdauto) in a new model.Adding one minor item in case I forgot.
config_loader, probably similar to what we do with catalog.