Note

This page is a reference documentation. It only explains the class signature, and not how to use it. Please refer to the user guide for the big picture.

brainprep.decorators.Hook

class brainprep.decorators.Hook[source]

Bases: object

Base class for decorator hooks.

Hooks used with the decorator must inherit from this class and and optionally override before_call and after_call methods. These methods act as hooks that run before and after the wrapped function is executed.

By default, both methods implement pass-through behavior: before_call returns the inputs unchanged, and after_call returns the outputs unchanged.

Methods

before_call(func, inputs)

Hook executed before the wrapped function is called. Must return a dictionary of (possibly modified) inputs.

after_call(func, outputs)

Hook executed after the wrapped function returns. Must return the (possibly modified) output value.

Notes

Subclasses may override one or both methods. If a method is not overridden, the default implementation simply returns its argument unchanged.

after_call(outputs)[source]

Transform and inspect outputs after the function call.

before_call(func, inputs)[source]

Transform and inspect inputs before the function call.

Examples using brainprep.decorators.Hook

RST reporting

RST reporting