Yijun Tang
09/03/2024, 9:43 PMlater calls will take precedence refers to in the docstring of with_modules? I was wondering if it’s possible to have 2 modules, module_a and module_b , that both implement a common_node node, and calling builder.with_module(module_a) and then builder.with_module(module_b) would use the common_node from module_b to build the DAG - but this doesn’t seem to be the case.Elijah Ben Izzy
09/03/2024, 9:45 PMcommon_node, and error out. Just to ensure — what happens when you try?
Otherwise “overriding” functions is something we’re thinking about but I don’t think we have the capability yet.
The common approach is to switch between a/b depending on a config, and parse out common ones.Elijah Ben Izzy
09/03/2024, 9:47 PM@config.when to help with this type of thing!
e.g.
@config.when(context="a")
def common_node__a() -> ...:
...
other module:
@config.when(context="b")
def common_node__b() -> ...:
...Yijun Tang
09/03/2024, 9:54 PM__a and __b with config , but sounds like that’s the best bet to implement this for now?Stefan Krawczyk
09/03/2024, 9:56 PM__ suffix if they’re in different filesYijun Tang
09/03/2024, 9:57 PMStefan Krawczyk
09/03/2024, 9:58 PMStefan Krawczyk
09/03/2024, 9:59 PMYijun Tang
09/03/2024, 10:01 PMonly required because you can’t have two python functions with the same name in a moduleThat makes a lot of sense!
this also means that if you run the modules individually, you’ll need to provide config valuesNoted, a small inconvenience
Yijun Tang
09/03/2024, 10:03 PMwith_modules() call?Stefan Krawczyk
09/03/2024, 10:05 PMStefan Krawczyk
09/03/2024, 10:05 PMYijun Tang
09/03/2024, 10:06 PMwith_modules(*module, override=False) that has to be explicitly turned on?Elijah Ben Izzy
09/03/2024, 10:07 PMallow_verride=TrueElijah Ben Izzy
09/03/2024, 10:08 PM.allow_module_overrides() or something like that.Stefan Krawczyk
09/03/2024, 10:10 PMwith_modules would be more contextually relevant personally…Elijah Ben Izzy
09/03/2024, 10:12 PMallow_overrides=True allows overrides globally (which is iffy). That said, very few people use multiple with_modules calls, so I’m not super concerned, as long as we document.Stefan Krawczyk
09/03/2024, 10:14 PMYijun Tang
09/03/2024, 10:28 PMany call toJust to check my understanding, this means in a sequence of multipleallows overrides globallyallow_overrides=True
with_module() calls, if any one call has allow_overrides=True , the overriding behavior will be applied to the entire sequence of modules added to the builder?Elijah Ben Izzy
09/03/2024, 10:32 PMYijun Tang
09/03/2024, 10:34 PMStefan Krawczyk
09/03/2024, 10:50 PMYijun Tang
09/04/2024, 12:02 AMYijun Tang
09/04/2024, 1:05 PMElijah Ben Izzy
09/13/2024, 4:36 PMsf-hamilton==1.77.0rc0 has it. You can see it here: https://github.com/jernejfrank/hamilton/blob/feature/override_nodes_at_module_import/examples/module_overrides/run.py — should be simple as just adding the .allow_module_overrides() call on the builderYijun Tang
09/13/2024, 7:31 PM