Slackbot
12/28/2023, 5:58 PMStefan Krawczyk
12/28/2023, 6:15 PMput_features_together
could be replaced by - https://hamilton.dagworks.io/en/latest/reference/api-extensions/custom-result-builders/ if it’s the last step.Arthur Andres
12/28/2023, 6:31 PMStefan Krawczyk
12/28/2023, 6:35 PM@config.when
over a set of functionsStefan Krawczyk
12/28/2023, 6:43 PMStefan Krawczyk
12/28/2023, 6:48 PMkwargs
only functions in the middle, that need values passed in via execute to know what they operate over…Elijah Ben Izzy
12/28/2023, 6:50 PM@inject_from_config(feature_set="features_to_use")
def put_features_together(**features: pa.Table):
...
def inject_from_config(feature_set: str):
@functools.wraps(fn)
def decorator(fn):
fn = resolve(when=ResolveAt.CONFIG_AVAILABLE, decorate_with=lambda feature_sets: feature_sets[feature_set])
return fn
return decorator
dr = driver.Driver({"feature_sets" : {"features_to_use" : ["feature_table_1", "feature_table_2"]}})
dr.execute(["put_features_together"])
Note that this involves a limitation where resolve
refers to config items by name of parameter — this is something I’d want to change at some point, to make it easier so they don’t have to be nested under a fixed feature_sets
. That said, the high-level is that the code is easier to read/understand, and you can mess with the way it works under the hood…Arthur Andres
12/28/2023, 8:58 PMconfig={"requested_features": ["feature_table_1", "feature_table_2"}
. I’ll change the config between runs.Arthur Andres
12/28/2023, 9:33 PM@resolve(
when=ResolveAt.CONFIG_AVAILABLE,
decorate_with=lambda feature_tables: inject(
feature_tables=group(
**{feature_table: source(feature_table) for feature_table in feature_tables}
)
),
)
def get_features(feature_tables: dict[str, pa.Table]) -> list[pa.Table]:
return list(feature_tables.values())
Arthur Andres
12/28/2023, 9:35 PMStefan Krawczyk
12/28/2023, 9:36 PMElijah Ben Izzy
12/28/2023, 11:22 PM