Skip to content

Commit

Permalink
Fix connection to Weaviate Cloud Service
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Mar 26, 2024
1 parent 69a171e commit 06a5936
Showing 1 changed file with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,31 @@ def __init__(
:param grpc_secure:
Whether to use a secure channel for the underlying gRPC API.
"""
# proxies, timeout_config, trust_env are part of additional_config now
# startup_period has been removed
self._client = weaviate.WeaviateClient(
connection_params=(
weaviate.connect.base.ConnectionParams.from_url(url=url, grpc_port=grpc_port, grpc_secure=grpc_secure)
if url
else None
),
auth_client_secret=auth_client_secret.resolve_value() if auth_client_secret else None,
additional_config=additional_config,
additional_headers=additional_headers,
embedded_options=embedded_options,
skip_init_checks=False,
)

# This is a quick ugly fix to make sure that users can use the DocumentStore
# with Weaviate Cloud Services with no issues
if url and url.startswith("http") and url.endswith(".weaviate.network"):
self._client = weaviate.connect_to_wcs(
url,
auth_credentials=auth_client_secret.resolve_value(),
headers=additional_headers,
additional_config=additional_config,
)
else:
self._client = weaviate.WeaviateClient(
connection_params=(
weaviate.connect.base.ConnectionParams.from_url(
url=url, grpc_port=grpc_port, grpc_secure=grpc_secure
)
if url
else None
),
auth_client_secret=auth_client_secret.resolve_value() if auth_client_secret else None,
additional_config=additional_config,
additional_headers=additional_headers,
embedded_options=embedded_options,
skip_init_checks=False,
)
self._client.connect()

# Test connection, it will raise an exception if it fails.
Expand Down

0 comments on commit 06a5936

Please sign in to comment.