From 6f33ea2afadf820c8b89257087117c6996c53e62 Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:41:05 -0800 Subject: [PATCH] add py test --- python/tests/integration_tests/test_runs.py | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/python/tests/integration_tests/test_runs.py b/python/tests/integration_tests/test_runs.py index b23451c76..6e0999bd2 100644 --- a/python/tests/integration_tests/test_runs.py +++ b/python/tests/integration_tests/test_runs.py @@ -99,6 +99,35 @@ def my_chain_run(text: str): pass +async def test_list_runs_multi_project(langchain_client: Client): + project_names = [ + "__My Tracer Project - test_list_runs_multi_project", + "__My Tracer Project - test_list_runs_multi_project2", + ] + try: + for project_name in project_names: + if langchain_client.has_project(project_name): + langchain_client.delete_project(project_name=project_name) + + @traceable(run_type="chain") + async def my_run(text: str): + return "Completed: " + text + + for project_name in project_names: + await my_run("foo", langsmith_extra=dict(project_name=project_name)) + poll_runs_until_count(langchain_client, project_names[0], 1) + poll_runs_until_count(langchain_client, project_names[1], 1) + runs = list(langchain_client.list_runs(project_name=project_names)) + assert len(runs) == 2 + assert all([run.outputs["output"] == "Completed: foo" for run in runs]) + assert runs[0].session_id != runs[1].session_id + + finally: + for project_name in project_names: + if langchain_client.has_project(project_name): + langchain_client.delete_project(project_name=project_name) + + async def test_nested_async_runs(langchain_client: Client): """Test nested runs with a mix of async and sync functions.""" project_name = "__My Tracer Project - test_nested_async_runs"