From 0aa4d607cf145d0c7fb6bd79a826817db2c82360 Mon Sep 17 00:00:00 2001 From: Harutaka Kawamura Date: Fri, 6 Dec 2024 09:22:40 +0900 Subject: [PATCH] Remove regex validation for `index_name` (#44) * Remove validation for index_name * Remove re * Update test_vectorstore.py * Update test_vectorstore.py --- libs/databricks/langchain_databricks/vectorstores.py | 8 +++----- libs/databricks/tests/unit_tests/test_vectorstore.py | 4 +--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/libs/databricks/langchain_databricks/vectorstores.py b/libs/databricks/langchain_databricks/vectorstores.py index 36cbe48..1e2aa0a 100644 --- a/libs/databricks/langchain_databricks/vectorstores.py +++ b/libs/databricks/langchain_databricks/vectorstores.py @@ -3,7 +3,6 @@ import asyncio import json import logging -import re import uuid from enum import Enum from functools import partial @@ -37,7 +36,6 @@ class IndexType(str, Enum): _NON_MANAGED_EMB_ONLY_MSG = ( "`%s` is not supported for index with Databricks-managed embeddings." ) -_INDEX_NAME_PATTERN = re.compile(r"^[a-zA-Z0-9_]+\.[a-zA-Z0-9_]+\.[a-zA-Z0-9_]+$") class DatabricksVectorSearch(VectorStore): @@ -217,10 +215,10 @@ def __init__( text_column: Optional[str] = None, columns: Optional[List[str]] = None, ): - if not (isinstance(index_name, str) and _INDEX_NAME_PATTERN.match(index_name)): + if not isinstance(index_name, str): raise ValueError( - "The `index_name` parameter must be a string in the format " - f"'catalog.schema.index'. Received: {index_name}" + "The `index_name` parameter must be a string, " + f"but got {type(index_name).__name__}." ) try: diff --git a/libs/databricks/tests/unit_tests/test_vectorstore.py b/libs/databricks/tests/unit_tests/test_vectorstore.py index 44c41e1..25411db 100644 --- a/libs/databricks/tests/unit_tests/test_vectorstore.py +++ b/libs/databricks/tests/unit_tests/test_vectorstore.py @@ -183,9 +183,7 @@ def test_init_with_endpoint_name() -> None: assert vectorsearch.index.describe() == INDEX_DETAILS[DELTA_SYNC_INDEX] -@pytest.mark.parametrize( - "index_name", [None, "invalid", 123, MagicMock(spec=VectorSearchIndex)] -) +@pytest.mark.parametrize("index_name", [None, 123, MagicMock(spec=VectorSearchIndex)]) def test_init_fail_invalid_index_name(index_name) -> None: with pytest.raises(ValueError, match="The `index_name` parameter must be"): DatabricksVectorSearch(index_name=index_name)