From 75465a2a3cc7643a3d3031d9854cc0d7a21fa083 Mon Sep 17 00:00:00 2001 From: Christophe Bornet Date: Fri, 16 Feb 2024 17:48:30 +0100 Subject: [PATCH] partners/astradb: Add dotenv to langchain-astradb integration tests (#17629) --- libs/partners/astradb/poetry.lock | 40 ++++++++++++++++--- libs/partners/astradb/pyproject.toml | 1 + .../tests/integration_tests/.env.example | 5 +++ .../tests/integration_tests/conftest.py | 19 +++++++++ 4 files changed, 59 insertions(+), 6 deletions(-) create mode 100644 libs/partners/astradb/tests/integration_tests/.env.example create mode 100644 libs/partners/astradb/tests/integration_tests/conftest.py diff --git a/libs/partners/astradb/poetry.lock b/libs/partners/astradb/poetry.lock index c63683ec99..41c52a6e98 100644 --- a/libs/partners/astradb/poetry.lock +++ b/libs/partners/astradb/poetry.lock @@ -483,7 +483,7 @@ develop = true [package.dependencies] anyio = ">=3,<5" jsonpatch = "^1.33" -langsmith = "^0.0.87" +langsmith = "^0.1.0" packaging = "^23.2" pydantic = ">=1,<3" PyYAML = ">=5.3" @@ -499,13 +499,13 @@ url = "../../core" [[package]] name = "langsmith" -version = "0.0.87" +version = "0.1.1" description = "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform." optional = false python-versions = ">=3.8.1,<4.0" files = [ - {file = "langsmith-0.0.87-py3-none-any.whl", hash = "sha256:8903d3811b9fc89eb18f5961c8e6935fbd2d0f119884fbf30dc70b8f8f4121fc"}, - {file = "langsmith-0.0.87.tar.gz", hash = "sha256:36c4cc47e5b54be57d038036a30fb19ce6e4c73048cd7a464b8f25b459694d34"}, + {file = "langsmith-0.1.1-py3-none-any.whl", hash = "sha256:10ff2b977a41e3f6351d1a4239d9bd57af0547aa909e839d2791e16cc197a6f9"}, + {file = "langsmith-0.1.1.tar.gz", hash = "sha256:09df0c2ca9085105f97a4e4f281b083e312c99d162f3fe2b2d5eefd5c3692e60"}, ] [package.dependencies] @@ -786,6 +786,21 @@ pytest = ">=7.0.0" docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] testing = ["coverage (>=6.2)", "flaky (>=3.5.0)", "hypothesis (>=5.7.1)", "mypy (>=0.931)", "pytest-trio (>=0.7.0)"] +[[package]] +name = "pytest-dotenv" +version = "0.5.2" +description = "A py.test plugin that parses environment files before running tests" +optional = false +python-versions = "*" +files = [ + {file = "pytest-dotenv-0.5.2.tar.gz", hash = "sha256:2dc6c3ac6d8764c71c6d2804e902d0ff810fa19692e95fe138aefc9b1aa73732"}, + {file = "pytest_dotenv-0.5.2-py3-none-any.whl", hash = "sha256:40a2cece120a213898afaa5407673f6bd924b1fa7eafce6bda0e8abffe2f710f"}, +] + +[package.dependencies] +pytest = ">=5.0.0" +python-dotenv = ">=0.9.1" + [[package]] name = "pytest-mock" version = "3.12.0" @@ -832,6 +847,20 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "python-dotenv" +version = "1.0.1" +description = "Read key-value pairs from a .env file and set them as environment variables" +optional = false +python-versions = ">=3.8" +files = [ + {file = "python-dotenv-1.0.1.tar.gz", hash = "sha256:e324ee90a023d808f1959c46bcbc04446a10ced277783dc6ee09987c37ec10ca"}, + {file = "python_dotenv-1.0.1-py3-none-any.whl", hash = "sha256:f7b63ef50f1b690dddf550d03497b66d609393b40b564ed0d674909a68ebf16a"}, +] + +[package.extras] +cli = ["click (>=5.0)"] + [[package]] name = "pyyaml" version = "6.0.1" @@ -857,7 +886,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -1083,4 +1111,4 @@ watchmedo = ["PyYAML (>=3.10)"] [metadata] lock-version = "2.0" python-versions = ">=3.8.1,<4.0" -content-hash = "a54c88fffa5aca9fe1961b2c584f1c9dd3870870019c8443803c1574367fed91" +content-hash = "fe6988cc6483f13341578e46b85a42fe242c21c5fdbe4f1f64384369b916b186" diff --git a/libs/partners/astradb/pyproject.toml b/libs/partners/astradb/pyproject.toml index 3850cd5fbd..3ba131e0a5 100644 --- a/libs/partners/astradb/pyproject.toml +++ b/libs/partners/astradb/pyproject.toml @@ -16,6 +16,7 @@ optional = true [tool.poetry.group.test.dependencies] pytest = "^7.3.0" +pytest-dotenv = "^0.5.2" freezegun = "^1.2.2" pytest-mock = "^3.10.0" syrupy = "^4.0.2" diff --git a/libs/partners/astradb/tests/integration_tests/.env.example b/libs/partners/astradb/tests/integration_tests/.env.example new file mode 100644 index 0000000000..4259d87682 --- /dev/null +++ b/libs/partners/astradb/tests/integration_tests/.env.example @@ -0,0 +1,5 @@ +# astra db +ASTRA_DB_API_ENDPOINT=https://your_astra_db_id-your_region.apps.astra.datastax.com +ASTRA_DB_APPLICATION_TOKEN=AstraCS:your_astra_db_application_token +# ASTRA_DB_KEYSPACE=your_astra_db_namespace +# ASTRA_DB_SKIP_COLLECTION_DELETIONS=true diff --git a/libs/partners/astradb/tests/integration_tests/conftest.py b/libs/partners/astradb/tests/integration_tests/conftest.py new file mode 100644 index 0000000000..02b518e869 --- /dev/null +++ b/libs/partners/astradb/tests/integration_tests/conftest.py @@ -0,0 +1,19 @@ +# Getting the absolute path of the current file's directory +import os + +ABS_PATH = os.path.dirname(os.path.abspath(__file__)) + +# Getting the absolute path of the project's root directory +PROJECT_DIR = os.path.abspath(os.path.join(ABS_PATH, os.pardir, os.pardir)) + + +# Loading the .env file if it exists +def _load_env() -> None: + dotenv_path = os.path.join(PROJECT_DIR, "tests", "integration_tests", ".env") + if os.path.exists(dotenv_path): + from dotenv import load_dotenv + + load_dotenv(dotenv_path) + + +_load_env()