Skip to content
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

Add feature server configuration for AWS lambda #1865

Merged
merged 6 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions sdk/python/feast/infra/feature_servers/aws_lambda/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from pydantic import StrictBool, StrictStr
from pydantic.typing import Literal

from feast.repo_config import FeastConfigBaseModel


class AwsLambdaFeatureServerConfig(FeastConfigBaseModel):
"""Feature server config for AWS Lambda."""

type: Literal["aws_lambda"] = "aws_lambda"
"""Feature server type selector."""

enabled: StrictBool
felixwang9817 marked this conversation as resolved.
Show resolved Hide resolved
"""Whether the feature server should be launched."""

public: StrictBool
felixwang9817 marked this conversation as resolved.
Show resolved Hide resolved
"""Whether the endpoint should be publicly accessible."""

auth: StrictStr
felixwang9817 marked this conversation as resolved.
Show resolved Hide resolved
"""Authentication method for the endpoint."""

execution_role_name: StrictStr
"""The execution role for the AWS Lambda function."""
44 changes: 44 additions & 0 deletions sdk/python/feast/repo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
"redshift": "feast.infra.offline_stores.redshift.RedshiftOfflineStore",
}

FEATURE_SERVER_CONFIG_CLASS_FOR_TYPE = {
"aws_lambda": "feast.infra.feature_servers.aws_lambda.app.AwsLambdaFeatureServerConfig",
}


class FeastBaseModel(BaseModel):
""" Feast Pydantic Configuration Class """
Expand Down Expand Up @@ -190,6 +194,37 @@ def _validate_offline_store_config(cls, values):

return values

@root_validator(pre=True)
def _validate_feature_server_config(cls, values):
# Having no feature server is the default.
if "feature_server" not in values:
return values
felixwang9817 marked this conversation as resolved.
Show resolved Hide resolved

# Make sure that the provider configuration is set. We need it to set the defaults
assert "provider" in values

# Make sure that the type is not set, since we will set it based on the provider.
assert "type" not in values
felixwang9817 marked this conversation as resolved.
Show resolved Hide resolved

# Set the default type. We only support AWS Lambda for now.
if values["provider"] == "aws":
values["feature_server"]["type"] = "aws_lambda"

feature_server_type = values["feature_server"]["type"]

# Validate the dict to ensure one of the union types match
try:
feature_server_config_class = get_feature_server_config_from_type(
feature_server_type
)
feature_server_config_class(**values["feature_server"])
except ValidationError as e:
raise ValidationError(
[ErrorWrapper(e, loc="feature_server")], model=RepoConfig,
)

return values

@validator("project")
def _validate_project_name(cls, v):
from feast.repo_operations import is_valid_name
Expand Down Expand Up @@ -244,6 +279,15 @@ def get_offline_config_from_type(offline_store_type: str):
return get_class_from_type(module_name, config_class_name, config_class_name)


def get_feature_server_config_from_type(feature_server_type: str):
# We do not support custom feature servers right now.
assert feature_server_type in FEATURE_SERVER_CONFIG_CLASS_FOR_TYPE
felixwang9817 marked this conversation as resolved.
Show resolved Hide resolved

feature_server_type = FEATURE_SERVER_CONFIG_CLASS_FOR_TYPE[feature_server_type]
module_name, config_class_name = feature_server_type.rsplit(".", 1)
return get_class_from_type(module_name, config_class_name, config_class_name)


def load_repo_config(repo_path: Path) -> RepoConfig:
config_path = repo_path / "feature_store.yaml"

Expand Down