Skip to content

Commit

Permalink
test(dag,yahoo#25): FAILing TC for overriding intermediate data
Browse files Browse the repository at this point in the history
  • Loading branch information
ankostis committed Oct 2, 2019
1 parent f58d148 commit fe76b31
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/test_graphkit.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,32 @@ def test_pruning_raises_for_bad_output():
outputs=['sum1', 'sum3', 'sum4'])


def test_unjust_culling_with_given_intermediate_and_asked_out():
# Test that operations with partial inputs are culled and not failing.
graph = compose(name="graph")(
operation(name="unjustly culled", needs=["given-1"], provides=["a"])(lambda a: a),
operation(name="shortcuted", needs=["a", "b"], provides=["given-2"])(add),
operation(name="good_op", needs=["a", "given-2"], provides=["asked"])(add),
)

# assert graph({'given-1': 5, 'a': 1, "b": 2}) == {'given-1': 5, 'a': 5, "b": 2, 'asked': -1} # that ok
# assert graph({'given-1': 5, "b": 2}) == {'given-1': 5, 'a': 5, "b": 2, 'asked': 7} # that ok
# assert graph({'a': 1, "b": 2}) == {'a': 1, "b": 2, 'cc': -1} # that ok
assert graph({'given-1': 1, "given-2": 2}, ['asked']) == {'asked': -1} # FAILS!
assert graph({'given-1': 1, "given-2": 2}, ['asked']) == {'asked': -1} # FAILS!


def test_pruning_not_overrides_given_intermediate():
# Test #25: not overriding intermediate data when an output is not asked
graph = compose(name="graph")(
operation(name="unjustly run", needs=["a"], provides=["overriden"])(lambda a: a),
operation(name="op", needs=["overriden", "c"], provides=["asked"])(add),
)
graph.net.plot('t.png')
assert graph({'a': 5, 'overriden': 1, "c": 2}, ['asked']) == {'asked': 3} # that's ok
assert graph({'a': 5, 'overriden': 1, "c": 2}) == {'a': 5, 'overriden': 1, "c": 2, 'asked': 3} # FAILs


def test_optional():
# Test that optional() needs work as expected.

Expand Down

0 comments on commit fe76b31

Please sign in to comment.