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 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes the way drivers handle parameters
See #52 Note: this is backwards compatible. The changes are that we've added the "inputs" parameter to the driver, as well as the function_graph executor. This allows external inputs to the DAG at runtime, not just construction time.
- Loading branch information
1 parent
c6cfeae
commit 5041770
Showing
5 changed files
with
89 additions
and
90 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 was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def b(a: int) -> int: | ||
return a |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,35 @@ | ||
from hamilton.driver import Driver | ||
import tests.resources.very_simple_dag | ||
|
||
|
||
def test_driver_validate_input_types(): | ||
dr = Driver({'a': 1}, []) | ||
dr = Driver({'a': 1}) | ||
results = dr.raw_execute(['a']) | ||
assert results == {'a': 1} | ||
|
||
|
||
def test_driver_validate_runtime_input_types(): | ||
dr = Driver({}, tests.resources.very_simple_dag) | ||
results = dr.raw_execute(['b'], inputs={'a': 1}) | ||
assert results == {'b': 1} | ||
|
||
|
||
def test_combine_inputs_no_collision(): | ||
"""Tests the combine_and_validate_inputs functionality when there are no collisions""" | ||
combined, error = Driver.combine_and_validate_inputs({'a': 1}, {'b': 2}) | ||
assert combined == {'a': 1, 'b': 2} | ||
assert error is None | ||
|
||
|
||
def test_combine_inputs_collision(): | ||
"""Tests the combine_and_validate_inputs functionality | ||
when there are collisions of keys but not values""" | ||
combined, error = Driver.combine_and_validate_inputs({'a': 1}, {'a': 2}) | ||
assert error is not None | ||
|
||
|
||
def test_combine_inputs_collision_2(): | ||
combined, error = Driver.combine_and_validate_inputs({'a': 1}, {'a': 1}) | ||
"""Tests the combine_and_validate_inputs functionality | ||
when there are collisions of keys but not values""" | ||
assert error is not None |