"after_node_run" hook

Hi all, I’m new to hooks and after reading the hook_spec for after_node_run, I note that it has node, catalog, inputs, outputs, is_async and run_id. However when I tried to implement my @hook_impl of after_node_run, the only 3 arguments I can access are node, inputs and outputs. Is there something I’m missing? For reference I attached the hook_spec below. Thanks all

@hook_spec
def after_node_run(  # pylint: disable=too-many-arguments
    self,
    node: Node,
    catalog: DataCatalog,
    inputs: Dict[str, Any],
    outputs: Dict[str, Any],
    is_async: bool,
    run_id: str,
) -> None:

I used this debug function to test

@hook_impl
def after_node_run(self, *args, **kwargs):
    self.logger.info(f"ARGS {args}")
    self.logger.info(f"ARG LENGTH: {len(args)}")
    self.logger.info(f"KWARGS {kwargs}")
    self.logger.info(f"KWARG LENGTH: {len(kwargs)}")

ARGS: Node, inputs, outputs
ARG LENGTH: 3
KWARGS: {}
KWARG LENGTH: 0

Do you have a use case for the other arguments? I have never used them, so I can’t say that I am familiar.

Hi thanks for your reply, I’m trying to use some parameters in catalog.

1 Like

If you are using 0.17.x you can get parameters from session.context

You can follow the docs on how to get to the session.

https://kedro.readthedocs.io/en/stable/04_kedro_project_setup/03_session.html