Mauricio
06/16/2025, 7:41 PMto materialization to execute a function after it happens?
# run.py
materializers = [to.csv(id="save_file", dependencies=["file_modify"], path="./out.csv")]
...driver build and execution
# pipeline.py
def load_saved_file(save_file, remote_path):
fs.put(save_file, remote_path)
When I try to reference like this I get Duplicate node names found
Any advice?Stefan Krawczyk
06/18/2025, 2:00 AMMauricio
06/18/2025, 1:33 PMStefan Krawczyk
06/18/2025, 4:46 PMdef load_saved_file(save_file, remote_path):
fs.put(save_file, remote_path)
you want save_file here to be passed the value "./out.csv" right? or an actual file handle?Mauricio
06/18/2025, 6:02 PMMauricio
06/18/2025, 6:05 PMStefan Krawczyk
06/18/2025, 6:09 PMmaterializers = [to.csv(id="save_to_csv", dependencies=["file_modify"], path=source("save_file_path")]
...driver build and execution
# pipeline.py
def load_saved_file(save_file_path, remote_path):
fs.put(save_file, remote_path)I think you want something more like this, no? I forget whether we allow
source in the materializer bit -- but it feels like that's the thing you want to connect right?Mauricio
06/18/2025, 6:13 PMload_saved_file function it would build the dependency between those 2 components (save_to_csv ---then---> load_saved_file)?Stefan Krawczyk
06/18/2025, 6:20 PMStefan Krawczyk
06/18/2025, 6:22 PMMauricio
06/18/2025, 6:22 PMStefan Krawczyk
06/18/2025, 6:30 PMMauricio
06/18/2025, 6:36 PMStefan Krawczyk
06/18/2025, 6:38 PMMauricio
06/18/2025, 6:38 PMwith_materializersStefan Krawczyk
06/19/2025, 4:34 AMfrom hamilton.function_modifiers import save_to, source, inject
import pandas as pd
def data_from_sql(sql: str)->list:
return []
@save_to.csv(path=source("file_path"))
def transformed_data(data_from_sql: list) -> pd.DataFrame:
return data_from_sql
@inject(dep=source("save.transformed_data"))
def upload_data(file_path: str, dep: dict) -> dict:
return {}
def copy_to_db(upload_data: dict) -> dict:
return {}
Using the save_to decorator -- because it's resolved when building the graphStefan Krawczyk
06/19/2025, 4:38 AM@save_to.csv(path=source("file_path")) with the to.csv version using with_materializers then yes I get the Duplicate node names found. This is a constraint in the code right now -- it could be relaxed ...
How dynamic do you want this to be? Since you could use @config.when / different modules to build the graph from to possibly achieve the same result.Stefan Krawczyk
06/20/2025, 5:11 AMMauricio
06/23/2025, 1:47 PM