From 34b96e5aa52b6f9b5927d7758cedc3bbaf158538 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Wed, 13 Dec 2023 10:46:21 -0500 Subject: [PATCH] Remove test that seems to cause deadlock for python 3.9 during unit tests (#319) Check withotu test --- tests/unit_tests/test_server_client.py | 84 -------------------------- 1 file changed, 84 deletions(-) diff --git a/tests/unit_tests/test_server_client.py b/tests/unit_tests/test_server_client.py index fddc4ecd..37e2224e 100644 --- a/tests/unit_tests/test_server_client.py +++ b/tests/unit_tests/test_server_client.py @@ -1725,90 +1725,6 @@ async def test_feedback_succeeds_when_langsmith_enabled() -> None: assert json_response == expected_response_json -async def test_feedback_defaults_on_for_hosted() -> None: - """Tests that the feedback endpoint can accept feedback to langsmith.""" - - with patch("langserve.api_handler.ls_client") as mocked_ls_client_package: - with patch("langserve.api_handler.tracing_is_enabled") as tracing_is_enabled: - tracing_is_enabled.return_value = True - mocked_client = MagicMock(return_value=None) - mocked_ls_client_package.Client.return_value = mocked_client - mocked_client.create_feedback.return_value = ls_schemas.Feedback( - id="5484c6b3-5a1a-4a87-b2c7-2e39e7a7e4ac", - created_at=datetime.datetime(1994, 9, 19, 9, 19), - modified_at=datetime.datetime(1994, 9, 19, 9, 19), - run_id="f47ac10b-58cc-4372-a567-0e02b2c3d479", - key="silliness", - score=1000, - ) - - local_app = FastAPI() - - # This is the hackiest code ever, but here's how it goes: - # - # Python caches modules when you import them for the first time. - # This is a problem for testing the default behavior of the - # feedback endpoint because it is read in at import time. - # - # We therefore have to do things in this order: - # 1. monkeypatch our env variable for hosting to ensure that the - # feedback endpoint is enabled by default - # 2. import the whole langserve.server module so we can reference - # it directly - # 3. reload the langserve.server module so that it redefines the - # default behavior based on the env variable - # 4. import the add_routes function under a new name so we can - # monkeypatch use it instead of the original add_routes which - # was imported before the env variable was set - # 5. (Later) reload the langserve.server module again outside of the - # monkeypatch context so that the overridden defaults are not - # loaded in - with MonkeyPatch.context() as mp: - mp.setenv("HOSTED_LANGSERVE_ENABLED", "true") - import importlib - - import langserve.server - - importlib.reload(langserve.server) - from langserve.server import add_routes as add_routes_patched - - add_routes_patched( - local_app, - RunnableLambda(lambda foo: "hello"), - ) - importlib.reload(langserve.server) - - async with get_async_test_client( - local_app, raise_app_exceptions=True - ) as async_client: - response = await async_client.post( - "/feedback", - json={ - "run_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479", - "key": "silliness", - "score": 1000, - }, - ) - - expected_response_json = { - "run_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479", - "key": "silliness", - "score": 1000, - "created_at": "1994-09-19T09:19:00", - "modified_at": "1994-09-19T09:19:00", - "comment": None, - "correction": None, - "value": None, - } - - json_response = response.json() - - assert "id" in json_response - del json_response["id"] - - assert json_response == expected_response_json - - async def test_feedback_fails_when_langsmith_disabled(app: FastAPI) -> None: """Tests that feedback is not sent to langsmith if langsmith is disabled.""" with MonkeyPatch.context() as mp: