hooks-and-extensions
Extend Kedro with hooks plugins custom CLI commands custom datasets custom runners notebooks serving and deployment integration points.
- License 许可
- Apache-2.0
- 最近更新
- 2026-09-03
- Stars
- ★ 351
- Forks
- 27
01 前言 Front Matter
- name
- hooks-and-extensions
- license
- Apache 2.0
- metadata
- { "disco-role": "operating" }
- description
- Extend Kedro with hooks plugins custom CLI commands custom datasets custom runners notebooks serving and deployment integration points.
- disable-model-invocation
- true
02 资源文件 4
- 参考文档references/custom-datasets-and-cli.md10.4 KB
- 参考文档references/deployment-and-integrations.md10.0 KB
- 参考文档references/hooks-and-plugins.md10.1 KB
- 参考文档references/troubleshooting.md12.5 KB
03 SKILL.md 正文
Hooks And Extensions
Use this sub-skill when a task asks how to extend Kedro rather than only use a standard project: project hooks, installable plugins, custom Click commands, custom datasets, custom runner surfaces, IPython/Jupyter line magics, minimal HTTP serving, or deployment-platform integration patterns.
Route Here
- Add project hooks with
from kedro.framework.hooks import hook_impl, register instances insettings.pyasHOOKS = (...), or disable installed plugin hooks withDISABLE_HOOKS_FOR_PLUGINS. - Build or debug installable plugins that expose
kedro.hooks,kedro.cli_hooks,kedro.global_commands,kedro.project_commands,kedro.init,kedro.line_magic, or starter entry points. - Override or add project CLI commands through
src/<package_name>/cli.py, or expose reusable Click command groups from a plugin. - Implement an
AbstractDatasetorAbstractVersionedDatasetsubclass, especially when the task is about the extension contract rather than basiccatalog.ymlsyntax. - Design custom runner classes, integration runners, or HTTP/serving wrappers while routing detailed run semantics to runners and execution.
- Extend notebook/IPython workflows with
%reload_kedro,%load_node, orkedro.line_magicplugin entry points. - Adapt Kedro projects for Airflow, Databricks, Dask, MLflow, Pandera, Great Expectations, Spark, or minimal FastAPI serving.
Route Elsewhere
- Basic project creation, project detection,
KedroSession,kedro new,kedro package, or stockkedro ipython/kedro jupyter: read../project-cli-and-sessions/SKILL.md. - Runner choice,
kedro runflags, slicing, resume,ParallelRunnermultiprocessing details, or async I/O behavior: read../runners-and-execution/SKILL.md. - Dataset YAML, credentials, versioning, factories,
OmegaConfigLoader, and catalog validation basics: read../data-catalog-and-config/SKILL.md. - Pipeline graph authoring,
node(),Pipeline, namespacing, tags, and registry design: read../pipelines-and-nodes/SKILL.md. - Inspection snapshots, server endpoint schemas, or read-only server diagnostics: read
../inspection-and-server/SKILL.md. - Package install/import checks or broad task routing: return to
../../SKILL.md.
Current Facts
- Kedro target version is
1.4.0; import and distribution name arekedro; Python requirement is>=3.10. - Hook implementations import
hook_implfromkedro.framework.hooks; CLI hook implementations importcli_hook_implfromkedro.framework.cli.hooks. - Project hooks are registered as instances in
settings.pyunderHOOKS; installed plugin hooks are discovered from thekedro.hooksentry point group. DISABLE_HOOKS_FOR_PLUGINS = ("<plugin-distribution-name>",)prevents auto-registered hooks for selected plugin distributions.- Hook implementation arguments must not have default values; Pluggy may otherwise pass the defaults instead of Kedro's runtime values.
ParallelRunnerin Kedro 1.4.0 warns that node and dataset hooks are not executed in worker processes; chooseSequentialRunnerorThreadRunnerwhen those hooks are essential.- CLI plugin entry point groups include
kedro.global_commands,kedro.project_commands,kedro.init,kedro.line_magic,kedro.hooks, andkedro.cli_hooks. - Project command resolution order is built-in commands, then plugin commands, then project
cli.py; later sources can override earlier commands.
Reference Map
- Read
references/hooks-and-plugins.mdfor hook specs, hook signatures, registration, plugin entry point groups, CLI hooks, command precedence, and plugin debugging. - Read
references/custom-datasets-and-cli.mdforAbstractDatasetcontracts, versioned datasets, projectcli.pyoverrides, reusable plugin commands, custom runner extension surfaces, and validation checks. - Read
references/deployment-and-integrations.mdfor notebooks/IPython, line magics, HTTP serving extension, deployment-platform patterns, and optional dependency/security notes. - Read
references/troubleshooting.mdwhen hooks are not firing, plugin entry points do not load, custom commands conflict, datasets fail to instantiate, optional extras are missing, or serving/deployment integration fails.
Fast Patterns
- For a project hook, create
src/<package_name>/hooks.py, decorate methods with@hook_impl, omit unused parameters, do not use defaults, then register instances insrc/<package_name>/settings.pyasHOOKS = (ProjectHooks(),). - For hook ordering, treat order as non-guaranteed; project hooks follow last-in-first-out registration and plugin hooks are auto-registered first, but prefer
@hook_impl(tryfirst=True)or@hook_impl(trylast=True)only when order is essential. - For plugin hooks, expose an object instance through
[project.entry-points."kedro.hooks"]; for CLI lifecycle hooks, expose an instance through[project.entry-points."kedro.cli_hooks"]. - For custom CLI, use project
src/<package_name>/cli.pyfor project-specific overrides and pluginkedro.global_commandsorkedro.project_commandsfor reusable commands. - For custom datasets, subclass
kedro.io.AbstractDatasetorAbstractVersionedDataset, implementload,save, and_describe, and configure by fully qualified class path incatalog.yml. - For serving or deployment, first decide whether you need a Kedro-native extension point, an orchestrator plugin, or a thin wrapper around
KedroServiceSession; warn before network, cloud, credential, or public-server operations.
Safety Notes
- Set
KEDRO_DISABLE_TELEMETRY=1orDO_NOT_TRACK=1for CLI probes or automated examples when telemetry must be disabled. - Avoid printing credential dictionaries, runtime params with secrets, personal access tokens, or full platform paths from hooks and server endpoints.
kedro server start --reloadis development-only; the built-in server does not include authentication, authorization, request queuing, or per-request session isolation.- Deployment commands for Airflow, Databricks, cloud platforms, Docker, or plugin CLIs may create files, contact networks, upload artifacts, or use credentials; ask before executing them.
04 同仓库更多 Skills
passnet-triton-opt
Make a single PassNet Triton kernel fast AND numerically faithful: performance model (when a replacement can win at all), block/grid/warp tuning, autotune policy, launch overhead, and per-op numeric recipes to pass the dtype baseline tolerances. Use when a pass matches and is correct but speedup below expected, or when correctness fails by small numeric margins.
passnet-solve
END-TO-END playbook for solving one PassNet sample: analyze the computation graphs, decide the optimization strategy (what to fuse, what to replace, what to leave alone), drive the iteration loop, and maximize the sample score. This is the ENTRY skill — invoke it first for any PassNet optimization task; it tells you when to use passnet-pattern-fusion, passnet-triton-opt and passnet-feedback.
passnet-skill
PassNet GPU kernel optimization via compiler passes. Design and implement Triton-based optimization passes, create pass files under ./pass_dir/, self-evaluate with pass_evaluator, and iterate to maximize GPU speedup.
passnet-pattern-fusion
Author PassNet pass files: write patterns that actually MATCH the FX graph, pick fusion regions (which ops to absorb into one Triton kernel), and structure multi-pass submissions with the mandatory shared-dispatch architecture. Use when creating or fixing pattern()/replacement_args()/replacement_func() files, when a pass "failed to match", or when deciding how to fuse multiple kernels/ops.
passnet-orchestrate
Round/batch planning and decision support for PassNet graph optimization. Use for multi-sample triage, worker allocation, eval-budget policy, and post-eval keep/revert decisions. For solving one concrete sample end to end, use passnet-solve as the entry skill; consult this skill only when you need broader planning or a specific decision gate.
passnet-feedback
Fast, deterministic feedback for PassNet work: pre-flight pattern/match verification WITHOUT burning a GPU evaluation, per-node bottleneck analysis of a sample's graphs, and eval-log parsing into per-variant status + estimated score + failure classification. Use BEFORE every GPU evaluation (check_pattern), at the START of a sample (analyze_graph), and AFTER every evaluation (parse_eval_log).