Skip to content

Commit 93c1c15

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 139f2c4 commit 93c1c15

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
@@ -20,6 +20,8 @@
2020
from feast.errors import (
2121
FeastFeatureServerTypeInvalidError,
2222
FeastFeatureServerTypeSetError,
23+
FeastOfflineStoreInvalidName,
24+
FeastOnlineStoreInvalidName,
2325
FeastProviderNotSetError,
2426
)
2527
from feast.importer import import_class
@@ -217,7 +219,8 @@ def _validate_online_store_config(cls, values):
217219
return values
218220

219221
# Make sure that the provider configuration is set. We need it to set the defaults
220-
assert "provider" in values
222+
if "provider" not in values:
223+
raise FeastProviderNotSetError()
221224

222225
# Set the default type
223226
# This is only direct reference to a provider or online store that we should have
@@ -253,7 +256,8 @@ def _validate_offline_store_config(cls, values):
253256
return values
254257

255258
# Make sure that the provider configuration is set. We need it to set the defaults
256-
assert "provider" in values
259+
if "provider" not in values:
260+
raise FeastProviderNotSetError()
257261

258262
# Set the default type
259263
if "type" not in values["offline_store"]:
@@ -375,8 +379,8 @@ def get_data_source_class_from_type(data_source_type: str):
375379
def get_online_config_from_type(online_store_type: str):
376380
if online_store_type in ONLINE_STORE_CLASS_FOR_TYPE:
377381
online_store_type = ONLINE_STORE_CLASS_FOR_TYPE[online_store_type]
378-
else:
379-
assert online_store_type.endswith("OnlineStore")
382+
elif not online_store_type.endswith("OnlineStore"):
383+
raise FeastOnlineStoreInvalidName(online_store_type)
380384
module_name, online_store_class_type = online_store_type.rsplit(".", 1)
381385
config_class_name = f"{online_store_class_type}Config"
382386

@@ -386,8 +390,8 @@ def get_online_config_from_type(online_store_type: str):
386390
def get_offline_config_from_type(offline_store_type: str):
387391
if offline_store_type in OFFLINE_STORE_CLASS_FOR_TYPE:
388392
offline_store_type = OFFLINE_STORE_CLASS_FOR_TYPE[offline_store_type]
389-
else:
390-
assert offline_store_type.endswith("OfflineStore")
393+
elif not offline_store_type.endswith("OfflineStore"):
394+
raise FeastOfflineStoreInvalidName(offline_store_type)
391395
module_name, offline_store_class_type = offline_store_type.rsplit(".", 1)
392396
config_class_name = f"{offline_store_class_type}Config"
393397

0 commit comments

Comments
 (0)