Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: More explicit error messages #2708

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions sdk/python/feast/errors.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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