Just wanted to point out the elegance of the retur...
# general
g
Just wanted to point out the elegance of the return dict from
execute()
matching the dict passed as ~inputs~_*overrides*_, such that it provides really easy checkpoint-style processing.
Copy code
# foo and bar are expensive to compute
setup = {…}
midpoint = dr.execute(["foo", "bar"], inputs=setup)

# Now we can use foo and bar as overrides
vars1 = {…}
results1 = dr.execute(["baz"], inputs=setup | vars1, overrides=midpoint)

vars2 = {…}
results2 = dr.execute(["baz"], inputs=setup | vars2, overrides=midpoint)
Nice!
❤️ 1
e
This is a great point! Just checking might you want to be considering overrides instead of inputs?
g
I know so little, just getting acquainted. I'm unfamiliar with overrides. /me rushes off to the docs
(And no: I haven't read the caching section of the docs yet. 🙂)
e
Caching is another one to do that automatically — but what you pointed out is the exact initial design goal :)
Ok I’m having a hard time finding my be portion of the docs that goes over input patterns
It should be under driver but it’s probably in the reference section
g
Oh, but from testing I now see that what I wrote is actually wrong. It needs to be:
Copy code
# What I had written
results1 = dr.execute(["baz"], inputs=setup | midpoint | vars1)

# What is needed
results1 = dr.execute(["baz"], inputs=setup | vars1, overrides=midpoint)
Just passing the nodes as inputs does not prevent them from being recomputed.
I bet there's a good and valid reason for this, but the difference between inputs and overrides is unfortunate.
e
Yep that’s fair — i need to report back on the behavior here, whether overrides also counts as inputs
In which case you’d just use overrides
g
Mmm, checking.
Nope; supplying inputs via overrides causes them not to be discovered.
e
Yeah so I generally agree that that is unfortunate, had I done it again in the first place I would have made it so overrides superceded inputs
Yep looking at the code it's different, and agreed I would really like overrides to override inputs as well as nodes
Specifically to enable the pattern you're talking about
g
I'll put it on the back burner of "might be nice PRs" to look into unifying them. Thanks!
t
as far as I remember: `inputs`: • is a
node_name: value
mapping •
node_name
must not match a node name defined by a function name •
node_name
must match a node name defined by a function argument name `overrides`: • is a
node_name: value
mapping •
node_name
must match a node name defined by a function name • with the
value
known before execution, this prevents the function execution, "overriding it". It then changes the remaining DAG path to execute
s
We could make overrides supersede inputs I think; but the idea was that they're separate things IIRC.
> such that it provides really easy checkpoint-style processing. also this comment makes me very happy. This brings up a design decision people have to figure out -- what do you do inside Hamilton vs outside it 🙂 , e.g. Hamilton actually has some caching functionality that is more merkle tree like... or you could manage it yourself outside of Hamilton using overrides...