Last active
July 19, 2024 17:25
-
-
Save skrawcz/f448a66950a9bd8f1ed6c1c6f08040d1 to your computer and use it in GitHub Desktop.
@parameterize_sources example. This will create
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# functions.py - declare and link your transformations as functions.... | |
import pandas as pd | |
from hamilton.function_modifiers import parameterize_sources | |
def a(input: pd.Series) -> pd.Series: | |
return input % 7 | |
def b(a: pd.Series) -> pd.Series: | |
return a * 2 | |
def c(a: pd.Series, b: pd.Series) -> pd.Series: | |
return a * 3 + b * 2 | |
def d(c: pd.Series) -> pd.Series: | |
return c ** 3 | |
# there are ways to make getting this list dynamic | |
# but I wont show them here | |
node_list = ["a", "b", "c", "d"] | |
@parameterize_sources( | |
**{f"{n}_precision": {"val": n} | |
for n in node_list | |
} | |
) | |
def precision_func(val: pd.Series) -> float: | |
"""Precision calculation for {val}""" | |
return val.sum() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment