From 3b38bcc2c7439b0e27d5677b000907657586bd4f Mon Sep 17 00:00:00 2001 From: William FH <13333726+hinthornw@users.noreply.github.com> Date: Thu, 1 Feb 2024 16:04:51 -0800 Subject: [PATCH] Update to use parallel testing (#395) --- js/src/tests/run_trees.int.test.ts | 2 +- python/Makefile | 2 +- python/langsmith/client.py | 2 ++ python/poetry.lock | 36 ++++++++++++++++++- python/pyproject.toml | 1 + python/tests/integration_tests/test_client.py | 1 - python/tests/integration_tests/test_runs.py | 1 - 7 files changed, 40 insertions(+), 5 deletions(-) diff --git a/js/src/tests/run_trees.int.test.ts b/js/src/tests/run_trees.int.test.ts index de99c70a0..357219c8c 100644 --- a/js/src/tests/run_trees.int.test.ts +++ b/js/src/tests/run_trees.int.test.ts @@ -9,7 +9,7 @@ async function toArray(iterable: AsyncIterable): Promise { return result; } -test("Test post and patch run", async () => { +test.concurrent("Test post and patch run", async () => { const projectName = `__test_run_tree`; const langchainClient = new Client({}); const projects = await toArray(langchainClient.listProjects()); diff --git a/python/Makefile b/python/Makefile index 2f6871f01..ad2609680 100644 --- a/python/Makefile +++ b/python/Makefile @@ -7,7 +7,7 @@ tests_watch: poetry run ptw --now . -- -vv -x tests/unit_tests integration_tests: - poetry run pytest tests/integration_tests + poetry run pytest -n auto tests/integration_tests lint: poetry run ruff . diff --git a/python/langsmith/client.py b/python/langsmith/client.py index 08face41b..4bb307920 100644 --- a/python/langsmith/client.py +++ b/python/langsmith/client.py @@ -812,6 +812,8 @@ def _run_transform( run_create["inputs"] = _hide_inputs(run_create["inputs"]) if "outputs" in run_create: run_create["outputs"] = _hide_outputs(run_create["outputs"]) + if not run_create.get("start_time"): + run_create["start_time"] = datetime.datetime.utcnow() return run_create @staticmethod diff --git a/python/poetry.lock b/python/poetry.lock index b4609c979..7bcd8bdfa 100644 --- a/python/poetry.lock +++ b/python/poetry.lock @@ -377,6 +377,20 @@ files = [ [package.extras] test = ["pytest (>=6)"] +[[package]] +name = "execnet" +version = "2.0.2" +description = "execnet: rapid multi-Python deployment" +optional = false +python-versions = ">=3.7" +files = [ + {file = "execnet-2.0.2-py3-none-any.whl", hash = "sha256:88256416ae766bc9e8895c76a87928c0012183da3cc4fc18016e6f050e025f41"}, + {file = "execnet-2.0.2.tar.gz", hash = "sha256:cc59bc4423742fd71ad227122eb0dd44db51efb3dc4095b45ac9a08c770096af"}, +] + +[package.extras] +testing = ["hatch", "pre-commit", "pytest", "tox"] + [[package]] name = "freezegun" version = "1.2.2" @@ -1110,6 +1124,26 @@ files = [ tomli = {version = ">=2.0.1,<3.0.0", markers = "python_version < \"3.11\""} watchdog = ">=2.0.0" +[[package]] +name = "pytest-xdist" +version = "3.5.0" +description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-xdist-3.5.0.tar.gz", hash = "sha256:cbb36f3d67e0c478baa57fa4edc8843887e0f6cfc42d677530a36d7472b32d8a"}, + {file = "pytest_xdist-3.5.0-py3-none-any.whl", hash = "sha256:d075629c7e00b611df89f490a5063944bee7a4362a5ff11c7cc7824a03dfce24"}, +] + +[package.dependencies] +execnet = ">=1.1" +pytest = ">=6.2.0" + +[package.extras] +psutil = ["psutil (>=3.0)"] +setproctitle = ["setproctitle"] +testing = ["filelock"] + [[package]] name = "python-dateutil" version = "2.8.2" @@ -1593,4 +1627,4 @@ multidict = ">=4.0" [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "67d509d96406a6d69827fa8956c89a1fc256277609fe6df21e94008ef5a01281" +content-hash = "f452b10f4c30cc0e4d78d5837ae0af3d044348dc76a9b0b2b52df66b0b8bb0a3" diff --git a/python/pyproject.toml b/python/pyproject.toml index ca913591e..5495e91a0 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -46,6 +46,7 @@ psutil = "^5.9.5" freezegun = "^1.2.2" pytest-subtests = "^0.11.0" pytest-watcher = "^0.3.4" +pytest-xdist = "^3.5.0" [tool.poetry.group.lint.dependencies] openai = "^1.10" diff --git a/python/tests/integration_tests/test_client.py b/python/tests/integration_tests/test_client.py index 2cbd6c5bb..86733f4b3 100644 --- a/python/tests/integration_tests/test_client.py +++ b/python/tests/integration_tests/test_client.py @@ -147,7 +147,6 @@ def test_persist_update_run( inputs={"text": "hello world"}, project_name=project_name, api_url=os.getenv("LANGCHAIN_ENDPOINT"), - execution_order=1, start_time=start_time, extra={"extra": "extra"}, revision_id=revision_id, diff --git a/python/tests/integration_tests/test_runs.py b/python/tests/integration_tests/test_runs.py index 06e1a7745..009b59160 100644 --- a/python/tests/integration_tests/test_runs.py +++ b/python/tests/integration_tests/test_runs.py @@ -132,7 +132,6 @@ async def my_chain_run(text: str): runs_dict = {run.name: run for run in runs} assert runs_dict["my_chain_run"].parent_run_id is None assert runs_dict["my_chain_run"].run_type == "chain" - assert runs_dict["my_chain_run"].execution_order == 1 assert runs_dict["my_run"].parent_run_id == runs_dict["my_chain_run"].id assert runs_dict["my_run"].run_type == "chain" assert runs_dict["my_llm_run"].parent_run_id == runs_dict["my_run"].id