-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feast_usage
- Loading branch information
Showing
13 changed files
with
152 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import importlib | ||
|
||
from feast import errors | ||
|
||
|
||
def get_class_from_type(module_name: str, class_name: str, class_type: str): | ||
if not class_name.endswith(class_type): | ||
raise errors.FeastClassInvalidName(class_name, class_type) | ||
|
||
# Try importing the module that contains the custom provider | ||
try: | ||
module = importlib.import_module(module_name) | ||
except Exception as e: | ||
# The original exception can be anything - either module not found, | ||
# or any other kind of error happening during the module import time. | ||
# So we should include the original error as well in the stack trace. | ||
raise errors.FeastModuleImportError(module_name, class_type) from e | ||
|
||
# Try getting the provider class definition | ||
try: | ||
_class = getattr(module, class_name) | ||
except AttributeError: | ||
# This can only be one type of error, when class_name attribute does not exist in the module | ||
# So we don't have to include the original exception here | ||
raise errors.FeastClassImportError( | ||
module_name, class_name, class_type=class_type | ||
) from None | ||
return _class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,31 @@ | ||
from feast.data_source import BigQuerySource, DataSource, FileSource | ||
from feast.errors import FeastOfflineStoreUnsupportedDataSource | ||
import importlib | ||
from typing import Any | ||
|
||
from feast import errors | ||
from feast.infra.offline_stores.offline_store import OfflineStore | ||
from feast.repo_config import ( | ||
BigQueryOfflineStoreConfig, | ||
FileOfflineStoreConfig, | ||
OfflineStoreConfig, | ||
) | ||
|
||
|
||
def get_offline_store_from_config( | ||
offline_store_config: OfflineStoreConfig, | ||
) -> OfflineStore: | ||
def get_offline_store_from_config(offline_store_config: Any,) -> OfflineStore: | ||
"""Get the offline store from offline store config""" | ||
|
||
if isinstance(offline_store_config, FileOfflineStoreConfig): | ||
from feast.infra.offline_stores.file import FileOfflineStore | ||
|
||
return FileOfflineStore() | ||
elif isinstance(offline_store_config, BigQueryOfflineStoreConfig): | ||
from feast.infra.offline_stores.bigquery import BigQueryOfflineStore | ||
|
||
return BigQueryOfflineStore() | ||
|
||
raise ValueError(f"Unsupported offline store config '{offline_store_config}'") | ||
|
||
|
||
def assert_offline_store_supports_data_source( | ||
offline_store_config: OfflineStoreConfig, data_source: DataSource | ||
): | ||
if ( | ||
isinstance(offline_store_config, FileOfflineStoreConfig) | ||
and isinstance(data_source, FileSource) | ||
) or ( | ||
isinstance(offline_store_config, BigQueryOfflineStoreConfig) | ||
and isinstance(data_source, BigQuerySource) | ||
): | ||
return | ||
raise FeastOfflineStoreUnsupportedDataSource( | ||
offline_store_config.type, data_source.__class__.__name__ | ||
) | ||
module_name = offline_store_config.__module__ | ||
qualified_name = type(offline_store_config).__name__ | ||
store_class_name = qualified_name.replace("Config", "") | ||
try: | ||
module = importlib.import_module(module_name) | ||
except Exception as e: | ||
# The original exception can be anything - either module not found, | ||
# or any other kind of error happening during the module import time. | ||
# So we should include the original error as well in the stack trace. | ||
raise errors.FeastModuleImportError(module_name, "OfflineStore") from e | ||
|
||
# Try getting the provider class definition | ||
try: | ||
offline_store_class = getattr(module, store_class_name) | ||
except AttributeError: | ||
# This can only be one type of error, when class_name attribute does not exist in the module | ||
# So we don't have to include the original exception here | ||
raise errors.FeastClassImportError( | ||
module_name, store_class_name, class_type="OfflineStore" | ||
) from None | ||
return offline_store_class() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.