Skip to content

Commit 79f9be3

Browse files
authored
chore(langchain): make langchain runnable lambda test less flaky (#15512)
## Description One of the tests added in #15477 asserts a list of span links, but since we only care about content and not order, asserting the raw lists sometimes flaked if the list was out of order (which doesn't matter for span links). so instead, since we cannot hash them into a set because they're dicts, we assert one expected element at a time. ## Testing updating the test itself, will check on the health of it after it merges ## Risks none, passed still locally
1 parent c1f16bb commit 79f9be3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/contrib/langchain/test_langchain_llmobs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,8 @@ def test_llmobs_runnable_with_span_links(langchain_core, llmobs_events):
956956
llmobs_events.sort(key=lambda span: span["start_ns"])
957957

958958
# assert output -> output links for runnable sequence span from last two runnable lambdas
959-
assert llmobs_events[0]["span_links"] == [
959+
# the order of the links is not guaranteed
960+
expected_links = [
960961
{
961962
"trace_id": mock.ANY,
962963
"span_id": llmobs_events[2]["span_id"],
@@ -968,6 +969,9 @@ def test_llmobs_runnable_with_span_links(langchain_core, llmobs_events):
968969
"attributes": {"from": "output", "to": "output"},
969970
},
970971
]
972+
assert len(llmobs_events[0]["span_links"]) == len(expected_links)
973+
for expected_link in expected_links:
974+
assert expected_link in llmobs_events[0]["span_links"]
971975

972976
# assert input -> input links for add_1 span
973977
assert llmobs_events[1]["span_links"] == [

0 commit comments

Comments
 (0)