Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trace sync evaluators correctly with aevaluate #1541

Merged
merged 1 commit into from
Feb 27, 2025
Merged
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
11 changes: 8 additions & 3 deletions python/langsmith/evaluation/evaluator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""This module contains the evaluator classes for evaluating runs."""

Check notice on line 1 in python/langsmith/evaluation/evaluator.py

View workflow job for this annotation

GitHub Actions / benchmark

Benchmark results

........... create_5_000_run_trees: Mean +- std dev: 680 ms +- 67 ms ........... WARNING: the benchmark result may be unstable * the standard deviation (134 ms) is 10% of the mean (1.34 sec) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. create_10_000_run_trees: Mean +- std dev: 1.34 sec +- 0.13 sec ........... create_20_000_run_trees: Mean +- std dev: 2.62 sec +- 0.16 sec ........... dumps_class_nested_py_branch_and_leaf_200x400: Mean +- std dev: 705 us +- 11 us ........... dumps_class_nested_py_leaf_50x100: Mean +- std dev: 24.8 ms +- 0.2 ms ........... dumps_class_nested_py_leaf_100x200: Mean +- std dev: 104 ms +- 3 ms ........... dumps_dataclass_nested_50x100: Mean +- std dev: 25.2 ms +- 0.2 ms ........... WARNING: the benchmark result may be unstable * the standard deviation (7.63 ms) is 14% of the mean (55.9 ms) Try to rerun the benchmark with more runs, values and/or loops. Run 'python -m pyperf system tune' command to reduce the system jitter. Use pyperf stats, pyperf dump and pyperf hist to analyze results. Use --quiet option to hide these warnings. dumps_pydantic_nested_50x100: Mean +- std dev: 55.9 ms +- 7.6 ms ........... dumps_pydanticv1_nested_50x100: Mean +- std dev: 194 ms +- 3 ms

Check notice on line 1 in python/langsmith/evaluation/evaluator.py

View workflow job for this annotation

GitHub Actions / benchmark

Comparison against main

+-----------------------------------------------+----------+------------------------+ | Benchmark | main | changes | +===============================================+==========+========================+ | dumps_pydanticv1_nested_50x100 | 218 ms | 194 ms: 1.13x faster | +-----------------------------------------------+----------+------------------------+ | dumps_pydantic_nested_50x100 | 58.3 ms | 55.9 ms: 1.04x faster | +-----------------------------------------------+----------+------------------------+ | create_20_000_run_trees | 2.68 sec | 2.62 sec: 1.02x faster | +-----------------------------------------------+----------+------------------------+ | dumps_dataclass_nested_50x100 | 25.3 ms | 25.2 ms: 1.00x faster | +-----------------------------------------------+----------+------------------------+ | dumps_class_nested_py_leaf_50x100 | 24.9 ms | 24.8 ms: 1.00x faster | +-----------------------------------------------+----------+------------------------+ | create_5_000_run_trees | 681 ms | 680 ms: 1.00x faster | +-----------------------------------------------+----------+------------------------+ | dumps_class_nested_py_leaf_100x200 | 104 ms | 104 ms: 1.00x slower | +-----------------------------------------------+----------+------------------------+ | dumps_class_nested_py_branch_and_leaf_200x400 | 702 us | 705 us: 1.01x slower | +-----------------------------------------------+----------+------------------------+ | create_10_000_run_trees | 1.33 sec | 1.34 sec: 1.01x slower | +-----------------------------------------------+----------+------------------------+ | Geometric mean | (ref) | 1.02x faster | +-----------------------------------------------+----------+------------------------+

from __future__ import annotations

Expand All @@ -21,6 +21,7 @@

from typing_extensions import TypedDict

from langsmith import run_helpers as rh
from langsmith import schemas

try:
Expand Down Expand Up @@ -141,9 +142,13 @@
self, run: Run, example: Optional[Example] = None
) -> Union[EvaluationResult, EvaluationResults]:
"""Evaluate an example asynchronously."""
return await asyncio.get_running_loop().run_in_executor(
None, self.evaluate_run, run, example
)
current_context = rh.get_tracing_context()

def _run_with_context():
with rh.tracing_context(**current_context):
return self.evaluate_run(run, example)

return await asyncio.get_running_loop().run_in_executor(None, _run_with_context)


_RUNNABLE_OUTPUT = Union[EvaluationResult, EvaluationResults, dict]
Expand Down
Loading