Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong committed Jan 27, 2025
1 parent b0fab8b commit 3f844d1
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions tests/trace/test_client_trace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3272,51 +3272,3 @@ def fib(n: int) -> int:
assert descendents[3].output == 0
assert descendents[4].inputs == {"n": 1}
assert descendents[4].output == 1


@pytest.mark.parametrize(
"descendents_code",
[
"list(call.get_descendents(nested=True))",
"client.get_call_descendents([call], nested=True)",
],
)
def test_get_call_descendents_nested(client, descendents_code):
@weave.op
def fib(n: int) -> int:
if n <= 1:
return n
return fib(n - 1) + fib(n - 2)

_, call = fib.call(3)
# calls will be:
# fib(3) (A)
# ├── fib(2) (B)
# │ ├── fib(1) (C)
# │ └── fib(0) (D)
# └── fib(1) (E)

descendents = eval(descendents_code)
# There's just 1 call, so outer envelope is a list with 1 item
assert len(descendents) == 1

assert len(descendents[0]) == 3 # Node A: (A, B, E)
assert len(descendents[0][1]) == 3 # Node B: (B, C, D)
assert len(descendents[0][1][1]) == 1 # Node C: (C)
assert len(descendents[0][1][2]) == 1 # Node D: (D)
assert len(descendents[0][2]) == 1 # Node E: (E)

assert descendents[0][0].inputs == {"n": 3} # Node A
assert descendents[0][0].output == 2

assert descendents[0][1][0].inputs == {"n": 2} # Node B
assert descendents[0][1][0].output == 1

assert descendents[0][1][1][0].inputs == {"n": 1} # Node C
assert descendents[0][1][1][0].output == 1

assert descendents[0][1][2][0].inputs == {"n": 0} # Node D
assert descendents[0][1][2][0].output == 0

assert descendents[0][2][0].inputs == {"n": 1} # Node E
assert descendents[0][2][0].output == 1

0 comments on commit 3f844d1

Please sign in to comment.