This message was deleted.
# hamilton-help
s
This message was deleted.
s
thanks for the question @ishan!
it seems they are more for cases when you want to run a node N times for each parameter specification
Close. You can think of
@parameterize*
decorators as a function that “creates a bunch of other functions”. E.g. you have a fixed list of parameters and you want to create a function per “parameter”, where a “parameter” can be values, or other functions/nodes you want to depend on. For simple values, rather than writing:
Copy code
def spend_lag_1_week(spend: pd.Series) -> pd.Series:
    return spend.shift(1)

def spend_lag_2_week(spend: pd.Series) -> pd.Series:
    return spend.shift(2)
...
you can write
Copy code
MAPPING = {
  (f'spend_lag_{v}_week', f'Spend lag {v}'): v for v in [1, 2, 3, 4, ..., n]
}

@parameterize_values(parameter="shift_value", assigned_output=MAPPING)
def spend_lag_creator(shift_value: int, spend: pd.Series) -> pd.Series
   return spend.shift(shift_value)
I was looking to run a node only once but with the “parameter” specified at runtime.
Yep you can do that easily. You just need to adjust your example:
Copy code
def c(a: pd.Series, b: pd.Series, param1: int, param2: int) -> pd.Series:
    # return a * 3 + b * 2
    return a * param1 + b * param2
Then at run time, you’d just pass in:
"param1":3, "param2":2
as inputs to .execute()
Copy code
dr = driver.Driver(config, module1, ...)
df = dr.execute(["output1", ...], inputs={"param1":3, "param2":2})
Does that help?
i
Thanks, let me give it a try!
👍 1