Skip to content

Commit 83c7ca8

Browse files
zabarnZach Barnett
andauthored
fix: Elasticsearch Feature Registration (#296)
* [EAPC-19839] fix: Elasticsearch Feature Registration * feat: update es test file with lazy_table_creation --------- Co-authored-by: Zach Barnett <[email protected]>
1 parent 2f4dd62 commit 83c7ca8

3 files changed

Lines changed: 26 additions & 16 deletions

File tree

sdk/python/feast/expediagroup/vectordb/elasticsearch_online_store.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ class ElasticsearchOnlineStoreConfig(FeastConfigBaseModel):
7171
password: str
7272
""" password to connect to Elasticsearch """
7373

74+
lazy_table_creation: Optional[bool] = False
75+
"""
76+
If True, tables will be created during materialization, rather than registration.
77+
Table deletion is not currently supported in this mode.
78+
"""
79+
7480

7581
class ElasticsearchConnectionManager:
7682
def __init__(self, online_config: RepoConfig):

sdk/python/feast/infra/online_stores/contrib/cassandra_online_store/cassandra_online_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class CassandraOnlineStoreConfig(FeastConfigBaseModel):
174174

175175
lazy_table_creation: Optional[bool] = False
176176
"""
177-
If True, tables will be created on during materialization, rather than registration.
177+
If True, tables will be created during materialization, rather than registration.
178178
Table deletion is not currently supported in this mode.
179179
"""
180180

sdk/python/tests/expediagroup/test_elasticsearch_online_store.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
4848
]
4949

5050

51-
@pytest.fixture(scope="session")
52-
def repo_config(embedded_elasticsearch):
51+
@pytest.fixture(scope="session", params=[False, True], ids=["normal", "lazy"])
52+
def repo_config(request, embedded_elasticsearch):
53+
"""Parametrized repo config with lazy_table_creation=False and True"""
5354
return RepoConfig(
5455
registry=REGISTRY,
5556
project=PROJECT,
@@ -58,6 +59,7 @@ def repo_config(embedded_elasticsearch):
5859
endpoint=f"http://{embedded_elasticsearch['host']}:{embedded_elasticsearch['port']}",
5960
username=embedded_elasticsearch["username"],
6061
password=embedded_elasticsearch["password"],
62+
lazy_table_creation=request.param, # This will be False, then True
6163
),
6264
offline_store=DaskOfflineStoreConfig(),
6365
entity_key_serialization_version=2,
@@ -75,24 +77,26 @@ def embedded_elasticsearch():
7577

7678

7779
class TestElasticsearchOnlineStore:
78-
index_to_write = "index_write"
79-
index_to_delete = "index_delete"
80-
index_to_read = "index_read"
81-
unavailable_index = "abc"
82-
8380
@pytest.fixture(autouse=True)
8481
def setup_method(self, repo_config):
82+
# Generate unique index names based on lazy_table_creation setting
83+
lazy_suffix = "_lazy" if repo_config.online_store.lazy_table_creation else ""
84+
self.index_to_write = f"index_write{lazy_suffix}"
85+
self.index_to_delete = f"index_delete{lazy_suffix}"
86+
self.index_to_read = f"index_read{lazy_suffix}"
87+
self.unavailable_index = f"abc{lazy_suffix}"
88+
8589
# Ensuring that the indexes created are dropped before the tests are run
8690
with ElasticsearchConnectionManager(repo_config.online_store) as es:
8791
# Dropping indexes if they exist
88-
if es.indices.exists(index=self.index_to_delete):
89-
es.indices.delete(index=self.index_to_delete)
90-
if es.indices.exists(index=self.index_to_write):
91-
es.indices.delete(index=self.index_to_write)
92-
if es.indices.exists(index=self.index_to_read):
93-
es.indices.delete(index=self.index_to_read)
94-
if es.indices.exists(index=self.unavailable_index):
95-
es.indices.delete(index=self.unavailable_index)
92+
for index in [
93+
self.index_to_delete,
94+
self.index_to_write,
95+
self.index_to_read,
96+
self.unavailable_index,
97+
]:
98+
if es.indices.exists(index=index):
99+
es.indices.delete(index=index)
96100

97101
yield
98102

0 commit comments

Comments
 (0)