diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 0000000..2c634d5 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,8 @@ +[run] +branch = true +omit = + */__init__.py + +[report] +show_missing = true +fail_under = 90 \ No newline at end of file diff --git a/.github/blunderbuss.yml b/.github/blunderbuss.yml new file mode 100644 index 0000000..21e15f8 --- /dev/null +++ b/.github/blunderbuss.yml @@ -0,0 +1,4 @@ +assign_issues: + - googleapis/langchain-csql-mssql +assign_prs: + - googleapis/langchain-csql-mssql diff --git a/.github/header-checker-lint.yml b/.github/header-checker-lint.yml index 53c9c5c..5a21e5f 100644 --- a/.github/header-checker-lint.yml +++ b/.github/header-checker-lint.yml @@ -11,6 +11,7 @@ sourceFileExtensions: - "py" - "text" ignoreFiles: + - ".github/blunderbuss.yml" - ".github/release-please.yml" - ".github/release-trigger.yml" - ".github/header-checker-lint.yml" diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt index c2ce28d..ad774a6 100644 --- a/.kokoro/requirements.txt +++ b/.kokoro/requirements.txt @@ -273,10 +273,12 @@ jaraco-classes==3.3.1 \ jeepney==0.8.0 \ --hash=sha256:5efe48d255973902f6badc3ce55e2aa6c5c3b3bc642059ef3a91247bcfcc5806 \ --hash=sha256:c0a454ad016ca575060802ee4d590dd912e35c122fa04e70306de3d076cce755 - # via secretstorage -jinja2==3.1.3 \ - --hash=sha256:7d6d50dd97d52cbc355597bd845fabfbac3f551e1f99619e39a35ce8c370b5fa \ - --hash=sha256:ac8bd6544d4bb2c9792bf3a159e80bba8fda7f07e81bc3aed565432d5925ba90 + # via + # keyring + # secretstorage +jinja2==3.1.4 \ + --hash=sha256:4a3aee7acbbe7303aede8e9648d13b8bf88a429282aa6122a993f0ac800cb369 \ + --hash=sha256:bc5dd2abb727a5319567b7a813e6a2e7318c39f4f487cfe6c89c6f9c7d25197d # via gcp-releasetool keyring==24.3.1 \ --hash=sha256:c3327b6ffafc0e8befbdb597cacdb4928ffe5c1212f7645f186e6d9957a898db \ @@ -451,9 +453,9 @@ readme-renderer==42.0 \ --hash=sha256:13d039515c1f24de668e2c93f2e877b9dbe6c6c32328b90a40a49d8b2b85f36d \ --hash=sha256:2d55489f83be4992fe4454939d1a051c33edbab778e82761d060c9fc6b308cd1 # via twine -requests==2.31.0 \ - --hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f \ - --hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1 +requests==2.32.0 \ + --hash=sha256:f2c3881dddb70d056c5bd7600a4fae312b2a300e39be6a118d30b90bd27262b5 \ + --hash=sha256:fa5490319474c82ef1d2c9bc459d3652e3ae4ef4c4ebdd18a21145a47ca4b6b8 # via # gcp-releasetool # google-api-core @@ -479,7 +481,9 @@ rsa==4.9 \ secretstorage==3.3.3 \ --hash=sha256:2403533ef369eca6d2ba81718576c5e0f564d5cca1b58f73a8b23e7d4eeebd77 \ --hash=sha256:f356e6628222568e3af06f2eba8df495efa13b3b63081dafd4f7d9a7b7bc9f99 - # via -r requirements.in + # via + # -r requirements.in + # keyring six==1.16.0 \ --hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \ --hash=sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254 @@ -498,9 +502,9 @@ typing-extensions==4.10.0 \ --hash=sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475 \ --hash=sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb # via -r requirements.in -urllib3==2.2.1 \ - --hash=sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d \ - --hash=sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19 +urllib3==2.2.2 \ + --hash=sha256:a448b2f64d686155468037e1ace9f2d2199776e17f0a46610480d311f73e3472 \ + --hash=sha256:dd505485549a7a552833da5e6063639d0d177c04f23bc3864e41e5dc5f612168 # via # requests # twine diff --git a/CHANGELOG.md b/CHANGELOG.md index 20ba473..b89ee48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.2.1](https://github.com/googleapis/langchain-google-cloud-sql-mssql-python/compare/v0.2.0...v0.2.1) (2024-06-26) + + +### Bug Fixes + +* Use lazy refresh for Cloud SQL Connector ([#55](https://github.com/googleapis/langchain-google-cloud-sql-mssql-python/issues/55)) ([0c29445](https://github.com/googleapis/langchain-google-cloud-sql-mssql-python/commit/0c29445be6680cd45b4c796a1f3254552131f15c)) + ## [0.2.0](https://github.com/googleapis/langchain-google-cloud-sql-mssql-python/compare/v0.1.0...v0.2.0) (2024-05-01) diff --git a/DEVELOPER.md b/DEVELOPER.md index cc958c3..c1d95df 100644 --- a/DEVELOPER.md +++ b/DEVELOPER.md @@ -58,7 +58,7 @@ substitutions: _VERSION: "3.8" ``` -Use `gcloud builds triggers import --source=trigger.yaml` create triggers via the command line +Use `gcloud builds triggers import --source=trigger.yaml` to create triggers via the command line #### Project Setup @@ -77,5 +77,17 @@ Use `gcloud builds triggers import --source=trigger.yaml` create triggers via th To run Cloud Build tests on GitHub from external contributors, ie RenovateBot, comment: `/gcbrun`. +#### 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. +Here is a breakdown of the report: +- `Stmts`: lines of executable code (statements). +- `Miss`: number of lines not covered by tests. +- `Branch`: branches of executable code (e.g an if-else clause may count as 1 statement but 2 branches; test for both conditions to have both branches covered). +- `BrPart`: number of branches not covered by tests. +- `Cover`: average coverage of files. +- `Missing`: lines that are not covered by tests. + [triggers]: https://console.cloud.google.com/cloud-build/triggers?e=13802955&project=langchain-cloud-sql-testing \ No newline at end of file diff --git a/integration.cloudbuild.yaml b/integration.cloudbuild.yaml index 8f37d32..a46e34d 100644 --- a/integration.cloudbuild.yaml +++ b/integration.cloudbuild.yaml @@ -26,7 +26,7 @@ steps: - id: Run integration tests name: python:${_VERSION} entrypoint: python - args: ["-m", "pytest"] + args: ["-m", "pytest", "--cov=langchain_google_cloud_sql_mssql", "--cov-config=.coveragerc", "tests/"] env: - "PROJECT_ID=$PROJECT_ID" - "INSTANCE_ID=$_INSTANCE_ID" diff --git a/pyproject.toml b/pyproject.toml index 505384b..88420b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ dependencies = [ "langchain-community>=0.0.18, <1.0.0", "SQLAlchemy>=2.0.7, <3.0.0", "sqlalchemy-pytds>=1.0.0, <2.0.0", - "cloud-sql-python-connector[pytds]>=1.7.0, <2.0.0" + "cloud-sql-python-connector[pytds]>=1.10.0, <2.0.0" ] classifiers = [ "Intended Audience :: Developers", @@ -40,10 +40,11 @@ Changelog = "https://github.com/googleapis/langchain-google-cloud-sql-mssql-pyth test = [ "black[jupyter]==23.12.1", "isort==5.13.2", - "langchain==0.1.12", - "mypy==1.9.0", - "pytest-asyncio==0.23.5.post1", - "pytest==7.4.4" + "langchain==0.2.5", + "mypy==1.10.0", + "pytest-asyncio==0.23.7", + "pytest==7.4.4", + "pytest-cov==5.0.0" ] [build-system] @@ -56,6 +57,7 @@ profile = "black" [tool.mypy] python_version = "3.11" warn_unused_configs = true +disallow_incomplete_defs = true exclude = [ 'docs/*', diff --git a/requirements.txt b/requirements.txt index 8fb218d..0ad100d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -langchain-core==0.1.35 -langchain-community==0.0.28 -SQLAlchemy==2.0.28 +langchain-core==0.2.7 +langchain-community==0.2.5 +SQLAlchemy==2.0.30 sqlalchemy-pytds==1.0.0 -cloud-sql-python-connector[pytds]==1.8.0 +cloud-sql-python-connector[pytds]==1.10.0 diff --git a/src/langchain_google_cloud_sql_mssql/engine.py b/src/langchain_google_cloud_sql_mssql/engine.py index 875d9eb..1dc7feb 100644 --- a/src/langchain_google_cloud_sql_mssql/engine.py +++ b/src/langchain_google_cloud_sql_mssql/engine.py @@ -18,7 +18,7 @@ from typing import List, Optional import sqlalchemy -from google.cloud.sql.connector import Connector +from google.cloud.sql.connector import Connector, RefreshStrategy from .version import __version__ @@ -96,7 +96,9 @@ def _create_connector_engine( Python Connector. """ if cls._connector is None: - cls._connector = Connector(user_agent=USER_AGENT) + cls._connector = Connector( + user_agent=USER_AGENT, refresh_strategy=RefreshStrategy.LAZY + ) # anonymous function to be used for SQLAlchemy 'creator' argument def getconn(): diff --git a/src/langchain_google_cloud_sql_mssql/version.py b/src/langchain_google_cloud_sql_mssql/version.py index 20c5861..fffa9d9 100644 --- a/src/langchain_google_cloud_sql_mssql/version.py +++ b/src/langchain_google_cloud_sql_mssql/version.py @@ -12,4 +12,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -__version__ = "0.2.0" +__version__ = "0.2.1"