Skip to content

Commit

Permalink
rc14
Browse files Browse the repository at this point in the history
  • Loading branch information
baskaryan committed Jan 20, 2025
1 parent e7675c1 commit 2bc8ad5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
4 changes: 3 additions & 1 deletion python/docs/create_api_rst.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ def _load_module_members(module_path: str, namespace: str) -> ModuleMembers:
else (
"enum"
if issubclass(type_, Enum)
else "Pydantic" if issubclass(type_, BaseModel) else "Regular"
else "Pydantic"
if issubclass(type_, BaseModel)
else "Regular"
)
)
classes_.append(
Expand Down
29 changes: 25 additions & 4 deletions python/langsmith/pytest_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def pytest_addoption(parser):
)


def pytest_cmdline_preparse(config, args):
"""Call immediately after command line options are parsed."""
def _handle_output_args(args):
"""Common logic for handling output arguments."""
if any(opt in args for opt in ["--output=langsmith", "--output=ls"]):
# Only add --quiet if it's not already there
if not any(a in args for a in ["-q", "--quiet"]):
Expand All @@ -40,6 +40,18 @@ def pytest_cmdline_preparse(config, args):
args.insert(0, "-s")


if pytest.__version__.startswith("7."):

def pytest_cmdline_preparse(config, args):
"""Call immediately after command line options are parsed (pytest v7)."""
_handle_output_args(args)
else:

def pytest_load_initial_conftests(args):
"""Handle args in pytest v8+."""
_handle_output_args(args)


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_call(item):
"""Apply LangSmith tracking to tests marked with @pytest.mark.langsmith."""
Expand All @@ -54,7 +66,13 @@ def pytest_runtest_call(item):
request_obj = getattr(item, "_request", None)
if request_obj is not None and "request" not in item.funcargs:
item.funcargs["request"] = request_obj
item._fixtureinfo.argnames += ("request",)
# Create a new FuncFixtureInfo instance with updated argnames
item._fixtureinfo = type(item._fixtureinfo)(
argnames=item._fixtureinfo.argnames + ("request",),
initialnames=item._fixtureinfo.initialnames,
names_closure=item._fixtureinfo.names_closure,
name2fixturedefs=item._fixtureinfo.name2fixturedefs,
)
yield


Expand Down Expand Up @@ -213,6 +231,7 @@ def _generate_table(self, suite_name: str):
self.console.width
- (max_status + max_feedback + max_duration + len("Logged"))
) // 4
max_dynamic_col_width = max(max_dynamic_col_width, 8)

for pid, status in suite_statuses.items():
status_color = {
Expand All @@ -233,7 +252,9 @@ def _generate_table(self, suite_name: str):
_abbreviate_test_name(str(pid), max_len=max_dynamic_col_width),
_abbreviate(inputs, max_len=max_dynamic_col_width),
_abbreviate(reference_outputs, max_len=max_dynamic_col_width),
_abbreviate(outputs, max_len=max_dynamic_col_width),
_abbreviate(outputs, max_len=max_dynamic_col_width)[
-max_dynamic_col_width:
],
f"[{status_color}]{status.get('status', 'queued')}[/{status_color}]",
feedback,
f"{duration:.2f}s",
Expand Down
2 changes: 1 addition & 1 deletion python/langsmith/testing/_internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ def _create_feedback(self, run_id: ID_TYPE, feedback: dict, **kwargs: Any) -> No
self.client.create_feedback(trace_id, **feedback, **kwargs)

def shutdown(self):
self._executor.shutdown(wait=True)
self._executor.shutdown()

def wait_example_updates(self, example_id: ID_TYPE):
"""Wait for all example updates to complete."""
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langsmith"
version = "0.2.11rc13"
version = "0.2.11rc14"
description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform."
authors = ["LangChain <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 2bc8ad5

Please sign in to comment.