fastflowtransform.hooks.registry¶
fft_hook ¶
fft_hook(name=None, when=None)
Decorator to register a Python hook.
Usage:
from fastflowtransform.hooks.registry import fft_hook
@fft_hook(name="python_banner") # no 'when' -> wildcard
def on_run_start(ctx: dict[str, Any]):
...
@fft_hook(name="python_banner", when="on_run_start")
def banner_for_run_start(ctx: dict[str, Any]):
...
name: logical hook name (matches project.ymlhooks: ... name:). If omitted, defaults to the function name.when: lifecycle event ("on_run_start", "on_run_end", "before_model", "after_model", etc.). If omitted, the hook is registered for the wildcard phase "*".
Source code in src/fastflowtransform/hooks/registry.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
resolve_hook ¶
resolve_hook(when, name)
Retrieve a previously-registered hook function.
Resolution order
- Exact match: (when, name)
- Wildcard match: ('*', name)
Raises KeyError if not found.
Source code in src/fastflowtransform/hooks/registry.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | |
load_project_hooks ¶
load_project_hooks(project_dir)
Load all Python files under <project_dir>/hooks/**.py.
This executes the modules (without requiring them to be proper
Python packages), so any @fft_hook(...) calls will populate the
registry.
This is intentionally import-path agnostic: we don't require
project_dir to be on sys.path and we don't care about the
module name outside of this function.
Source code in src/fastflowtransform/hooks/registry.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | |