Skip to content

Commit 39be498

Browse files
committed
Remove create_repo_config in favor of __init__
Signed-off-by: Achal Shah <achals@gmail.com>
1 parent 1060170 commit 39be498

3 files changed

Lines changed: 16 additions & 18 deletions

File tree

‎sdk/python/feast/repo_config.py‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,13 @@ class RepoConfig(FeastBaseModel):
9292

9393
repo_path: Optional[Path] = None
9494

95+
def __init__(self, **data: Any):
96+
super().__init__(**data)
97+
if isinstance(self.online_store, Dict):
98+
self.online_store = get_online_config_from_type(self.online_store["type"])(
99+
**self.online_store
100+
)
101+
95102
def get_registry_config(self):
96103
if isinstance(self.registry, str):
97104
return RegistryConfig(path=self.registry)
@@ -198,15 +205,6 @@ def __repr__(self) -> str:
198205
)
199206

200207

201-
def create_repo_config(**data) -> RepoConfig:
202-
rc = RepoConfig(**data)
203-
if isinstance(rc.online_store, Dict):
204-
rc.online_store = get_online_config_from_type(rc.online_store["type"])(
205-
**rc.online_store
206-
)
207-
return rc
208-
209-
210208
def get_online_config_from_type(online_store_type: str):
211209
if online_store_type in ONLINE_CONFIG_CLASS_FOR_TYPE:
212210
online_store_type = ONLINE_CONFIG_CLASS_FOR_TYPE[online_store_type]
@@ -245,7 +243,7 @@ def load_repo_config(repo_path: Path) -> RepoConfig:
245243
with open(config_path) as f:
246244
raw_config = yaml.safe_load(f)
247245
try:
248-
c = create_repo_config(**raw_config)
246+
c = RepoConfig(**raw_config)
249247
c.repo_path = repo_path
250248
return c
251249
except ValidationError as e:

‎sdk/python/tests/test_feature_store.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from feast.feature_view import FeatureView
2727
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
2828
from feast.protos.feast.types import Value_pb2 as ValueProto
29-
from feast.repo_config import RepoConfig, create_repo_config
29+
from feast.repo_config import RepoConfig
3030
from feast.value_type import ValueType
3131
from tests.utils.data_source_utils import (
3232
prep_file_source,
@@ -64,7 +64,7 @@ def feature_store_with_gcs_registry():
6464
bucket.blob("registry.db")
6565

6666
return FeatureStore(
67-
config=create_repo_config(
67+
config=RepoConfig(
6868
registry=f"gs://{bucket_name}/registry.db",
6969
project="default",
7070
provider="gcp",

‎sdk/python/tests/test_historical_retrieval.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
from pytz import utc
1515

1616
import feast.driver_test_data as driver_data
17-
from feast import errors, utils
17+
from feast import errors, utils, RepoConfig
1818
from feast.data_source import BigQuerySource, FileSource
1919
from feast.entity import Entity
2020
from feast.feature import Feature
2121
from feast.feature_store import FeatureStore
2222
from feast.feature_view import FeatureView
2323
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
2424
from feast.infra.provider import DEFAULT_ENTITY_DF_EVENT_TIMESTAMP_COL
25-
from feast.repo_config import BigQueryOfflineStoreConfig, create_repo_config
25+
from feast.repo_config import BigQueryOfflineStoreConfig
2626
from feast.value_type import ValueType
2727

2828
np.random.seed(0)
@@ -270,7 +270,7 @@ def test_historical_features_from_parquet_sources(infer_event_timestamp_col):
270270
customer = Entity(name="customer_id", value_type=ValueType.INT64)
271271

272272
store = FeatureStore(
273-
config=create_repo_config(
273+
config=RepoConfig(
274274
registry=os.path.join(temp_dir, "registry.db"),
275275
project="default",
276276
provider="local",
@@ -375,7 +375,7 @@ def test_historical_features_from_bigquery_sources(
375375

376376
if provider_type == "local":
377377
store = FeatureStore(
378-
config=create_repo_config(
378+
config=RepoConfig(
379379
registry=os.path.join(temp_dir, "registry.db"),
380380
project="default",
381381
provider="local",
@@ -389,7 +389,7 @@ def test_historical_features_from_bigquery_sources(
389389
)
390390
elif provider_type == "gcp":
391391
store = FeatureStore(
392-
config=create_repo_config(
392+
config=RepoConfig(
393393
registry=os.path.join(temp_dir, "registry.db"),
394394
project="".join(
395395
random.choices(string.ascii_uppercase + string.digits, k=10)
@@ -402,7 +402,7 @@ def test_historical_features_from_bigquery_sources(
402402
)
403403
elif provider_type == "gcp_custom_offline_config":
404404
store = FeatureStore(
405-
config=create_repo_config(
405+
config=RepoConfig(
406406
registry=os.path.join(temp_dir, "registry.db"),
407407
project="".join(
408408
random.choices(string.ascii_uppercase + string.digits, k=10)

0 commit comments

Comments
 (0)