fastflowtransform¶
FastFlowTransform package entry point.
Expose the package version and a few commonly-used types/APIs for convenience. Importing here is intentionally lightweight to avoid circular imports with CLI code.
EnvCtx
dataclass
¶
Stable environment context used for fingerprinting. Include only inputs that should invalidate compiled artifacts when they change.
Source code in src/fastflowtransform/fingerprint.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
relation_for ¶
relation_for(node_name)
Map a logical node name to the physical relation (table/view name). Convention: - if the name ends with '.ff' → strip the suffix (e.g. 'users.ff' → 'users') - otherwise: return unchanged
Source code in src/fastflowtransform/core.py
822 823 824 825 826 827 828 829 | |
levels ¶
levels(nodes)
Returns a level-wise topological ordering. - Each inner list contains nodes with no prerequisites inside the remaining graph (i.e. eligible to run in parallel). - Ordering within a level is lexicographically stable. - Validation for missing deps/cycles matches topo_sort.
Source code in src/fastflowtransform/dag.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | |
model ¶
model(name=None, deps=None, require=None, *, tags=None, kind='python', materialized=None, meta=None)
Decorator to register a Python model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str | None
|
Logical node name in the DAG (defaults to function name). |
None
|
deps
|
Sequence[str] | None
|
Upstream node names (e.g., ['users.ff']). |
None
|
require
|
Any | None
|
|
None
|
tags
|
Sequence[str] | None
|
Optional tags for selection (e.g. ['demo','env']). |
None
|
kind
|
str
|
Logical kind; defaults to 'python' (useful for selectors kind:python). |
'python'
|
materialized
|
str | None
|
Shorthand for meta['materialized']; mirrors config(materialized='...'). |
None
|
meta
|
Mapping[str, Any] | None
|
Arbitrary metadata for executors/docs (merged with materialized if provided). |
None
|
Source code in src/fastflowtransform/decorators.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 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 112 113 114 115 116 117 118 119 | |
build_env_ctx ¶
build_env_ctx(*, engine, profile_name, relevant_env_keys=(), sources=None)
Construct an EnvCtx from engine/profile + a curated set of environment variables and the (normalized) sources.yml mapping. Only the provided environment keys are captured; all others are ignored.
Source code in src/fastflowtransform/fingerprint.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
fingerprint_py ¶
fingerprint_py(*, node, func_src, env_ctx, dep_fps=None)
Compute a stable fingerprint for a Python model. Inputs: - node : Node or node name - func_src : normalized function source (use get_function_source) - env_ctx : EnvCtx or compatible mapping - dep_fps : mapping of dependency name → fingerprint
Source code in src/fastflowtransform/fingerprint.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
fingerprint_sql ¶
fingerprint_sql(*, node, rendered_sql, env_ctx, dep_fps=None)
Compute a stable fingerprint for a SQL model. Inputs: - node : Node or node name for stable identity and relation - rendered_sql : final SQL after templating (ref()/source() resolved as in executor) - env_ctx : EnvCtx or compatible mapping (engine, profile, selected env vars, sources) - dep_fps : mapping of dependency name → fingerprint (to invalidate downstream)
Source code in src/fastflowtransform/fingerprint.py
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
get_function_source ¶
get_function_source(func)
Return a best-effort, stable source string for a Python callable.
Strategy (in order): 1) inspect.getsource(func) → dedented string 2) Read the defining file (co_filename) and slice starting at co_firstlineno until the next top-level def/class (heuristic). Dedent as needed. 3) Final fallback: combine qualified name and bytecode to ensure stability.
This ensures fingerprinting works even for dynamically loaded modules, lambdas, or environments where inspect cannot read the original file (e.g., zipimport).
Source code in src/fastflowtransform/fingerprint.py
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 | |
normalized_sources_blob ¶
normalized_sources_blob(sources)
Return a stable JSON blob for a sources.yml mapping. Keys are sorted recursively; absent input becomes "{}".
Source code in src/fastflowtransform/fingerprint.py
83 84 85 86 87 88 | |