Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion py/src/braintrust/btx/span_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,11 @@ def validate_spans(actual_spans: list[dict[str, Any]], spec: LlmSpanSpec) -> Non
for i, (actual_span, expected_span) in enumerate(zip(llm_spans, expected_spans)):
span_errors: list[str] = []
for key, exp_val in expected_span.items():
if key not in actual_span:
if key == "child_spans":
children = [s for s in actual_spans if actual_span.get("span_id") in (s.get("span_parents") or [])]
children.sort(key=lambda s: s.get("span_attributes", {}).get("exec_counter", 0))
_validate_value(children, exp_val, f"span[{i}].child_spans", span_errors)
elif key not in actual_span:
span_errors.append(f" span[{i}].{key}: key not found in actual span")
else:
_validate_value(actual_span[key], exp_val, f"span[{i}].{key}", span_errors)
Expand Down
2 changes: 1 addition & 1 deletion py/src/braintrust/btx/spec-ref.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.10
v0.0.13
2 changes: 1 addition & 1 deletion py/src/braintrust/btx/test_btx.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_btx_spec(

assert btx_project_id is not None

num_expected = len(spec.expected_brainstore_spans)
num_expected = sum(1 + len(span.get("child_spans", [])) for span in spec.expected_brainstore_spans)
print(f"\n[btx] Fetching {num_expected} span(s) for root_span_id={root_span_id!r} ...")
spans = fetch_spans(root_span_id, btx_project_id, num_expected)
print(f"[btx] Got {len(spans)} span(s), validating...")
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading