def get_online_store_from_config(online_store_config: Any) -> OnlineStore: """Creates an online store corresponding to the given online store config.""" module_name = online_store_config.__module__ qualified_name = type(online_store_config).__name__ class_name = qualified_name.replace("Config", "") online_store_class = import_class(module_name, class_name, "OnlineStore") return online_store_class()
def get_feature_server_config_from_type(feature_server_type: str): # We do not support custom feature servers right now. if feature_server_type not in FEATURE_SERVER_CONFIG_CLASS_FOR_TYPE: raise FeastFeatureServerTypeInvalidError(feature_server_type) feature_server_type = FEATURE_SERVER_CONFIG_CLASS_FOR_TYPE[ feature_server_type] module_name, config_class_name = feature_server_type.rsplit(".", 1) return import_class(module_name, config_class_name, config_class_name)
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") module_name, offline_store_class_type = offline_store_type.rsplit(".", 1) config_class_name = f"{offline_store_class_type}Config" return import_class(module_name, config_class_name, config_class_name)
def get_registry_store_class_from_type(registry_store_type: str): if not registry_store_type.endswith("RegistryStore"): raise Exception( 'Registry store class name should end with "RegistryStore"') if registry_store_type in REGISTRY_STORE_CLASS_FOR_TYPE: registry_store_type = REGISTRY_STORE_CLASS_FOR_TYPE[ registry_store_type] module_name, registry_store_class_name = registry_store_type.rsplit(".", 1) return import_class(module_name, registry_store_class_name, "RegistryStore")
def get_provider(config: RepoConfig, repo_path: Path) -> Provider: if "." not in config.provider: if config.provider not in PROVIDERS_CLASS_FOR_TYPE: raise errors.FeastProviderNotImplementedError(config.provider) provider = PROVIDERS_CLASS_FOR_TYPE[config.provider] else: provider = config.provider # Split provider into module and class names by finding the right-most dot. # For example, provider 'foo.bar.MyProvider' will be parsed into 'foo.bar' and 'MyProvider' module_name, class_name = provider.rsplit(".", 1) cls = import_class(module_name, class_name, "Provider") return cls(config)
def get_data_source_class_from_type(data_source_type: str): module_name, config_class_name = data_source_type.rsplit(".", 1) return import_class(module_name, config_class_name, "DataSource")
def _get_infra_object_class_from_type(infra_object_class_type: str): module_name, infra_object_class_name = infra_object_class_type.rsplit( ".", 1) return import_class(module_name, infra_object_class_name)