1- import importlib
21from pathlib import Path
32from typing import Any
43
76from pydantic .error_wrappers import ErrorWrapper
87from pydantic .typing import Dict , Optional , Union
98
10- from feast import errors
9+ from feast . importer import get_class_from_type
1110from feast .telemetry import log_exceptions
1211
1312# These dict exists so that:
@@ -185,33 +184,6 @@ def __repr__(self) -> str:
185184 )
186185
187186
188- def get_config_class_from_type (
189- module_name : str , config_class_name : str , store_type : str
190- ):
191- if not config_class_name .endswith (f"{ store_type } Config" ):
192- raise errors .FeastStoreConfigInvalidName (config_class_name , store_type )
193-
194- # Try importing the module that contains the custom provider
195- try :
196- module = importlib .import_module (module_name )
197- except Exception as e :
198- # The original exception can be anything - either module not found,
199- # or any other kind of error happening during the module import time.
200- # So we should include the original error as well in the stack trace.
201- raise errors .FeastModuleImportError (module_name , store_type ) from e
202-
203- # Try getting the provider class definition
204- try :
205- online_store_config_class = getattr (module , config_class_name )
206- except AttributeError :
207- # This can only be one type of error, when class_name attribute does not exist in the module
208- # So we don't have to include the original exception here
209- raise errors .FeastClassImportError (
210- module_name , config_class_name , class_type = f"{ store_type } Config"
211- ) from None
212- return online_store_config_class
213-
214-
215187def get_online_config_from_type (online_store_type : str ):
216188 if online_store_type in ONLINE_STORE_CLASS_FOR_TYPE :
217189 online_store_type = ONLINE_STORE_CLASS_FOR_TYPE [online_store_type ]
@@ -220,7 +192,7 @@ def get_online_config_from_type(online_store_type: str):
220192 module_name , online_store_class_type = online_store_type .rsplit ("." , 1 )
221193 config_class_name = f"{ online_store_class_type } Config"
222194
223- return get_config_class_from_type (module_name , config_class_name , "OnlineStore" )
195+ return get_class_from_type (module_name , config_class_name , config_class_name )
224196
225197
226198def get_offline_config_from_type (offline_store_type : str ):
@@ -231,7 +203,7 @@ def get_offline_config_from_type(offline_store_type: str):
231203 module_name , offline_store_class_type = offline_store_type .rsplit ("." , 1 )
232204 config_class_name = f"{ offline_store_class_type } Config"
233205
234- return get_config_class_from_type (module_name , config_class_name , "OfflineStore" )
206+ return get_class_from_type (module_name , config_class_name , config_class_name )
235207
236208
237209def load_repo_config (repo_path : Path ) -> RepoConfig :
0 commit comments