Iliya R
08/20/2024, 7:11 PMparameterize_extract_columns and saw that it requires ParameterizedExtract objects. Suggestion: have it accept some sort of named/ordered fields (e.g. list of dicts, or list of tuples) then wrap them internally in ParameterizedExtract . It saves an import and is a tiny bit more elegant imho. wdyt?Elijah Ben Izzy
08/20/2024, 7:43 PMTuple[str, …], Dict[str, ParametrizedDependency] to be cumbersome — lots of tuples. That said, our solution si, as you pointed out, quite cumbersome as well 😆 And it adds extra surface area.
So, we’re going to want to keep it backwards compatible, but taking a step back — what do you think the ideal interface would be? Lists of tuples might be nice, but maybe theres a room for a cleaner way of presenting it…Iliya R
08/21/2024, 1:00 AM.model property (I don't know if that's even possible), e.g. pseudocode
from hamilton.decorators import parameterize, subdag
...
@parameterize(
# the top level will always contain a {*}collection of the associated model type
parameterize.model(
# these will be optional (or mandatory) kwargs, and hence hinted
output_name=...,
replace_dict=...,
docstring=...,
),
...
)
def foo(...): ...
@subdag(
subdag.model(
subdag_param_1=...,
...
)
)
def bar(...): ...Iliya R
08/21/2024, 6:38 AMparameterize_extract_columns - shouldn't there be a step that renames the df columns so that extraction can pick them up? According to the extract_columns docs, when the output column doesn't exist it either errors out or fills it with a default value. There's a different behavior here that's "hidden" by the reassign_columns parameter which is "active" by default. I think the docs should be amended to explain this behavior explicitly (what happens when it's on and off).
@parameterize_extract_columns(
ParameterizedExtract(
("outseries1a", "outseries2a"),
{"input1": source("inseries1a"), "input2": source("inseries1b"), "input3": value(10)},
),
ParameterizedExtract(
("outseries1b", "outseries2b"),
{"input1": source("inseries2a"), "input2": source("inseries2b"), "input3": value(100)},
),
)
def fn(input1: pd.Series, input2: pd.Series, input3: float) -> pd.DataFrame:
return pd.concat([input1 * input2 * input3, input1 + input2 + input3], axis=1)
# How we magically get a series named e.g. `outseries1a` out of the above is unclear from the docstring.Elijah Ben Izzy
08/21/2024, 4:36 PM@parameterize_extract_columns is a bit messy though — there’s a lot to spec out. Having a .model is a clever idea, but I guess why have that if we can just have the parameters?Elijah Ben Izzy
08/21/2024, 4:37 PMElijah Ben Izzy
08/22/2024, 5:06 PMUnion[ParameterizedExtract, Tuple], and we can create the ParameterizeExtract under the hood. Should be an easy change, happy with a PR if you want!