From 6eb662de9b2f329ce3542f384e7e601b9814a67e Mon Sep 17 00:00:00 2001 From: Bert Date: Fri, 24 Nov 2023 19:28:33 -0500 Subject: [PATCH] fix: python remote correct open_table error message (#659) --- python/lancedb/remote/db.py | 12 +++++++----- python/tests/test_remote_db.py | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/python/lancedb/remote/db.py b/python/lancedb/remote/db.py index 2c53f21f..855ebf50 100644 --- a/python/lancedb/remote/db.py +++ b/python/lancedb/remote/db.py @@ -28,6 +28,7 @@ from ..pydantic import LanceModel from ..table import Table, _sanitize_data from .arrow import to_ipc_binary from .client import ARROW_STREAM_CONTENT_TYPE, RestfulLanceDBClient +from .errors import LanceDBClientError class RemoteDBConnection(DBConnection): @@ -101,11 +102,12 @@ class RemoteDBConnection(DBConnection): self._loop.run_until_complete( self._client.post(f"/v1/table/{name}/describe/") ) - except Exception: - logging.error( - "Table {name} does not exist." - "Please first call db.create_table({name}, data)" - ) + except LanceDBClientError as err: + if str(err).startswith("Not found"): + logging.error( + f"Table {name} does not exist. " + f"Please first call db.create_table({name}, data)" + ) return RemoteTable(self, name) @override diff --git a/python/tests/test_remote_db.py b/python/tests/test_remote_db.py index 592c5b7d..00ee8c43 100644 --- a/python/tests/test_remote_db.py +++ b/python/tests/test_remote_db.py @@ -26,6 +26,9 @@ class FakeLanceDBClient: t = pa.schema([]).empty_table() return VectorQueryResult(t) + async def post(self, path: str): + pass + def test_remote_db(): conn = lancedb.connect("db://client-will-be-injected", api_key="fake")