Skip to content

Commit

Permalink
Introduce use_async_with_x instead of `connect_to_x(..., use_async=…
Browse files Browse the repository at this point in the history
…True)`
  • Loading branch information
tsmith023 committed Jun 10, 2024
1 parent f4b89e6 commit ad92247
Show file tree
Hide file tree
Showing 5 changed files with 284 additions and 254 deletions.
3 changes: 1 addition & 2 deletions integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,11 @@ async def _factory(
) -> weaviate.WeaviateAsyncClient:
nonlocal client_fixture
if client_fixture is None:
client_fixture = weaviate.connect_to_local(
client_fixture = weaviate.use_async_with_local(
headers=headers,
grpc_port=ports[1],
port=ports[0],
additional_config=AdditionalConfig(timeout=(60, 120)), # for image tests
use_async=True,
)
await client_fixture.connect()
return client_fixture
Expand Down
12 changes: 5 additions & 7 deletions integration/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,14 +533,13 @@ async def test_async_client_with_extra_options(timeout: Union[Tuple[int, int], T
additional_config = wvc.init.AdditionalConfig(timeout=timeout, trust_env=True)

for client in [
weaviate.connect_to_weaviate_cloud(
weaviate.use_async_with_weaviate_cloud(
cluster_url=WCS_URL,
auth_credentials=WCS_CREDS,
additional_config=additional_config,
use_async=True,
),
weaviate.connect_to_local(additional_config=additional_config, use_async=True),
weaviate.connect_to_custom(
weaviate.use_async_with_local(additional_config=additional_config),
weaviate.use_async_with_custom(
http_secure=True,
http_host=WCS_HOST,
http_port=443,
Expand All @@ -549,7 +548,6 @@ async def test_async_client_with_extra_options(timeout: Union[Tuple[int, int], T
grpc_port=443,
auth_credentials=WCS_CREDS,
additional_config=additional_config,
use_async=True,
),
]:
await client.connect()
Expand Down Expand Up @@ -582,8 +580,8 @@ def test_client_is_ready() -> None:

@pytest.mark.asyncio
async def test_async_client_is_ready() -> None:
async with weaviate.connect_to_weaviate_cloud(
cluster_url=WCS_URL, auth_credentials=WCS_CREDS, skip_init_checks=True, use_async=True
async with weaviate.use_async_with_weaviate_cloud(
cluster_url=WCS_URL, auth_credentials=WCS_CREDS, skip_init_checks=True
) as client:
assert client.is_ready()

Expand Down
6 changes: 3 additions & 3 deletions journey_tests/journeys.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from weaviate import WeaviateAsyncClient, WeaviateClient, connect_to_local
from weaviate import WeaviateAsyncClient, WeaviateClient, connect_to_local, use_async_with_local
from weaviate.classes.config import Configure, DataType, Property


Expand All @@ -10,7 +10,7 @@ def __init__(self, client: WeaviateClient) -> None:

@classmethod
def use(cls) -> "SyncJourneys":
return cls(connect_to_local(use_async=False))
return cls(connect_to_local())

def close(self) -> None:
self.__client.close()
Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(self, client: WeaviateAsyncClient) -> None:

@classmethod
async def use(cls) -> "AsyncJourneys":
client = connect_to_local(use_async=True)
client = use_async_with_local()
await client.connect()
return cls(client)

Expand Down
6 changes: 6 additions & 0 deletions weaviate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
connect_to_local,
connect_to_wcs,
connect_to_weaviate_cloud,
use_async_with_custom,
use_async_with_local,
use_async_with_weaviate_cloud,
)
from . import (
auth,
Expand Down Expand Up @@ -71,6 +74,9 @@
"outputs",
"schema",
"types",
"use_async_with_custom",
"use_async_with_local",
"use_async_with_weaviate_cloud",
]

deprs = [
Expand Down
Loading

0 comments on commit ad92247

Please sign in to comment.