Emeka Anyanwu
02/21/2025, 7:37 PMElijah Ben Izzy
02/21/2025, 7:39 PMEmeka Anyanwu
02/21/2025, 7:39 PMEmeka Anyanwu
02/21/2025, 7:46 PMElijah Ben Izzy
02/21/2025, 7:54 PMElijah Ben Izzy
02/21/2025, 7:55 PMEmeka Anyanwu
02/21/2025, 7:56 PMElijah Ben Izzy
02/21/2025, 7:56 PMEmeka Anyanwu
02/21/2025, 7:57 PMElijah Ben Izzy
02/21/2025, 7:57 PMEmeka Anyanwu
02/21/2025, 7:57 PMElijah Ben Izzy
02/21/2025, 7:57 PMElijah Ben Izzy
02/21/2025, 7:57 PMEmeka Anyanwu
02/21/2025, 7:58 PMEmeka Anyanwu
02/21/2025, 8:00 PMElijah Ben Izzy
02/21/2025, 8:04 PMStefan Krawczyk
02/21/2025, 8:05 PMdef my_function(a: int, b: int, __run_id: str) -> ...
then in your adapter code (actually this is something we could add to the SDK version easily)
def pre_graph_execute(...) :
...
if inputs is not None: # always have to pass in a dict for inputs to execution
inputs["__run_id"] = run_idEmeka Anyanwu
02/21/2025, 8:06 PMStefan Krawczyk
02/21/2025, 8:13 PMStefan Krawczyk
02/21/2025, 8:13 PMElijah Ben Izzy
02/21/2025, 8:14 PMElijah Ben Izzy
02/21/2025, 8:14 PMEmeka Anyanwu
02/21/2025, 8:15 PMEmeka Anyanwu
02/21/2025, 8:15 PMEmeka Anyanwu
02/21/2025, 8:16 PMElijah Ben Izzy
02/21/2025, 8:16 PMEmeka Anyanwu
02/21/2025, 8:17 PMElijah Ben Izzy
02/21/2025, 8:19 PMStefan Krawczyk
02/21/2025, 8:20 PMEmeka Anyanwu
02/21/2025, 8:21 PMStefan Krawczyk
02/21/2025, 8:23 PMEmeka Anyanwu
02/21/2025, 8:25 PMEmeka Anyanwu
02/21/2025, 8:25 PMElijah Ben Izzy
02/21/2025, 8:26 PMElijah Ben Izzy
02/21/2025, 8:27 PMStefan Krawczyk
02/21/2025, 8:27 PMEmeka Anyanwu
02/21/2025, 9:29 PMEmeka Anyanwu
02/21/2025, 9:30 PMElijah Ben Izzy
02/21/2025, 9:32 PM.set() in pre_node_execute
3. Call .get() from within the function
4. Call .set(None) in post_node_execute to reset itEmeka Anyanwu
02/21/2025, 9:33 PMElijah Ben Izzy
02/21/2025, 9:34 PMpre_node_execute and post_node_execute — context vars will work if you do (they’re meant to work in async contexts as wellElijah Ben Izzy
02/21/2025, 9:35 PMEmeka Anyanwu
02/25/2025, 2:46 PMEmeka Anyanwu
02/25/2025, 2:47 PMEmeka Anyanwu
02/25/2025, 2:47 PMElijah Ben Izzy
02/25/2025, 6:21 PMDataflowContext object that functions can declare or get globally (like burr does) — this is long overdue IMO
3. @Emeka Anyanwu to figure out what works for him, then post with code and we’ll take it over
4. @Elijah Ben Izzy to figure out why the context var approach didn’t work (there’s some weirdness with context/the indirection layer that Hamilton uses for execute — my guess is we need to do this directly for running the fn, not in pre/post node execute)