Skip to content

BUG: pruning when output given unjustly drops ancestors #24

Description

@ankostis

The following graph with given-1 & given-2 inputs fails to compute with KeyError: 'a' when the asked output is asked, but it does so when not asked!

Code to reproduce:

def test_pruning_with_given_intermediate_and_asked_out():
    # Test that operations with partial inputs are pruned and not failing.
    graph = compose(name="graph")(
        operation(name="unjustly pruned", needs=["given-1"], provides=["a"])(lambda a: a),
        operat`ion(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, "b": 2, "given-2": 2}) == {"given-1": 5, "b": 2, "given-2": 7, "a": 5, "b": 2, "asked": 12}  # that ok # FAILS!
    assert graph({"given-1": 5, "b": 2, "given-2": 2}, ["asked"]) == {"asked": 12}  # FAILS!

Root cause:

  • The culling logic in v1.2.4 when specific outputs are asked is to drop indiscriminately all predecessors of the given inputs, which might include values that needs to be computed.
  • The existing "pruning" TCs were too simple to catch this..

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions