diff --git a/.kokoro/requirements.txt b/.kokoro/requirements.txt index 7eb2ec20..ad774a65 100644 --- a/.kokoro/requirements.txt +++ b/.kokoro/requirements.txt @@ -502,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 51cc3777..69d06f8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [0.6.0](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/compare/v0.5.0...v0.6.0) (2024-06-18) + + +### Features + +* Add support for quota project ([#137](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/issues/137)) ([4f950b9](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/commit/4f950b90b53b7e1943744ab95a00cd6b4045a892)) + ## [0.5.0](https://github.com/googleapis/langchain-google-cloud-sql-pg-python/compare/v0.4.1...v0.5.0) (2024-05-30) diff --git a/pyproject.toml b/pyproject.toml index 378a771c..d751674c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,8 +13,7 @@ dependencies = [ "cloud-sql-python-connector[asyncpg] >= 1.7.0, <2.0.0", "langchain-core>=0.1.1, <1.0.0 ", "langchain-community>=0.0.18, <0.3.0", - "numpy==1.24.4; python_version<='3.8'", - "numpy>=1.24.4, <2.0.0; python_version>'3.8'", + "numpy>=1.24.4, <2.0.0", "pgvector>=0.2.5, <1.0.0", "SQLAlchemy[asyncio]>=2.0.25, <3.0.0" ] @@ -42,11 +41,11 @@ Changelog = "https://github.com/googleapis/langchain-google-cloud-sql-pg-python/ [project.optional-dependencies] test = [ - "black[jupyter]==23.12.1", + "black[jupyter]==24.4.2", "isort==5.13.2", "mypy==1.10.0", "pytest-asyncio==0.23.7", - "pytest==7.4.4", + "pytest==8.2.2", "pytest-cov==5.0.0" ] diff --git a/requirements.txt b/requirements.txt index db27ab05..ec40d805 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ -cloud-sql-python-connector[asyncpg]==1.9.2 -langchain-core==0.2.2 -langchain-community==0.2.1 +cloud-sql-python-connector[asyncpg]==1.10.0 +langchain-core==0.2.7 +langchain-community==0.2.5 numpy===1.24.4; python_version<='3.8' numpy==1.26.4; python_version>'3.8' pgvector==0.2.5 diff --git a/src/langchain_google_cloud_sql_pg/engine.py b/src/langchain_google_cloud_sql_pg/engine.py index d24126d1..ae353d70 100644 --- a/src/langchain_google_cloud_sql_pg/engine.py +++ b/src/langchain_google_cloud_sql_pg/engine.py @@ -112,6 +112,7 @@ def from_instance( user: Optional[str] = None, password: Optional[str] = None, ip_type: Union[str, IPTypes] = IPTypes.PUBLIC, + quota_project: Optional[str] = None, ) -> PostgresEngine: # Running a loop in a background thread allows us to support # async methods from non-async environments @@ -128,6 +129,7 @@ def from_instance( password, loop=loop, thread=thread, + quota_project=quota_project, ) return asyncio.run_coroutine_threadsafe(coro, loop).result() @@ -143,6 +145,7 @@ async def _create( password: Optional[str] = None, loop: Optional[asyncio.AbstractEventLoop] = None, thread: Optional[Thread] = None, + quota_project: Optional[str] = None, ) -> PostgresEngine: if bool(user) ^ bool(password): raise ValueError( @@ -152,7 +155,9 @@ async def _create( ) if cls._connector is None: cls._connector = Connector( - loop=asyncio.get_event_loop(), user_agent=USER_AGENT + loop=asyncio.get_event_loop(), + user_agent=USER_AGENT, + quota_project=quota_project, ) # if user and password are given, use basic auth @@ -197,6 +202,7 @@ async def afrom_instance( user: Optional[str] = None, password: Optional[str] = None, ip_type: Union[str, IPTypes] = IPTypes.PUBLIC, + quota_project: Optional[str] = None, ) -> PostgresEngine: return await cls._create( project_id, @@ -206,6 +212,7 @@ async def afrom_instance( ip_type, user, password, + quota_project=quota_project, ) @classmethod diff --git a/src/langchain_google_cloud_sql_pg/version.py b/src/langchain_google_cloud_sql_pg/version.py index 4f5353ed..7bf0f20b 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.5.0" +__version__ = "0.6.0" diff --git a/tests/test_postgresql_engine.py b/tests/test_postgresql_engine.py index 8c08a238..50265731 100644 --- a/tests/test_postgresql_engine.py +++ b/tests/test_postgresql_engine.py @@ -270,6 +270,7 @@ async def test_password( database=db_name, user=user, password=password, + quota_project=db_project, ) assert engine engine._execute("SELECT 1") diff --git a/tests/test_postgresql_loader.py b/tests/test_postgresql_loader.py index 49b11de9..d295c027 100644 --- a/tests/test_postgresql_loader.py +++ b/tests/test_postgresql_loader.py @@ -38,6 +38,7 @@ class TestLoaderAsync: @pytest_asyncio.fixture async def engine(self): + PostgresEngine._connector = None engine = await PostgresEngine.afrom_instance( project_id=project_id, instance=instance_id, @@ -48,6 +49,7 @@ async def engine(self): @pytest_asyncio.fixture def sync_engine(self): + PostgresEngine._connector = None engine = PostgresEngine.from_instance( project_id=project_id, instance=instance_id, @@ -734,6 +736,7 @@ async def test_delete_doc_with_customized_metadata( assert len(await self._collect_async_items(loader.alazy_load())) == 0 def test_sync_engine(self): + PostgresEngine._connector = None engine = PostgresEngine.from_instance( project_id=project_id, instance=instance_id,