-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Refactor OfflineStoreConfig classes into their owning modules #1657
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c642b42
Refactor OfflineStoreConfig classes into their owning modules
achals ec876d6
Fix error string
achals 2030e47
Generic error class
achals c94ae83
Merge conflicts
achals fa5f912
make the store type work, and add a test that uses the fully qualifie…
achals 0b3d14c
Address comments from previous PR
achals df59a5d
CR updates
achals File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Refactor OfflineStoreConfig classes into their owning modules
Signed-off-by: Achal Shah <achals@gmail.com>
- Loading branch information
commit c642b4280d4dd2387a84a91dde6b756a0f41070c
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,33 @@ | ||
| 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, module_type="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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to set a default here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, going to clean this up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, should
online_store_config_class_namebe online store agnostic?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done