From 85a10a8d9ecb4c9269af3cd83794c10d057ee8b0 Mon Sep 17 00:00:00 2001 From: David Otte Date: Mon, 11 Mar 2024 17:49:15 +0100 Subject: [PATCH] Fix minor things --- tabpfn_client/client.py | 5 +++-- tabpfn_client/tests/unit/test_client.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tabpfn_client/client.py b/tabpfn_client/client.py index 1360393..aacb1aa 100644 --- a/tabpfn_client/client.py +++ b/tabpfn_client/client.py @@ -4,6 +4,7 @@ from importlib.metadata import version, PackageNotFoundError import numpy as np from omegaconf import OmegaConf +import json from tabpfn_client.tabpfn_common_utils import utils as common_utils @@ -136,8 +137,8 @@ def _validate_response(response, method_name, only_version_check=False): load = None try: load = response.json() - except Exception: - pass + except json.JSONDecodeError as e: + logging.error(f"Failed to parse JSON from response in {method_name}: {e}") # Check if the server requires a newer client version. if response.status_code == 426: diff --git a/tabpfn_client/tests/unit/test_client.py b/tabpfn_client/tests/unit/test_client.py index 9c14318..0f21738 100644 --- a/tabpfn_client/tests/unit/test_client.py +++ b/tabpfn_client/tests/unit/test_client.py @@ -29,7 +29,7 @@ def test_try_connection_with_invalid_server(self, mock_server): self.assertFalse(self.client.try_connection()) @with_mock_server() - def test_try_connection_with_outdated_client(self, mock_server): + def test_try_connection_with_outdated_client_raises_runtime_error(self, mock_server): mock_server.router.get(mock_server.endpoints.root.path).respond( 426, json={"detail": "Client version too old. ..."}) with self.assertRaises(RuntimeError) as cm: