#5789·kedro

run_params['runner'] passed to hooks is 'None' or a repr with a memory address, never the runner name

Author: Rodrigo-PalmaCreated Sep 24, 2026Updated Sep 25, 2026
LabelsCommunity

Description

The runner entry that hooks receive in run_params is never a runner name. It is either the string 'None' or the repr of a runner instance, complete with a memory address.

KedroSession.run builds record_data like this:

python
record_data = {
    ...
    "runner": getattr(runner, "__name__", str(runner)),
    ...
}

runner = runner or SequentialRunner()
if not isinstance(runner, AbstractRunner):
    raise KedroSessionError(
        "KedroSession expect an instance of Runner instead of a class."
        "Have you forgotten the `()` at the end of the statement?"
    )

Two things go wrong at once:

  1. record_data is built before the runner or SequentialRunner() fallback, so a plain session.run() records 'None' even though the pipeline is run by SequentialRunner.
  2. getattr(runner, "__name__", ...) only works for a class, and the very next lines reject a class. Instances have no __name__, so it always falls through to str(runner).

The hook spec documents the field as "runner": str and plugins read it to record which runner was used.

Context

Found while writing a hook that logs the runner. The value cannot be used for anything: it is not stable between runs, it is not comparable, and putting it in run metadata leaks a memory address.

The same line exists in service_session.py.

The reason the test suite does not catch this is that the tests assign the attribute by hand to a mock, which a real runner never has:

python
mock_runner.__name__ = "SequentialRunner"
...
"runner": mock_runner.__name__,

Steps to Reproduce

  1. Register a hook in settings.py:
python
from kedro.framework.hooks import hook_impl


class ShowRunner:
    @hook_impl
    def before_pipeline_run(self, run_params, pipeline, catalog):
        print("run_params['runner'] =", repr(run_params["runner"]))


HOOKS = (ShowRunner(),)
  1. Run the pipeline three ways:
python
session.run()                              # run_params['runner'] = 'None'
session.run(runner=SequentialRunner())     # '<kedro.runner.sequential_runner.SequentialRunner object at 0x10b0c9fa0>'
bash
kedro run                                  # '<kedro.runner.sequential_runner.SequentialRunner object at 0x109628d40>'

The kedro run path goes through project.py, which passes runner_obj(**runner_kwargs), so the CLI, the most common entry point, always produces the address form.

Expected Result

The runner class name, for example 'SequentialRunner', in all three cases, including the default one where no runner is passed.

Actual Result

run_params['runner'] = 'None'
run_params['runner'] = '<kedro.runner.sequential_runner.SequentialRunner object at 0x10b0c9fa0>'
run_params['runner'] = '<kedro.runner.sequential_runner.SequentialRunner object at 0x109628d40>'

Your Environment

  • Kedro version used: 1.6.0 (installed from source at 8d9abdf)
  • Python version used: 3.12.13
  • Operating system and version: macOS 15

Possible fix

Apply the SequentialRunner() fallback before building record_data and read the name from the instance's class, for example type(runner).__name__. The tests that assign __name__ to the mock should then assert the real value instead. I have a fix and a regression test ready and I am happy to open a PR if you agree with the approach.