Skip to content

Commit

Permalink
Make serverless alpha feature (#1928)
Browse files Browse the repository at this point in the history
* Hide AWS Lambda feature server behind experimental flag

Signed-off-by: Felix Wang <wangfelix98@gmail.com>

* Ensure that registry is on S3 for AWS Lambda feature server

Signed-off-by: Felix Wang <wangfelix98@gmail.com>
  • Loading branch information
felixwang9817 authored Oct 7, 2021
1 parent a0918bf commit d0778f7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
7 changes: 7 additions & 0 deletions sdk/python/feast/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,10 @@ def __init__(self, resource_name: str):
super().__init__(
f"The AWS API Gateway {resource_name} should have been created properly, but does not exist."
)


class IncompatibleRegistryStoreClass(Exception):
def __init__(self, actual_class: str, expected_class: str):
super().__init__(
f"The registry store class was expected to be {expected_class}, but was instead {actual_class}."
)
2 changes: 2 additions & 0 deletions sdk/python/feast/flags.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
FLAG_ALPHA_FEATURES_NAME = "alpha_features"
FLAG_ON_DEMAND_TRANSFORM_NAME = "on_demand_transforms"
FLAG_PYTHON_FEATURE_SERVER_NAME = "python_feature_server"
FLAG_AWS_LAMBDA_FEATURE_SERVER_NAME = "aws_lambda_feature_server"
ENV_FLAG_IS_TEST = "IS_TEST"

FLAG_NAMES = {
FLAG_ALPHA_FEATURES_NAME,
FLAG_ON_DEMAND_TRANSFORM_NAME,
FLAG_PYTHON_FEATURE_SERVER_NAME,
FLAG_AWS_LAMBDA_FEATURE_SERVER_NAME,
}
4 changes: 4 additions & 0 deletions sdk/python/feast/flags_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ def enable_on_demand_feature_views(repo_config: RepoConfig) -> bool:

def enable_python_feature_server(repo_config: RepoConfig) -> bool:
return feature_flag_enabled(repo_config, flags.FLAG_PYTHON_FEATURE_SERVER_NAME)


def enable_aws_lambda_feature_server(repo_config: RepoConfig) -> bool:
return feature_flag_enabled(repo_config, flags.FLAG_AWS_LAMBDA_FEATURE_SERVER_NAME)
21 changes: 21 additions & 0 deletions sdk/python/feast/infra/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@
from feast.errors import (
AwsAPIGatewayDoesNotExist,
AwsLambdaDoesNotExist,
ExperimentalFeatureNotEnabled,
IncompatibleRegistryStoreClass,
RepoConfigPathDoesNotExist,
S3RegistryBucketForbiddenAccess,
S3RegistryBucketNotExist,
)
from feast.feature_table import FeatureTable
from feast.feature_view import FeatureView
from feast.flags import FLAG_AWS_LAMBDA_FEATURE_SERVER_NAME
from feast.flags_helper import enable_aws_lambda_feature_server
from feast.infra.passthrough_provider import PassthroughProvider
from feast.infra.utils import aws_utils
from feast.protos.feast.core.Registry_pb2 import Registry as RegistryProto
from feast.registry import get_registry_store_class_from_scheme
from feast.registry_store import RegistryStore
from feast.repo_config import RegistryConfig
from feast.version import get_version
Expand Down Expand Up @@ -62,6 +67,22 @@ def update_infra(
)

if self.repo_config.feature_server and self.repo_config.feature_server.enabled:
if not enable_aws_lambda_feature_server(self.repo_config):
raise ExperimentalFeatureNotEnabled(FLAG_AWS_LAMBDA_FEATURE_SERVER_NAME)

# Since the AWS Lambda feature server will attempt to load the registry, we
# only allow the registry to be in S3.
registry_path = (
self.repo_config.registry
if isinstance(self.repo_config.registry, str)
else self.repo_config.registry.path
)
registry_store_class = get_registry_store_class_from_scheme(registry_path)
if registry_store_class != S3RegistryStore:
raise IncompatibleRegistryStoreClass(
registry_store_class.__name__, S3RegistryStore.__name__
)

image_uri = self._upload_docker_image(project)
_logger.info("Deploying feature server...")

Expand Down

0 comments on commit d0778f7

Please sign in to comment.