From 9eca8e7cd18338be7fd1e13bbb64458aba93cf97 Mon Sep 17 00:00:00 2001 From: Chang She <759245+changhiskhan@users.noreply.github.com> Date: Thu, 21 Dec 2023 20:13:08 -0800 Subject: [PATCH] tests pass; still need catalog --- python/lancedb/table.py | 6 +++++- python/tests/test_fts.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/python/lancedb/table.py b/python/lancedb/table.py index 6684f6d7..f0c8107a 100644 --- a/python/lancedb/table.py +++ b/python/lancedb/table.py @@ -595,7 +595,11 @@ class LanceTable(Table): raise ValueError( f"Index already exists. Use replace=True to overwrite." ) - fs.delete_dir(path) + try: + fs.delete_dir(path) + except FileNotFoundError as e: + if "Cannot get information for path" in str(e): + pass index = create_index(self._get_fts_index_path(), field_names) populate_index(index, self, field_names) diff --git a/python/tests/test_fts.py b/python/tests/test_fts.py index 2a61f3ca..51a6c641 100644 --- a/python/tests/test_fts.py +++ b/python/tests/test_fts.py @@ -95,12 +95,12 @@ def test_create_index_from_table(tmp_path, table): ] ) - with pytest.raises(ValueError, match="already exists"): - table.create_fts_index("text") - table.create_fts_index("text", replace=True) assert len(table.search("gorilla").limit(1).to_pandas()) == 1 + with pytest.raises(ValueError, match="already exists"): + table.create_fts_index("text") + def test_create_index_multiple_columns(tmp_path, table): table.create_fts_index(["text", "text2"])