Zoltan Eisler
02/04/2025, 10:38 PMStefan Krawczyk
02/04/2025, 11:36 PMZoltan Eisler
02/05/2025, 6:50 AMStefan Krawczyk
02/05/2025, 8:07 AMray.remote around every function - so it wouldn’t do what you need I think.
🤔 hmm. I think you could build a little adapter and implement the run_before_node_execution function, e.g. like the PrintLn adapter (see blog post on adapters), and have it do what you need. Make sure the adapter is serializable and then add it to the adapters list.Zoltan Eisler
02/05/2025, 8:10 AMpre_graph_execute then? At any rate this is more than enough to get me going, thanks!Stefan Krawczyk
02/05/2025, 8:13 AMRayGraphAdapter each function will be serialize and deserialized and run as its own ray task. So I don’t understand “what” needs to be set up (e.g. is it local to the python process?) - it could be that you need to run it before each “node”. Or yeah, just use pre_graph_execute if it really only needs to be run once.Zoltan Eisler
02/05/2025, 8:23 AMElijah Ben Izzy
02/05/2025, 5:57 PMpre_graph_execute is what you want if it’s idempotent and before every execution — if it’s just on driver instantiation, you’ll want pre_do_anything — https://github.com/DAGWorks-Inc/hamilton/blob/7f4bc6633bc683b511cf95dbab1521d01bc894af/hamilton/lifecycle/base.py#L263Zoltan Eisler
02/05/2025, 6:00 PMElijah Ben Izzy
02/05/2025, 6:01 PMStefan Krawczyk
02/05/2025, 6:05 PMrun_before_node_execution so that when the task runs in the ray task process, it puts whatever is needed into the python process that you need to run.Zoltan Eisler
02/05/2025, 6:06 PMZoltan Eisler
02/06/2025, 10:17 AMStefan Krawczyk
02/06/2025, 5:48 PM__getstate__ & __setstate__ (example) can help here as objects are serialized and deserialized. Notoriously DB connections etc are not serializeableZoltan Eisler
02/06/2025, 6:22 PM