From 069ad267bd680037340dc2c4ec5ee7e38c7154d3 Mon Sep 17 00:00:00 2001 From: QianZhu Date: Fri, 9 Feb 2024 10:07:47 -0800 Subject: [PATCH] added error msg to SaaS APIs (#852) 1. improved error msg for SaaS create_table and create_index --------- Co-authored-by: Chang She <759245+changhiskhan@users.noreply.github.com> --- python/lancedb/remote/db.py | 7 +++++-- python/lancedb/remote/table.py | 37 +++++++++++++++++++++++++++++----- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/python/lancedb/remote/db.py b/python/lancedb/remote/db.py index 2b84f6c2..0c0bd46a 100644 --- a/python/lancedb/remote/db.py +++ b/python/lancedb/remote/db.py @@ -118,6 +118,7 @@ class RemoteDBConnection(DBConnection): schema: Optional[Union[pa.Schema, LanceModel]] = None, on_bad_vectors: str = "error", fill_value: float = 0.0, + mode: Optional[str] = None, embedding_functions: Optional[List[EmbeddingFunctionConfig]] = None, ) -> Table: """Create a [Table][lancedb.table.Table] in the database. @@ -215,11 +216,13 @@ class RemoteDBConnection(DBConnection): if data is None and schema is None: raise ValueError("Either data or schema must be provided.") if embedding_functions is not None: - raise NotImplementedError( - "embedding_functions is not supported for remote databases." + logging.warning( + "embedding_functions is not yet supported on LanceDB Cloud." "Please vote https://github.com/lancedb/lancedb/issues/626 " "for this feature." ) + if mode is not None: + logging.warning("mode is not yet supported on LanceDB Cloud.") if inspect.isclass(schema) and issubclass(schema, LanceModel): # convert LanceModel to pyarrow schema diff --git a/python/lancedb/remote/table.py b/python/lancedb/remote/table.py index d298ec1b..341837b3 100644 --- a/python/lancedb/remote/table.py +++ b/python/lancedb/remote/table.py @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import logging import uuid from functools import cached_property from typing import Dict, Optional, Union @@ -57,17 +58,17 @@ class RemoteTable(Table): return resp["version"] def to_arrow(self) -> pa.Table: - """to_arrow() is not supported on the LanceDB cloud""" - raise NotImplementedError("to_arrow() is not supported on the LanceDB cloud") + """to_arrow() is not yet supported on LanceDB cloud.""" + raise NotImplementedError("to_arrow() is not yet supported on LanceDB cloud.") def to_pandas(self): - """to_pandas() is not supported on the LanceDB cloud""" - return NotImplementedError("to_pandas() is not supported on the LanceDB cloud") + """to_pandas() is not yet supported on LanceDB cloud.""" + return NotImplementedError("to_pandas() is not yet supported on LanceDB cloud.") def create_scalar_index(self, *args, **kwargs): """Creates a scalar index""" return NotImplementedError( - "create_scalar_index() is not supported on the LanceDB cloud" + "create_scalar_index() is not yet supported on LanceDB cloud." ) def create_index( @@ -75,6 +76,10 @@ class RemoteTable(Table): metric="L2", vector_column_name: str = VECTOR_COLUMN_NAME, index_cache_size: Optional[int] = None, + num_partitions: Optional[int] = None, + num_sub_vectors: Optional[int] = None, + replace: Optional[bool] = None, + accelerator: Optional[str] = None, ): """Create an index on the table. Currently, the only parameters that matter are @@ -108,6 +113,28 @@ class RemoteTable(Table): ... ) >>> table.create_index("L2", "vector") # doctest: +SKIP """ + + if num_partitions is not None: + logging.warning( + "num_partitions is not supported on LanceDB cloud." + "This parameter will be tuned automatically." + ) + if num_sub_vectors is not None: + logging.warning( + "num_sub_vectors is not supported on LanceDB cloud." + "This parameter will be tuned automatically." + ) + if accelerator is not None: + logging.warning( + "GPU accelerator is not yet supported on LanceDB cloud." + "If you have 100M+ vectors to index," + "please contact us at contact@lancedb.com" + ) + if replace is not None: + logging.warning( + "replace is not supported on LanceDB cloud." + "Existing indexes will always be replaced." + ) index_type = "vector" data = {