From 94f69eae6b6fd9691383783ba725faa86501a29d Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Wed, 18 Sep 2024 15:22:02 -0700 Subject: [PATCH 1/5] chore(ci): fix kokoro release secret (#217) --- .kokoro/release.sh | 2 +- .kokoro/release/common.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.kokoro/release.sh b/.kokoro/release.sh index b38a2bd9..bf07994c 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -23,7 +23,7 @@ python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source / export PYTHONUNBUFFERED=1 # Move into the package, build the distribution and upload. -TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1") +TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-2") cd github/langchain-google-cloud-sql-pg-python python3 -m build --wheel twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 164fa4cd..623c99af 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -28,7 +28,7 @@ before_action { fetch_keystore { keystore_resource { keystore_config_id: 73713 - keyname: "google-cloud-pypi-token-keystore-1" + keyname: "google-cloud-pypi-token-keystore-2" } } } From 1737adc696e725488af860d031a22f6e6b66171b Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Thu, 19 Sep 2024 11:27:22 -0700 Subject: [PATCH 2/5] feat: remove support for Python 3.8 (#216) --- .github/sync-repo-settings.yaml | 1 - DEVELOPER.md | 12 ++++++------ README.rst | 2 +- integration.cloudbuild.yaml | 2 +- pyproject.toml | 7 +++---- requirements.txt | 5 ++--- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 4494dee6..a1539006 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -27,7 +27,6 @@ branchProtectionRules: requiredStatusCheckContexts: - "cla/google" - "lint" - - "pg-integration-test-pr-py38 (langchain-cloud-sql-testing)" - "pg-integration-test-pr-py39 (langchain-cloud-sql-testing)" - "pg-integration-test-pr-py310 (langchain-cloud-sql-testing)" - "pg-integration-test-pr-py311 (langchain-cloud-sql-testing)" diff --git a/DEVELOPER.md b/DEVELOPER.md index a2089553..899f62b6 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -28,7 +28,7 @@ Learn more by reading [How should I write my commits?](https://github.com/google Notes: -* Tests use both IAM and built-in authentication. +* Tests use both IAM and built-in authentication. * Learn how to set up a built-in databases user at [Cloud SQL built-in database authentication](https://cloud.google.com/sql/docs/postgres/built-in-authentication). * Local tests will run against your `gcloud` credentials. Use `gcloud` to login with your personal account or a service account. This account will be used to run IAM tests. Learn how to set up access to the database at [Manage users with IAM database authentication](https://cloud.google.com/sql/docs/postgres/add-manage-iam-users). The "IAM_ACCOUNT" environment variable is also used to test authentication to override the local account. A personal account or a service account can be used for this test. * You may need to grant access to the public schema for your new database user: `GRANT ALL ON SCHEMA public TO myaccount@example.com;` @@ -42,11 +42,11 @@ These tests are registered as required tests in `.github/sync-repo-settings.yaml #### Trigger Setup -Cloud Build triggers (for Python versions 3.8 to 3.11) were created with the following specs: +Cloud Build triggers (for Python versions 3.9 to 3.11) were created with the following specs: ```YAML -name: pg-integration-test-pr-py38 -description: Run integration tests on PR for Python 3.8 +name: pg-integration-test-pr-py39 +description: Run integration tests on PR for Python 3.9 filename: integration.cloudbuild.yaml github: name: langchain-google-cloud-sql-pg-python @@ -64,7 +64,7 @@ substitutions: _DATABASE_ID: _INSTANCE_ID: _REGION: us-central1 - _VERSION: "3.8" + _VERSION: "3.9" ``` Use `gcloud builds triggers import --source=trigger.yaml` to create triggers via the command line @@ -89,7 +89,7 @@ To run Cloud Build tests on GitHub from external contributors, ie RenovateBot, c #### Code Coverage Please make sure your code is fully tested. The Cloud Build integration tests are run with the `pytest-cov` code coverage plugin. They fail for PRs with a code coverage less than the threshold specified in `.coveragerc`. If your file is inside the main module and should be ignored by code coverage check, add it to the `omit` section of `.coveragerc`. -Check for code coverage report in any Cloud Build integration test log. +Check for code coverage report in any Cloud Build integration test log. Here is a breakdown of the report: - `Stmts`: lines of executable code (statements). - `Miss`: number of lines not covered by tests. diff --git a/README.rst b/README.rst index 17a6e652..dc45371c 100644 --- a/README.rst +++ b/README.rst @@ -48,7 +48,7 @@ dependencies. Supported Python Versions ^^^^^^^^^^^^^^^^^^^^^^^^^ -Python >= 3.8 +Python >= 3.9 Mac/Linux ^^^^^^^^^ diff --git a/integration.cloudbuild.yaml b/integration.cloudbuild.yaml index e685c3bb..18414b8e 100644 --- a/integration.cloudbuild.yaml +++ b/integration.cloudbuild.yaml @@ -62,7 +62,7 @@ substitutions: _DATABASE_PORT: "5432" _DATABASE_ID: test-database _REGION: us-central1 - _VERSION: "3.8" + _VERSION: "3.9" _IP_ADDRESS: "127.0.0.1" options: diff --git a/pyproject.toml b/pyproject.toml index 83a3bc23..53ad7861 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ dynamic = ["version"] description = "LangChain integrations for Google Cloud SQL for PostgreSQL" readme = "README.rst" license = {file = "LICENSE"} -requires-python = ">=3.8" +requires-python = ">=3.9" authors = [ {name = "Google LLC", email = "googleapis-packages@google.com"} ] @@ -22,7 +22,6 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", @@ -53,13 +52,13 @@ requires = ["setuptools"] build-backend = "setuptools.build_meta" [tool.black] -target-version = ['py38'] +target-version = ['py39'] [tool.isort] profile = "black" [tool.mypy] -python_version = 3.8 +python_version = 3.9 warn_unused_configs = true disallow_incomplete_defs = true diff --git a/requirements.txt b/requirements.txt index ec4b6dd2..34ed4380 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,5 @@ cloud-sql-python-connector[asyncpg]==1.12.0 -langchain-core==0.2.38 -numpy==1.24.4; python_version<='3.8' -numpy==1.26.4; python_version>'3.8' +langchain-core==0.3.0 +numpy==1.26.4 pgvector==0.3.2 SQLAlchemy[asyncio]==2.0.34 From 8059390b2350a4a42161041c63121d9b60823d91 Mon Sep 17 00:00:00 2001 From: Averi Kitsch Date: Fri, 4 Oct 2024 10:33:57 -0700 Subject: [PATCH 3/5] chore(samples): update samples for async/sync refactor (#221) * chore(samples): update samples for async/sync refactor * clean * fix * clean --- .../create_vector_embeddings.py | 2 ++ samples/index_tuning_sample/index_search.py | 7 ++++++- samples/langchain_on_vertexai/clean_up.py | 9 +++++--- .../create_embeddings.py | 21 ++++++++++++------- .../langchain_on_vertexai/requirements.txt | 4 ++-- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/samples/index_tuning_sample/create_vector_embeddings.py b/samples/index_tuning_sample/create_vector_embeddings.py index 8e962fb4..a49f4ad6 100644 --- a/samples/index_tuning_sample/create_vector_embeddings.py +++ b/samples/index_tuning_sample/create_vector_embeddings.py @@ -106,6 +106,8 @@ async def create_vector_store_table(documents): ids = [str(uuid.uuid4()) for i in range(len(documents))] await vector_store.aadd_documents(documents, ids) print("Vector table created.") + await engine.close() + await engine._connector.close() async def main(): diff --git a/samples/index_tuning_sample/index_search.py b/samples/index_tuning_sample/index_search.py index 9b680ebd..593aa307 100644 --- a/samples/index_tuning_sample/index_search.py +++ b/samples/index_tuning_sample/index_search.py @@ -81,7 +81,10 @@ async def query_vector_with_timing(vector_store, query): async def hnsw_search(vector_store, knn_docs): hnsw_index = HNSWIndex( - name="hnsw", distance_strategy=DISTANCE_STRATEGY, m=36, ef_construction=96 + name="hnsw", + distance_strategy=DISTANCE_STRATEGY, + m=36, + ef_construction=96, ) await vector_store.aapply_vector_index(hnsw_index) assert await vector_store.is_valid_index(hnsw_index.name) @@ -156,6 +159,8 @@ async def main(): print( f"IVFFLAT average recall: {ivfflat_average_recall} IVFFLAT latency: {ivfflat_average_latency}" ) + await vector_store._engine.close() + await vector_store._engine._connector.close() if __name__ == "__main__": diff --git a/samples/langchain_on_vertexai/clean_up.py b/samples/langchain_on_vertexai/clean_up.py index 99b2e7bc..45e57ae5 100644 --- a/samples/langchain_on_vertexai/clean_up.py +++ b/samples/langchain_on_vertexai/clean_up.py @@ -24,6 +24,7 @@ TABLE_NAME, USER, ) +from sqlalchemy import text from vertexai.preview import reasoning_engines # type: ignore from langchain_google_cloud_sql_pg import PostgresEngine @@ -41,10 +42,12 @@ async def delete_tables(): password=PASSWORD, ) - await engine._aexecute_outside_tx(f"DROP TABLE IF EXISTS {TABLE_NAME}") - await engine._aexecute_outside_tx(f"DROP TABLE IF EXISTS {CHAT_TABLE_NAME}") + async with engine._pool.connect() as conn: + await conn.execute(text("COMMIT")) + await conn.execute(text(f"DROP TABLE IF EXISTS {TABLE_NAME}")) + await conn.execute(text(f"DROP TABLE IF EXISTS {CHAT_TABLE_NAME}")) + await engine.close() await engine._connector.close_async() - await engine._engine.dispose() def delete_engines(): diff --git a/samples/langchain_on_vertexai/create_embeddings.py b/samples/langchain_on_vertexai/create_embeddings.py index 49e6ad79..105a86df 100644 --- a/samples/langchain_on_vertexai/create_embeddings.py +++ b/samples/langchain_on_vertexai/create_embeddings.py @@ -12,7 +12,6 @@ # See the License for the specific language governing permissions and # limitations under the License. import asyncio -import os import uuid from config import ( @@ -28,6 +27,7 @@ from google.cloud import resourcemanager_v3 # type: ignore from langchain_community.document_loaders.csv_loader import CSVLoader from langchain_google_vertexai import VertexAIEmbeddings +from sqlalchemy import text from langchain_google_cloud_sql_pg import PostgresEngine, PostgresVectorStore @@ -41,10 +41,11 @@ async def create_databases(): user=USER, password=PASSWORD, ) - await engine._aexecute_outside_tx(f'DROP DATABASE IF EXISTS "{DATABASE}"') - await engine._aexecute_outside_tx(f'CREATE DATABASE "{DATABASE}"') - await engine._connector.close_async() - await engine._engine.dispose() + async with engine._pool.connect() as conn: + await conn.execute(text("COMMIT")) + await conn.execute(text(f'DROP DATABASE IF EXISTS "{DATABASE}"')) + await conn.execute(text(f'CREATE DATABASE "{DATABASE}"')) + await engine.close() async def create_vectorstore(): @@ -69,7 +70,13 @@ async def create_vectorstore(): ) project_number = res.name.split("/")[1] IAM_USER = f"service-{project_number}@gcp-sa-aiplatform-re.iam" - await engine._aexecute(f'GRANT SELECT ON {TABLE_NAME} TO "{IAM_USER}";') + + async def grant_select(engine): + async with engine._pool.connect() as conn: + await conn.execute(text(f'GRANT SELECT ON {TABLE_NAME} TO "{IAM_USER}";')) + await conn.commit() + + await engine._run_as_async(grant_select(engine)) metadata = [ "show_id", @@ -94,8 +101,6 @@ async def create_vectorstore(): ids = [str(uuid.uuid4()) for i in range(len(docs))] await vector_store.aadd_documents(docs, ids=ids) - await engine._connector.close_async() - await engine._engine.dispose() async def main(): diff --git a/samples/langchain_on_vertexai/requirements.txt b/samples/langchain_on_vertexai/requirements.txt index 5996cbf4..9f389480 100644 --- a/samples/langchain_on_vertexai/requirements.txt +++ b/samples/langchain_on_vertexai/requirements.txt @@ -1,5 +1,5 @@ -google-cloud-aiplatform[reasoningengine,langchain]==1.65.0 +google-cloud-aiplatform[reasoningengine,langchain]==1.68.0 google-cloud-resource-manager==1.12.5 langchain-community==0.2.16 -langchain-google-cloud-sql-pg==0.9.0 +langchain-google-cloud-sql-pg==0.10.0 langchain-google-vertexai==1.0.10 From b501171d15d19f3cb0d9ddecd9d37d5cf1665b34 Mon Sep 17 00:00:00 2001 From: Mend Renovate Date: Fri, 4 Oct 2024 22:30:04 +0200 Subject: [PATCH 4/5] chore(deps): update python-nonmajor (#214) * chore(deps): update python-nonmajor --------- Co-authored-by: Averi Kitsch --- pyproject.toml | 2 +- requirements.txt | 8 ++++---- samples/index_tuning_sample/requirements.txt | 6 +++--- samples/langchain_on_vertexai/requirements.txt | 2 +- samples/requirements.txt | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 53ad7861..dacb49f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,7 +43,7 @@ test = [ "isort==5.13.2", "mypy==1.11.2", "pytest-asyncio==0.24.0", - "pytest==8.3.2", + "pytest==8.3.3", "pytest-cov==5.0.0" ] diff --git a/requirements.txt b/requirements.txt index 34ed4380..2433a992 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -cloud-sql-python-connector[asyncpg]==1.12.0 -langchain-core==0.3.0 +cloud-sql-python-connector[asyncpg]==1.12.1 +langchain-core==0.3.8 numpy==1.26.4 -pgvector==0.3.2 -SQLAlchemy[asyncio]==2.0.34 +pgvector==0.3.4 +SQLAlchemy[asyncio]==2.0.35 diff --git a/samples/index_tuning_sample/requirements.txt b/samples/index_tuning_sample/requirements.txt index d59a3563..de611708 100644 --- a/samples/index_tuning_sample/requirements.txt +++ b/samples/index_tuning_sample/requirements.txt @@ -1,3 +1,3 @@ -langchain-community==0.2.16 -langchain-google-cloud-sql-pg==0.9.0 -langchain-google-vertexai==1.0.10 \ No newline at end of file +langchain-community==0.3.1 +langchain-google-cloud-sql-pg==0.10.0 +langchain-google-vertexai==2.0.0 diff --git a/samples/langchain_on_vertexai/requirements.txt b/samples/langchain_on_vertexai/requirements.txt index 9f389480..818c8021 100644 --- a/samples/langchain_on_vertexai/requirements.txt +++ b/samples/langchain_on_vertexai/requirements.txt @@ -1,4 +1,4 @@ -google-cloud-aiplatform[reasoningengine,langchain]==1.68.0 +google-cloud-aiplatform[reasoningengine,langchain]==1.69.0 google-cloud-resource-manager==1.12.5 langchain-community==0.2.16 langchain-google-cloud-sql-pg==0.10.0 diff --git a/samples/requirements.txt b/samples/requirements.txt index 13db4cc8..818c8021 100644 --- a/samples/requirements.txt +++ b/samples/requirements.txt @@ -1,5 +1,5 @@ -google-cloud-aiplatform[reasoningengine,langchain]==1.65.0 +google-cloud-aiplatform[reasoningengine,langchain]==1.69.0 google-cloud-resource-manager==1.12.5 langchain-community==0.2.16 -langchain-google-cloud-sql-pg==0.9.0 -langchain-google-vertexai==1.0.10 \ No newline at end of file +langchain-google-cloud-sql-pg==0.10.0 +langchain-google-vertexai==1.0.10 From 8ad35b1951918c81deaf53e316e51db35ec2f9ff Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 7 Oct 2024 11:02:21 -0700 Subject: [PATCH 5/5] chore(main): release 0.11.0 (#219) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Averi Kitsch --- CHANGELOG.md | 7 +++++++ src/langchain_google_cloud_sql_pg/version.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a5bc737a..9d7bd57a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.11.0](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/compare/v0.10.0...v0.11.0) (2024-10-04) + + +### Features + +* Remove support for Python 3.8 ([#216](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/issues/216)) ([1737adc](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/commit/1737adc696e725488af860d031a22f6e6b66171b)) + ## [0.10.0](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/compare/v0.9.0...v0.10.0) (2024-09-17) diff --git a/src/langchain_google_cloud_sql_pg/version.py b/src/langchain_google_cloud_sql_pg/version.py index 00f17d64..185281d4 100644 --- a/src/langchain_google_cloud_sql_pg/version.py +++ b/src/langchain_google_cloud_sql_pg/version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.10.0" +__version__ = "0.11.0"