From c2214a8bdc62084a6138ea7e8868884a9afd54a0 Mon Sep 17 00:00:00 2001 From: harupy <17039389+harupy@users.noreply.github.com> Date: Sat, 5 Apr 2025 11:37:47 +0900 Subject: [PATCH 1/2] Remove regex validation for index_name Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> --- .../langchain/src/databricks_langchain/vectorstores.py | 6 ++---- .../langchain/tests/unit_tests/test_vectorstores.py | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/integrations/langchain/src/databricks_langchain/vectorstores.py b/integrations/langchain/src/databricks_langchain/vectorstores.py index 48c01553..ec68c650 100644 --- a/integrations/langchain/src/databricks_langchain/vectorstores.py +++ b/integrations/langchain/src/databricks_langchain/vectorstores.py @@ -35,7 +35,6 @@ _DIRECT_ACCESS_ONLY_MSG = "`%s` is only supported for direct-access index." _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): @@ -227,10 +226,9 @@ def __init__( workspace_client: Optional[WorkspaceClient] = None, client_args: Optional[Dict[str, Any]] = 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}" + f"The `index_name` parameter must be a string, but got {type(index_name).__name__}." ) try: diff --git a/integrations/langchain/tests/unit_tests/test_vectorstores.py b/integrations/langchain/tests/unit_tests/test_vectorstores.py index 7aab6b45..dd92be1f 100644 --- a/integrations/langchain/tests/unit_tests/test_vectorstores.py +++ b/integrations/langchain/tests/unit_tests/test_vectorstores.py @@ -52,7 +52,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) From 9695c6d6be8a486e48ae98aa1c820925a6b2f880 Mon Sep 17 00:00:00 2001 From: harupy <17039389+harupy@users.noreply.github.com> Date: Sat, 5 Apr 2025 11:41:44 +0900 Subject: [PATCH 2/2] Remove re Signed-off-by: harupy <17039389+harupy@users.noreply.github.com> --- integrations/langchain/src/databricks_langchain/vectorstores.py | 1 - 1 file changed, 1 deletion(-) diff --git a/integrations/langchain/src/databricks_langchain/vectorstores.py b/integrations/langchain/src/databricks_langchain/vectorstores.py index ec68c650..ae24f7b4 100644 --- a/integrations/langchain/src/databricks_langchain/vectorstores.py +++ b/integrations/langchain/src/databricks_langchain/vectorstores.py @@ -2,7 +2,6 @@ import asyncio import logging -import re import uuid from functools import partial from typing import (