Skip to content

Commit

Permalink
python: log experiment with html
Browse files Browse the repository at this point in the history
  • Loading branch information
baskaryan committed Nov 8, 2024
1 parent a8cab88 commit 7d00697
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions python/langsmith/evaluation/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import concurrent.futures as cf
import datetime
import functools
import importlib
import inspect
import itertools
import logging
import pathlib
import queue
import random
import sys
import textwrap
import threading
import uuid
Expand Down Expand Up @@ -94,6 +96,9 @@
],
]

_IS_INTERACTIVE_ENV = hasattr(sys, "ps2")
_IPYTHON_INSTALLED = importlib.util.find_spec("IPython")


def evaluate(
target: TARGET_T,
Expand Down Expand Up @@ -1113,15 +1118,25 @@ def _print_experiment_start(
f"{base_url}/datasets/{dataset_id}/compare?"
f"selectedSessions={project.id}"
)
print( # noqa: T201
f"View the evaluation results for experiment: '{self.experiment_name}'"
f" at:\n{comparison_url}\n\n"
)
else:
# HACKHACK
comparison_url = None

if _IS_INTERACTIVE_ENV and _IPYTHON_INSTALLED and comparison_url:
from IPython.display import HTML, display # type: ignore[import-not-found]

display(
HTML(
f"RUNNING EXPERIMENT: <a href='{comparison_url}'>"
f"{self.experiment_name}</a>"
)
)
elif comparison_url:
print( # noqa: T201
"Starting evaluation of experiment: %s", self.experiment_name
f"RUNNING EXPERIMENT: {self.experiment_name}\nEXPERIMENT URL: "
f"{comparison_url}"
)
else:
print(f"RUNNING EXPERIMENT: {self.experiment_name}") # noqa: T201


class _ExperimentManager(_ExperimentManagerMixin):
Expand Down

0 comments on commit 7d00697

Please sign in to comment.