This repository has been archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes case where optional user inputs broke computation
The execute function gets all upstream nodes of the required node to compute. This will mean that there will likely be "user input" nodes to cycle through. When we were computing the DFS value for them, we would assume they were required. To illustrate, if you had a function that had optional input, `baz` e.g. ```python def foo(bar: int, baz: float = 1.0) -> float: ``` This meant that if you did not pass in a value for `baz`, and `baz` was a user input, Hamilton would complain that a required node was not provided. Even though it was not required for computation. So to fix that, in execute any user node is now marked with `optional`. I believe this is fine to do, because if this is not the case, there will be a node in the graph that will have `baz` as a REQUIRED dependency, and thus things will break appropriately. To help with that, I also fixed and added some unit tests. One unit test is to ensure that we don't remove passing in `None` values as part of the kwargs to the function. Since that's what we do now, and this was another way to fix this bug, which I think would be the wrong way to go about it. Otherwise I added tests to ensure that node order does not change the result too.
- Loading branch information
Showing
3 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters