From 5e6e19b2ba7910104a0ea42f71119001a293fe82 Mon Sep 17 00:00:00 2001 From: Dirk Kulawiak Date: Wed, 14 Aug 2024 16:57:34 +0200 Subject: [PATCH 1/2] Remove deprecation warnings --- weaviate/batch/crud_batch.py | 2 +- weaviate/connect/connection.py | 17 +---------------- weaviate/warnings.py | 28 ---------------------------- 3 files changed, 2 insertions(+), 45 deletions(-) diff --git a/weaviate/batch/crud_batch.py b/weaviate/batch/crud_batch.py index e4f41a405..6607902a1 100644 --- a/weaviate/batch/crud_batch.py +++ b/weaviate/batch/crud_batch.py @@ -1,6 +1,7 @@ """ Batch class definitions. """ + import datetime import sys import threading @@ -349,7 +350,6 @@ def __call__(self, **kwargs: Any) -> "Batch": ValueError If the value of one of the arguments is wrong. """ - _Warnings.use_of_client_batch_will_be_removed_in_next_major_release() return self.configure(**kwargs) def configure( diff --git a/weaviate/connect/connection.py b/weaviate/connect/connection.py index 83322ad7e..2b1a0c7d9 100644 --- a/weaviate/connect/connection.py +++ b/weaviate/connect/connection.py @@ -1,6 +1,7 @@ """ Connection class definition. """ + from __future__ import annotations import datetime @@ -18,7 +19,6 @@ from requests.exceptions import HTTPError as RequestsHTTPError from requests.exceptions import JSONDecodeError -from weaviate import __version__ as client_version from weaviate.auth import AuthCredentials, AuthClientCredentials, AuthApiKey from weaviate.config import ConnectionConfig from weaviate.connect.authentication import _Auth @@ -31,14 +31,10 @@ from weaviate.util import ( _check_positive_num, is_weaviate_domain, - is_weaviate_too_old, - is_weaviate_client_too_old, - PYPI_PACKAGE_URL, _decode_json_response_dict, ) from weaviate.warnings import _Warnings - try: import grpc # type: ignore from weaviate.proto.v1 import weaviate_pb2_grpc @@ -171,17 +167,6 @@ def __init__( self._server_version = self.get_meta()["version"] if self._server_version < "1.14": _Warnings.weaviate_server_older_than_1_14(self._server_version) - if is_weaviate_too_old(self._server_version): - _Warnings.weaviate_too_old_vs_latest(self._server_version) - - try: - pkg_info = requests.get(PYPI_PACKAGE_URL, timeout=INIT_CHECK_TIMEOUT).json() - pkg_info = pkg_info.get("info", {}) - latest_version = pkg_info.get("version", "unknown version") - if is_weaviate_client_too_old(client_version, latest_version): - _Warnings.weaviate_client_too_old_vs_latest(client_version, latest_version) - except requests.exceptions.RequestException: - pass # ignore any errors related to requests, it is a best-effort warning def _create_sessions(self, auth_client_secret: Optional[AuthCredentials]) -> None: """Creates a async httpx session and a sync request session. diff --git a/weaviate/warnings.py b/weaviate/warnings.py index aab6cf6f5..fd54eb49a 100644 --- a/weaviate/warnings.py +++ b/weaviate/warnings.py @@ -106,31 +106,3 @@ def token_refresh_failed(exc: Exception) -> None: category=UserWarning, stacklevel=1, ) - - @staticmethod - def weaviate_too_old_vs_latest(server_version: str) -> None: - warnings.warn( - message=f"""Dep004: You are connected to Weaviate {server_version}. - Please consider upgrading to the latest version. See https://www.weaviate.io/developers/weaviate for details.""", - category=DeprecationWarning, - stacklevel=1, - ) - - @staticmethod - def weaviate_client_too_old_vs_latest(client_version: str, latest_version: str) -> None: - warnings.warn( - message=f"""Dep005: You are using weaviate-client version {client_version}. The latest version is {latest_version}. - Please consider upgrading to the latest version. See https://weaviate.io/developers/weaviate/client-libraries/python for details.""", - category=DeprecationWarning, - stacklevel=1, - ) - - @staticmethod - def use_of_client_batch_will_be_removed_in_next_major_release() -> None: - warnings.warn( - message="""Dep006: You are using the `client.batch()` method, which will be removed in the next major release. - Please instead use the `client.batch.configure()` method to configure your batch and `client.batch` to enter the context manager. - See https://weaviate.io/developers/weaviate/client-libraries/python for details.""", - category=DeprecationWarning, - stacklevel=1, - ) From 684fe166130b974fb60afa216958fb24bb9a5eb9 Mon Sep 17 00:00:00 2001 From: Dirk Kulawiak Date: Thu, 15 Aug 2024 10:22:10 +0200 Subject: [PATCH 2/2] Fix tests --- ci/start_weaviate.sh | 16 ++++++++-------- ci/stop_weaviate.sh | 16 ++++++++-------- mock_tests/test_connection.py | 21 --------------------- 3 files changed, 16 insertions(+), 37 deletions(-) diff --git a/ci/start_weaviate.sh b/ci/start_weaviate.sh index c547a19b0..0a45b1297 100755 --- a/ci/start_weaviate.sh +++ b/ci/start_weaviate.sh @@ -3,11 +3,11 @@ set -eou pipefail echo "Run Docker compose" -nohup docker-compose -f ci/docker-compose.yml up -d -nohup docker-compose -f ci/docker-compose-async.yml up -d -nohup docker-compose -f ci/docker-compose-azure.yml up -d -nohup docker-compose -f ci/docker-compose-okta-cc.yml up -d -nohup docker-compose -f ci/docker-compose-okta-users.yml up -d -nohup docker-compose -f ci/docker-compose-wcs.yml up -d -nohup docker-compose -f ci/docker-compose-openai.yml up -d -nohup docker-compose -f ci/docker-compose-cluster.yml up -d +nohup docker compose -f ci/docker-compose.yml up -d +nohup docker compose -f ci/docker-compose-async.yml up -d +nohup docker compose -f ci/docker-compose-azure.yml up -d +nohup docker compose -f ci/docker-compose-okta-cc.yml up -d +nohup docker compose -f ci/docker-compose-okta-users.yml up -d +nohup docker compose -f ci/docker-compose-wcs.yml up -d +nohup docker compose -f ci/docker-compose-openai.yml up -d +nohup docker compose -f ci/docker-compose-cluster.yml up -d diff --git a/ci/stop_weaviate.sh b/ci/stop_weaviate.sh index 0b13b9519..41e41fd44 100755 --- a/ci/stop_weaviate.sh +++ b/ci/stop_weaviate.sh @@ -2,11 +2,11 @@ set -eou pipefail -docker-compose -f ci/docker-compose.yml down --remove-orphans -docker-compose -f ci/docker-compose-async.yml down --remove-orphans -docker-compose -f ci/docker-compose-azure.yml down --remove-orphans -docker-compose -f ci/docker-compose-okta-cc.yml down --remove-orphans -docker-compose -f ci/docker-compose-okta-users.yml down --remove-orphans -docker-compose -f ci/docker-compose-wcs.yml down --remove-orphans -docker-compose -f ci/docker-compose-openai.yml down --remove-orphans -docker-compose -f ci/docker-compose-cluster.yml down --remove-orphans +docker compose -f ci/docker-compose.yml down --remove-orphans +docker compose -f ci/docker-compose-async.yml down --remove-orphans +docker compose -f ci/docker-compose-azure.yml down --remove-orphans +docker compose -f ci/docker-compose-okta-cc.yml down --remove-orphans +docker compose -f ci/docker-compose-okta-users.yml down --remove-orphans +docker compose -f ci/docker-compose-wcs.yml down --remove-orphans +docker compose -f ci/docker-compose-openai.yml down --remove-orphans +docker compose -f ci/docker-compose-cluster.yml down --remove-orphans diff --git a/mock_tests/test_connection.py b/mock_tests/test_connection.py index 654dc8f5a..940f403ed 100644 --- a/mock_tests/test_connection.py +++ b/mock_tests/test_connection.py @@ -33,27 +33,6 @@ def handler(request: Request): client.schema.delete_all() # some call that includes headers -@pytest.mark.parametrize("version,warning", [("1.13", True), ("1.14", False)]) -def test_warning_old_weaviate(recwarn, ready_mock: HTTPServer, version: str, warning: bool): - """Test that we warn if a new client version is using an old weaviate server.""" - ready_mock.expect_request("/v1/meta").respond_with_json({"version": version}) - weaviate.Client(url=MOCK_SERVER_URL) - - if warning: - assert len(recwarn) == 2 - w = recwarn.pop() - assert issubclass(w.category, DeprecationWarning) - assert str(w.message).startswith("Dep001") - w = recwarn.pop() - assert issubclass(w.category, DeprecationWarning) - assert str(w.message).startswith("Dep004") - else: - assert len(recwarn) == 1 - w = recwarn.pop() - assert issubclass(w.category, DeprecationWarning) - assert str(w.message).startswith("Dep004") - - def test_wait_for_weaviate(httpserver: HTTPServer): def handler(request: Request): time.sleep(0.01)