Skip to main content

PyPI Python License Kedro pluggy Ruff uv prek

kedro-intercept

A Kedro hook for attaching interceptors to pipeline lifecycle phases. Unlike writing a hook class, interceptors are declared in the pipeline definition — scoped to the node or dataset they belong to.

Full documentation at saemeon.github.io/kedro-intercept

Installation

pip install kedro-intercept

The hook is auto-discovered via Kedro's entry point mechanism. No settings.py changes needed.

Usage

Call intercept_node next to the node it applies to:

from kedro_intercept import intercept_node

my_node = node(func=train, inputs="raw", outputs="model", name="train_model")

intercept_node(
    my_node,
    before_node_run=log_start,
    after_dataset_saved={"model": validate_model},
)

For global phases, node can be omitted:

intercept_node(before_pipeline_run=setup, after_pipeline_run=teardown)

Or use intercept directly by phase name:

from kedro_intercept import intercept

intercept("before_pipeline_run", setup)
intercept("before_node_run", log_start, name="train_model")
intercept("after_dataset_saved", validate_model, name="model")

Parameter matching

Interceptors only need to declare the parameters they use. Everything else is dropped:

def log_start(node, run_id):
    print(f"{node.name} started — run {run_id}")

Available parameters depend on the phase. See the Kedro hooks documentation for the full signatures.

Phases

Global

Phase When
after_context_created After KedroContext is created
after_catalog_created After the data catalog is created
before_pipeline_run Before the pipeline starts
after_pipeline_run After the pipeline finishes
on_pipeline_error If the pipeline raises

Node-level

Phase When
before_node_run Before the node runs
after_node_run After the node runs
on_node_error If the node raises

Dataset-level

Phase When
before_dataset_loaded Before a dataset is loaded
after_dataset_loaded After a dataset is loaded
before_dataset_saved Before a dataset is saved
after_dataset_saved After a dataset is saved

Dataset phases accept a single callable (applied to all inputs/outputs), a list, or a dict keyed by dataset name:

intercept_node(
    my_node,
    after_dataset_saved={"predictions": validate, "metrics": log_metrics},
)

Assert variants

Every phase has an assert_ variant that re-raises on failure instead of logging a warning:

intercept_node(
    my_node,
    assert_after_dataset_saved={"predictions": check_no_nulls},
)

Logging

Kedro's default logging only covers the kedro namespace. To see output from this package, add to conf/logging.yml:

loggers:
  kedro_intercept:
    level: INFO

License

MIT

Metadata

Release files for kedro-intercept 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kedro-intercept 0.0.1
File Size Uploaded
kedro_intercept-0.0.1.tar.gz 81.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kedro-intercept 0.0.1
File Interpreter ABI Platform
kedro_intercept-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 91.7 kB

Release files / kedro_intercept-0.0.1.tar.gz

Download URL kedro_intercept-0.0.1.tar.gz
Size 81.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c63956e7fc1d209ece0a650ee1183d9d59565b32e8f6f94803362cf635098460
BLAKE2b-256 checksum
How to use checksums
9fe75ed1b9973711545dc6b904b6ea4c4900e0312114eae5a2a3400fab026c1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 21, 2026.

Transparency log

Release files / kedro_intercept-0.0.1-py3-none-any.whl

Download URL kedro_intercept-0.0.1-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1837121c1c115c198aa5faf161fb0ff9188aa9938ba02efcf29ba7e08505f477
BLAKE2b-256 checksum
How to use checksums
c02bbe65aedceca81b4ed73f37b54c5fdad86955869d565055cb69a0bcd1a02d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page