Skip to content

Commit ad979dd

Browse files
authored
Merge branch 'main' into DABH-patch-1
2 parents 3768dde + 24035cc commit ad979dd

5 files changed

Lines changed: 48 additions & 19 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [{ name = "Temporal Technologies Inc", email = "sdk@temporal.io" }]
66
requires-python = ">=3.10"
77
readme = "README.md"
88
license = "MIT"
9-
dependencies = ["temporalio>=1.27.0,<2"]
9+
dependencies = ["temporalio>=1.27.2,<2"]
1010

1111
[project.urls]
1212
Homepage = "https://github.com/temporalio/samples-python"
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Shared fixtures for LangSmith tracing tests."""
2+
3+
from unittest.mock import MagicMock
4+
5+
import pytest
6+
7+
8+
@pytest.fixture
9+
def mock_ls_client() -> MagicMock:
10+
"""Return a mock ``langsmith.Client`` that never makes network calls.
11+
12+
The samples tests don't assert on trace output — the LangSmith plugin
13+
just needs *some* client object to wire into the worker. ``MagicMock``
14+
auto-stubs every method the interceptor calls; the explicit ``session``
15+
and ``tracing_queue`` stubs match what the langsmith library touches
16+
internally.
17+
"""
18+
client = MagicMock()
19+
client.session = MagicMock()
20+
client.tracing_queue = MagicMock()
21+
return client

tests/langsmith_tracing/test_basic.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import uuid
2+
from unittest.mock import MagicMock
23

34
from temporalio import activity
45
from temporalio.client import Client
@@ -10,7 +11,9 @@
1011
from langsmith_tracing.basic.workflows import BasicLLMWorkflow
1112

1213

13-
async def test_basic_workflow(client: Client, env: WorkflowEnvironment):
14+
async def test_basic_workflow(
15+
client: Client, env: WorkflowEnvironment, mock_ls_client: MagicMock
16+
):
1417
expected_text = "Temporal is a durable execution platform."
1518

1619
@activity.defn(name="call_openai")
@@ -22,7 +25,7 @@ async def mock_call_openai(request: OpenAIRequest) -> str:
2225
task_queue="test-langsmith-basic",
2326
workflows=[BasicLLMWorkflow],
2427
activities=[mock_call_openai],
25-
plugins=[LangSmithPlugin()],
28+
plugins=[LangSmithPlugin(client=mock_ls_client)],
2629
):
2730
result = await client.execute_workflow(
2831
BasicLLMWorkflow.run,

tests/langsmith_tracing/test_chatbot.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import uuid
3+
from unittest.mock import MagicMock
34

45
from temporalio import activity
56
from temporalio.client import Client
@@ -27,7 +28,9 @@ def _make_function_call_response(
2728
)
2829

2930

30-
async def test_chatbot_save_note(client: Client, env: WorkflowEnvironment):
31+
async def test_chatbot_save_note(
32+
client: Client, env: WorkflowEnvironment, mock_ls_client: MagicMock
33+
):
3134
"""Test save_note tool call loop — save_note runs as a workflow method."""
3235
call_count = 0
3336

@@ -47,7 +50,7 @@ async def mock_call_openai(request: OpenAIRequest) -> ChatResponse:
4750
task_queue="test-langsmith-chatbot",
4851
workflows=[ChatbotWorkflow],
4952
activities=[mock_call_openai],
50-
plugins=[LangSmithPlugin()],
53+
plugins=[LangSmithPlugin(client=mock_ls_client)],
5154
):
5255
wf_handle = await client.start_workflow(
5356
ChatbotWorkflow.run,
@@ -68,8 +71,10 @@ async def mock_call_openai(request: OpenAIRequest) -> ChatResponse:
6871
assert result == "Session ended."
6972

7073

71-
async def test_chatbot_read_note(client: Client, env: WorkflowEnvironment):
72-
"""Test read_note tool call loop — read_note runs as a workflow method."""
74+
async def test_chatbot_read_note(
75+
client: Client, env: WorkflowEnvironment, mock_ls_client: MagicMock
76+
):
77+
"""Test read_note tool call loop — saves a note first, then reads it back."""
7378
call_count = 0
7479

7580
@activity.defn(name="call_openai")
@@ -97,7 +102,7 @@ async def mock_call_openai(request: OpenAIRequest) -> ChatResponse:
97102
task_queue="test-langsmith-chatbot-read",
98103
workflows=[ChatbotWorkflow],
99104
activities=[mock_call_openai],
100-
plugins=[LangSmithPlugin()],
105+
plugins=[LangSmithPlugin(client=mock_ls_client)],
101106
):
102107
wf_handle = await client.start_workflow(
103108
ChatbotWorkflow.run,

uv.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)