Skip to content

Commit

Permalink
fix: Weaviate - fix connection issues with some WCS URLs (#1058)
Browse files Browse the repository at this point in the history
* try fix

* small fix in docstring

* simplify condition

* better condition and comments

* only lint on 3.9 like other integrations
  • Loading branch information
anakin87 authored Sep 7, 2024
1 parent b897441 commit ec236b8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/weaviate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
run: pip install --upgrade hatch

- name: Lint
if: matrix.python-version == '3.9' && runner.os == 'Linux'
run: hatch run lint:all

- name: Run Weaviate container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class WeaviateDocumentStore:
from haystack_integrations.document_stores.weaviate.auth import AuthApiKey
from haystack_integrations.document_stores.weaviate.document_store import WeaviateDocumentStore
os.environ["WEAVIATE_API_KEY"] = "MY_API_KEY
os.environ["WEAVIATE_API_KEY"] = "MY_API_KEY"
document_store = WeaviateDocumentStore(
url="rAnD0mD1g1t5.something.weaviate.cloud",
Expand Down Expand Up @@ -172,17 +172,18 @@ def client(self):
if self._client:
return self._client

if self._url and self._url.startswith("http") and self._url.endswith(".weaviate.network"):
# We use this utility function instead of using WeaviateClient directly like in other cases
# otherwise we'd have to parse the URL to get some information about the connection.
# This utility function does all that for us.
self._client = weaviate.connect_to_wcs(
if self._url and self._url.endswith((".weaviate.network", ".weaviate.cloud")):
# If we detect that the URL is a Weaviate Cloud URL, we use the utility function to connect
# instead of using WeaviateClient directly like in other cases.
# Among other things, the utility function takes care of parsing the URL.
self._client = weaviate.connect_to_weaviate_cloud(
self._url,
auth_credentials=self._auth_client_secret.resolve_value() if self._auth_client_secret else None,
headers=self._additional_headers,
additional_config=self._additional_config,
)
else:
# Embedded, local Docker deployment or custom connection.
# proxies, timeout_config, trust_env are part of additional_config now
# startup_period has been removed
self._client = weaviate.WeaviateClient(
Expand Down

0 comments on commit ec236b8

Please sign in to comment.