Skip to content

Commit

Permalink
fix: More explicit error messages (#2708)
Browse files Browse the repository at this point in the history
Add more explicit error messages to validation checks in repo_config.py (for better pydantic error messages)

Signed-off-by: Tomas Pereira de Vasconcelos <tomasvasconcelos1@gmail.com>
  • Loading branch information
tpvasconcelos authored and adchia committed Aug 10, 2022
1 parent 0ff79e5 commit ca48963
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 7 additions & 0 deletions sdk/python/feast/errors.py
Expand Up @@ -197,6 +197,13 @@ def __init__(
)


class FeastOfflineStoreInvalidName(Exception):
def __init__(self, offline_store_class_name: str):
super().__init__(
f"Offline Store Class '{offline_store_class_name}' should end with the string `OfflineStore`.'"
)


class FeastOnlineStoreInvalidName(Exception):
def __init__(self, online_store_class_name: str):
super().__init__(
Expand Down
16 changes: 10 additions & 6 deletions sdk/python/feast/repo_config.py
Expand Up @@ -21,6 +21,8 @@
from feast.errors import (
FeastFeatureServerTypeInvalidError,
FeastFeatureServerTypeSetError,
FeastOfflineStoreInvalidName,
FeastOnlineStoreInvalidName,
FeastProviderNotSetError,
)
from feast.importer import import_class
Expand Down Expand Up @@ -278,7 +280,8 @@ def _validate_online_store_config(cls, values):
return values

# Make sure that the provider configuration is set. We need it to set the defaults
assert "provider" in values
if "provider" not in values:
raise FeastProviderNotSetError()

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

# Make sure that the provider configuration is set. We need it to set the defaults
assert "provider" in values
if "provider" not in values:
raise FeastProviderNotSetError()

# Set the default type
if "type" not in values["offline_store"]:
Expand Down Expand Up @@ -455,8 +459,8 @@ def get_batch_engine_config_from_type(batch_engine_type: str):
def get_online_config_from_type(online_store_type: str):
if online_store_type in ONLINE_STORE_CLASS_FOR_TYPE:
online_store_type = ONLINE_STORE_CLASS_FOR_TYPE[online_store_type]
else:
assert online_store_type.endswith("OnlineStore")
elif not online_store_type.endswith("OnlineStore"):
raise FeastOnlineStoreInvalidName(online_store_type)
module_name, online_store_class_type = online_store_type.rsplit(".", 1)
config_class_name = f"{online_store_class_type}Config"

Expand All @@ -466,8 +470,8 @@ def get_online_config_from_type(online_store_type: str):
def get_offline_config_from_type(offline_store_type: str):
if offline_store_type in OFFLINE_STORE_CLASS_FOR_TYPE:
offline_store_type = OFFLINE_STORE_CLASS_FOR_TYPE[offline_store_type]
else:
assert offline_store_type.endswith("OfflineStore")
elif not offline_store_type.endswith("OfflineStore"):
raise FeastOfflineStoreInvalidName(offline_store_type)
module_name, offline_store_class_type = offline_store_type.rsplit(".", 1)
config_class_name = f"{offline_store_class_type}Config"

Expand Down

0 comments on commit ca48963

Please sign in to comment.