Skip to content

Commit ca48963

Browse files
tpvasconcelosadchia
authored andcommitted
fix: More explicit error messages (#2708)
Add more explicit error messages to validation checks in repo_config.py (for better pydantic error messages) Signed-off-by: Tomas Pereira de Vasconcelos <[email protected]>
1 parent 0ff79e5 commit ca48963

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

sdk/python/feast/errors.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ def __init__(
197197
)
198198

199199

200+
class FeastOfflineStoreInvalidName(Exception):
201+
def __init__(self, offline_store_class_name: str):
202+
super().__init__(
203+
f"Offline Store Class '{offline_store_class_name}' should end with the string `OfflineStore`.'"
204+
)
205+
206+
200207
class FeastOnlineStoreInvalidName(Exception):
201208
def __init__(self, online_store_class_name: str):
202209
super().__init__(

sdk/python/feast/repo_config.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from feast.errors import (
2222
FeastFeatureServerTypeInvalidError,
2323
FeastFeatureServerTypeSetError,
24+
FeastOfflineStoreInvalidName,
25+
FeastOnlineStoreInvalidName,
2426
FeastProviderNotSetError,
2527
)
2628
from feast.importer import import_class
@@ -278,7 +280,8 @@ def _validate_online_store_config(cls, values):
278280
return values
279281

280282
# Make sure that the provider configuration is set. We need it to set the defaults
281-
assert "provider" in values
283+
if "provider" not in values:
284+
raise FeastProviderNotSetError()
282285

283286
# Set the default type
284287
# This is only direct reference to a provider or online store that we should have
@@ -315,7 +318,8 @@ def _validate_offline_store_config(cls, values):
315318
return values
316319

317320
# Make sure that the provider configuration is set. We need it to set the defaults
318-
assert "provider" in values
321+
if "provider" not in values:
322+
raise FeastProviderNotSetError()
319323

320324
# Set the default type
321325
if "type" not in values["offline_store"]:
@@ -455,8 +459,8 @@ def get_batch_engine_config_from_type(batch_engine_type: str):
455459
def get_online_config_from_type(online_store_type: str):
456460
if online_store_type in ONLINE_STORE_CLASS_FOR_TYPE:
457461
online_store_type = ONLINE_STORE_CLASS_FOR_TYPE[online_store_type]
458-
else:
459-
assert online_store_type.endswith("OnlineStore")
462+
elif not online_store_type.endswith("OnlineStore"):
463+
raise FeastOnlineStoreInvalidName(online_store_type)
460464
module_name, online_store_class_type = online_store_type.rsplit(".", 1)
461465
config_class_name = f"{online_store_class_type}Config"
462466

@@ -466,8 +470,8 @@ def get_online_config_from_type(online_store_type: str):
466470
def get_offline_config_from_type(offline_store_type: str):
467471
if offline_store_type in OFFLINE_STORE_CLASS_FOR_TYPE:
468472
offline_store_type = OFFLINE_STORE_CLASS_FOR_TYPE[offline_store_type]
469-
else:
470-
assert offline_store_type.endswith("OfflineStore")
473+
elif not offline_store_type.endswith("OfflineStore"):
474+
raise FeastOfflineStoreInvalidName(offline_store_type)
471475
module_name, offline_store_class_type = offline_store_type.rsplit(".", 1)
472476
config_class_name = f"{offline_store_class_type}Config"
473477

0 commit comments

Comments
 (0)