#5796·kedro

Generator node wrapped with a functools.wraps decorator is saved as a generator object instead of being streamed

Author: MohammadHijjawi97Created Sep 28, 2026Updated Sep 28, 2026
LabelsCommunity

Description

Since #5512, runners only stream outputs when inspect.isgeneratorfunction(node.func) is true. That check does not follow __wrapped__. So a generator function decorated with a standard functools.wraps decorator (logging, timing, or a function set via node.func in a hook) is no longer streamed. catalog.save receives the generator object instead, or the unzipped iterators for multiple outputs.

python
from functools import wraps

def logged(func):
    @wraps(func)
    def wrapper(*a, **k):
        return func(*a, **k)
    return wrapper

@logged
def gen():
    yield from range(3)

# node(gen, None, "out") with a dataset that records its saves
# expected saves: 0, 1, 2   actual: [<generator object gen ...>]

Async runs also do not reject such nodes, although they reject undecorated generator nodes.

Possible fix

Use inspect.isgeneratorfunction(inspect.unwrap(node.func)) in both checks in kedro/runner/task.py. Non-generator iterables such as mne.Epochs would still be passed through unchanged.

Environment

kedro main (1.7.0)