Beispiel #1
0
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 = importer.get_class_from_type(module_name, class_name, "Provider")

    return cls(config)
Beispiel #2
0
def get_provider(config: RepoConfig, repo_path: Path) -> Provider:
    if "." not in config.provider:
        if config.provider in {"gcp", "aws", "local"}:
            from feast.infra.passthrough_provider import PassthroughProvider

            return PassthroughProvider(config)
        else:
            raise errors.FeastProviderNotImplementedError(config.provider)
    else:
        # 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 = config.provider.rsplit(".", 1)

        cls = importer.get_class_from_type(module_name, class_name, "Provider")

        return cls(config)
Beispiel #3
0
def get_provider(config: RepoConfig, repo_path: Path) -> Provider:
    if "." not in config.provider:
        if config.provider == "gcp":
            from feast.infra.gcp import GcpProvider

            return GcpProvider(config)
        elif config.provider == "redis":
            from feast.infra.redis import RedisProvider

            return RedisProvider(config)
        elif config.provider == "local":
            from feast.infra.local import LocalProvider

            return LocalProvider(config, repo_path)
        else:
            raise errors.FeastProviderNotImplementedError(config.provider)
    else:
        # 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 = config.provider.rsplit(".", 1)

        # 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.FeastProviderModuleImportError(module_name) from e

        # Try getting the provider class definition
        try:
            ProviderCls = 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.FeastProviderClassImportError(
                module_name, class_name
            ) from None

        return ProviderCls(config, repo_path)
Beispiel #4
0
def get_provider(config: RepoConfig, repo_path: Path) -> Provider:
    if "." not in config.provider:
        if config.provider == "gcp":
            from feast.infra.gcp import GcpProvider

            return GcpProvider(config)
        elif config.provider == "aws":
            from feast.infra.aws import AwsProvider

            return AwsProvider(config)
        elif config.provider == "local":
            from feast.infra.local import LocalProvider

            return LocalProvider(config)
        else:
            raise errors.FeastProviderNotImplementedError(config.provider)
    else:
        # 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 = config.provider.rsplit(".", 1)

        cls = importer.get_class_from_type(module_name, class_name, "Provider")

        return cls(config, repo_path)