Skip to content

Commit a5c330e

Browse files
authored
Allow strings for online/offline store instead of dicts (feast-dev#1673)
Signed-off-by: Achal Shah <[email protected]>
1 parent fc2a035 commit a5c330e

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

sdk/python/feast/repo_config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,15 @@ def __init__(self, **data: Any):
8383
self.online_store = get_online_config_from_type(self.online_store["type"])(
8484
**self.online_store
8585
)
86+
elif isinstance(self.online_store, str):
87+
self.online_store = get_online_config_from_type(self.online_store)()
88+
8689
if isinstance(self.offline_store, Dict):
8790
self.offline_store = get_offline_config_from_type(
8891
self.offline_store["type"]
8992
)(**self.offline_store)
93+
elif isinstance(self.offline_store, str):
94+
self.offline_store = get_offline_config_from_type(self.offline_store)()
9095

9196
def get_registry_config(self):
9297
if isinstance(self.registry, str):

sdk/python/tests/test_repo_config.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from textwrap import dedent
44
from typing import Optional
55

6+
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
67
from feast.repo_config import FeastConfigError, load_repo_config
78

89

@@ -18,8 +19,9 @@ def _test_config(config_text, expect_error: Optional[str]):
1819

1920
repo_config.write_text(config_text)
2021
error = None
22+
rc = None
2123
try:
22-
load_repo_config(repo_path)
24+
rc = load_repo_config(repo_path)
2325
except FeastConfigError as e:
2426
error = e
2527

@@ -29,6 +31,8 @@ def _test_config(config_text, expect_error: Optional[str]):
2931
print(f"error: {error}")
3032
assert error is None
3133

34+
return rc
35+
3236

3337
def test_local_config():
3438
_test_config(
@@ -44,7 +48,7 @@ def test_local_config():
4448

4549

4650
def test_local_config_with_full_online_class():
47-
_test_config(
51+
c = _test_config(
4852
dedent(
4953
"""
5054
project: foo
@@ -56,6 +60,22 @@ def test_local_config_with_full_online_class():
5660
),
5761
expect_error=None,
5862
)
63+
assert isinstance(c.online_store, SqliteOnlineStoreConfig)
64+
65+
66+
def test_local_config_with_full_online_class_directly():
67+
c = _test_config(
68+
dedent(
69+
"""
70+
project: foo
71+
registry: "registry.db"
72+
provider: local
73+
online_store: feast.infra.online_stores.sqlite.SqliteOnlineStore
74+
"""
75+
),
76+
expect_error=None,
77+
)
78+
assert isinstance(c.online_store, SqliteOnlineStoreConfig)
5979

6080

6181
def test_gcp_config():

0 commit comments

Comments
 (0)