Skip to content

Commit

Permalink
Merge branch 'main' into mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwotherspoon authored Oct 16, 2024
2 parents 2119909 + 1da3e1d commit e4e40cd
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 69 deletions.
1 change: 0 additions & 1 deletion .github/sync-repo-settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ branchProtectionRules:
requiredStatusCheckContexts:
- "cla/google"
- "lint"
- "mysql-integration-test-pr-py38 (langchain-cloud-sql-testing)"
- "mysql-integration-test-pr-py39 (langchain-cloud-sql-testing)"
- "mysql-integration-test-pr-py310 (langchain-cloud-sql-testing)"
- "mysql-integration-test-pr-py311 (langchain-cloud-sql-testing)"
Expand Down
29 changes: 0 additions & 29 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ on:
- "*.md"
- ".kokoro/**"
- ".github/**"
pull_request_target:
types: [labeled]
paths-ignore:
- "*.md"
- ".kokoro/**"
- ".github/**"

jobs:
lint:
Expand All @@ -34,33 +28,10 @@ jobs:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# run job on proper workflow event triggers (skip job for pull_request event from forks and only run pull_request_target for "tests: run" label)
if: "${{ (github.event.action != 'labeled' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) || github.event.label.name == 'tests: run' }}"

steps:
- name: Remove PR label
if: "${{ github.event.action == 'labeled' && github.event.label.name == 'tests: run' }}"
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
name: 'tests: run',
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number
});
} catch (e) {
console.log('Failed to remove label. Another job may have already removed it!');
}
- name: Checkout Repository
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Python
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
Expand Down
2 changes: 1 addition & 1 deletion .kokoro/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-mysql-python
python3 -m build --wheel
twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/*
2 changes: 1 addition & 1 deletion .kokoro/release/common.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions .kokoro/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ cachetools==4.2.4 \
--hash=sha256:89ea6f1b638d5a73a4f9226be57ac5e4f399d22770b92355f92dcb0f7f001693 \
--hash=sha256:92971d3cb7d2a97efff7c7bb1657f21a8f5fb309a37530537c71b1774189f2d1
# via google-auth
certifi==2023.11.17 \
--hash=sha256:9b469f3a900bf28dc19b8cfbf8019bf47f7fdd1a65a1d4ffb98fc14166beb4d1 \
--hash=sha256:e036ab49d5b79556f99cfc2d9320b34cfbe5be05c5871b51de9329f0603b0474
certifi==2024.7.4 \
--hash=sha256:5a1e7645bc0ec61a09e26c36f6106dd4cf40c6db3a1fb6352b0244e7fb057c7b \
--hash=sha256:c198e21b1289c2ab85ee4e67bb4b4ef3ead0892059901a8d5b622f24a1101e90
# via requests
cffi==1.16.0 \
--hash=sha256:0c9ef6ff37e974b73c25eecc13952c55bceed9112be2d9d938ded8e856138bcc \
Expand Down Expand Up @@ -453,9 +453,9 @@ readme-renderer==43.0 \
--hash=sha256:1818dd28140813509eeed8d62687f7cd4f7bad90d4db586001c5dc09d4fde311 \
--hash=sha256:19db308d86ecd60e5affa3b2a98f017af384678c63c88e5d4556a380e674f3f9
# 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
Expand Down Expand Up @@ -502,9 +502,9 @@ typing-extensions==4.10.0 \
--hash=sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475 \
--hash=sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb
# via -r requirements.in
urllib3==1.26.18 \
--hash=sha256:34b97092d7e0a3a8cf7cd10e386f401b3737364026c45e622aa02903dffe0f07 \
--hash=sha256:f8ecc1bba5667413457c529ab955bf8c67b45db799d159066261719e328580a0
urllib3==1.26.19 \
--hash=sha256:37a0344459b199fce0e80b0d3569837ec6b6937435c5244e7fd73fa6006830f3 \
--hash=sha256:3e3d753a8618b86d7de333b4223005f68720bcd6a7d2bcb9fbd2229ec7c1e429
# via
# requests
# twine
Expand All @@ -516,9 +516,9 @@ wheel==0.43.0 \
--hash=sha256:465ef92c69fa5c5da2d1cf8ac40559a8c940886afcef87dcf14b9470862f1d85 \
--hash=sha256:55c570405f142630c6b9f72fe09d9b67cf1477fcf543ae5b8dcb1f5b7377da81
# via -r requirements.in
zipp==3.18.1 \
--hash=sha256:206f5a15f2af3dbaee80769fb7dc6f249695e940acca08dfb2a4769fe61e538b \
--hash=sha256:2884ed22e7d8961de1c9a05142eb69a247f120291bc0206a00a7642f09b5b715
zipp==3.19.1 \
--hash=sha256:2828e64edb5386ea6a52e7ba7cdb17bb30a73a858f5eb6eb93d8d36f5ea26091 \
--hash=sha256:35427f6d5594f4acf82d25541438348c26736fa9b3afa2754bcd63cdb99d8e8f
# via importlib-metadata

# WARNING: The following packages were not pinned, but pip requires them to be
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [0.2.3](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/compare/v0.2.2...v0.2.3) (2024-07-03)


### Bug Fixes

* Use lazy refresh for Cloud SQL Connector ([#86](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/issues/86)) ([58591d5](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/commit/58591d564255217f00582eabd12a1183b089f5e3))

## [0.2.2](https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/compare/v0.2.1...v0.2.2) (2024-04-30)


Expand Down
8 changes: 4 additions & 4 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,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: mysql-integration-test-pr-py38
description: Run integration tests on PR for Python 3.8
name: mysql-integration-test-pr-py39
description: Run integration tests on PR for Python 3.9
filename: integration.cloudbuild.yaml
github:
name: langchain-google-cloud-sql-mysql-python
Expand All @@ -55,7 +55,7 @@ substitutions:
_INSTANCE_ID: <ADD_VALUE>
_DB_NAME: <ADD_VALUE>
_REGION: us-central1
_VERSION: "3.8"
_VERSION: "3.9"
```

Use `gcloud builds triggers import --source=trigger.yaml` to create triggers via the command line
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ With `virtualenv`_, it’s possible to install this library without needing syst
Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^

Python >= 3.8
Python >= 3.9

Mac/Linux
^^^^^^^^^
Expand Down Expand Up @@ -112,7 +112,7 @@ See the full `Document Loader`_ tutorial.
.. _`Document Loader`: https://github.com/googleapis/langchain-google-cloud-sql-mysql-python/blob/main/docs/document_loader.ipynb

Chat Message History Usage
--------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~

Use ``ChatMessageHistory`` to store messages and provide conversation
history to LLMs.
Expand Down
11 changes: 9 additions & 2 deletions integration.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ steps:
- id: Run integration tests
name: python:${_VERSION}
entrypoint: python
args: ["-m", "pytest", "--cov=langchain_google_cloud_sql_mysql", "--cov-config=.coveragerc", "tests/"]
args:
[
"-m",
"pytest",
"--cov=langchain_google_cloud_sql_mysql",
"--cov-config=.coveragerc",
"tests/",
]
env:
- "PROJECT_ID=$PROJECT_ID"
- "INSTANCE_ID=$_INSTANCE_ID"
Expand All @@ -46,7 +53,7 @@ substitutions:
_INSTANCE_ID: test-instance
_REGION: us-central1
_DB_NAME: test
_VERSION: "3.8"
_VERSION: "3.9"

options:
dynamicSubstitutions: true
15 changes: 7 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dynamic = ["version"]
description = "LangChain integrations for Google Cloud SQL for MySQL"
readme = "README.rst"
license = {file = "LICENSE"}
requires-python = ">=3.8"
requires-python = ">=3.9"
authors = [
{name = "Google LLC", email = "googleapis-packages@google.com"}
]
Expand All @@ -13,15 +13,14 @@ dependencies = [
"langchain-community>=0.0.18, <1.0.0",
"numpy>=1.24.4, <2.0.0",
"SQLAlchemy>=2.0.7, <3.0.0",
"cloud-sql-python-connector[pymysql]>=1.7.0, <2.0.0"
"cloud-sql-python-connector[pymysql]>=1.10.0, <2.0.0"
]

classifiers = [
"Intended Audience :: Developers",
"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",
Expand All @@ -39,11 +38,11 @@ Changelog = "https://github.com/googleapis/langchain-google-cloud-sql-mysql-pyth

[project.optional-dependencies]
test = [
"black[jupyter]==24.4.1",
"black[jupyter]==24.8.0",
"isort==5.13.2",
"mypy==1.10.0",
"pytest-asyncio==0.23.6",
"pytest==8.1.1",
"mypy==1.11.2",
"pytest-asyncio==0.24.0",
"pytest==8.3.3",
"pytest-cov==5.0.0"
]

Expand All @@ -55,7 +54,7 @@ build-backend = "setuptools.build_meta"
profile = "black"

[tool.mypy]
python_version = "3.8"
python_version = "3.9"
warn_unused_configs = true
disallow_incomplete_defs = true

Expand Down
11 changes: 5 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
langchain==0.1.16
langchain-community==0.0.34
numpy==1.24.4; python_version<='3.8'
numpy==1.26.4; python_version>'3.8'
SQLAlchemy==2.0.29
cloud-sql-python-connector[pymysql]==1.9.1
langchain==0.3.1
langchain-community==0.3.1
numpy==1.26.4
SQLAlchemy==2.0.35
cloud-sql-python-connector[pymysql]==1.12.1

6 changes: 4 additions & 2 deletions src/langchain_google_cloud_sql_mysql/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import google.auth.transport.requests
import requests
import sqlalchemy
from google.cloud.sql.connector import Connector
from google.cloud.sql.connector import Connector, RefreshStrategy

from .version import __version__

Expand Down Expand Up @@ -193,7 +193,9 @@ def _create_connector_engine(
enable_iam_auth = True

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() -> pymysql.Connection:
Expand Down
2 changes: 1 addition & 1 deletion src/langchain_google_cloud_sql_mysql/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version__ = "0.2.2"
__version__ = "0.2.3"

0 comments on commit e4e40cd

Please sign in to comment.