-
Notifications
You must be signed in to change notification settings - Fork 1k
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 Dockerfile for GCP CloudRun FeatureServer #1887
Merged
+74
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
sdk/python/feast/infra/feature_servers/gcp_cloudrun/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
FROM python:3.9-slim | ||
|
||
# Allow statements and log messages to immediately appear in the Knative logs | ||
ENV PYTHONUNBUFFERED True | ||
|
||
# Copy local code to the container image. | ||
ENV APP_HOME /app | ||
WORKDIR $APP_HOME | ||
|
||
# Copy app handler code | ||
COPY sdk/python/feast/infra/feature_servers/gcp_cloudrun/app.py ./app.py | ||
|
||
# Copy necessary parts of the Feast codebase | ||
COPY sdk/python ./sdk/python | ||
COPY protos ./protos | ||
COPY README.md ./README.md | ||
|
||
# Install production dependencies. | ||
RUN pip install --no-cache-dir \ | ||
-e 'sdk/python[gcp,redis]' \ | ||
-r ./sdk/python/feast/infra/feature_servers/gcp_cloudrun/requirements.txt | ||
|
||
# Run the web service on container startup. Here we use the gunicorn | ||
# webserver, with one worker process and 8 threads. | ||
# For environments with multiple CPU cores, increase the number of workers | ||
# to be equal to the cores available. | ||
# Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling. | ||
CMD exec gunicorn -k uvicorn.workers.UvicornWorker --bind :$PORT --workers 1 --threads 8 --timeout 0 app:app |
24 changes: 24 additions & 0 deletions
24
sdk/python/feast/infra/feature_servers/gcp_cloudrun/app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import base64 | ||
import os | ||
import tempfile | ||
from pathlib import Path | ||
|
||
from feast import FeatureStore | ||
from feast.constants import FEATURE_STORE_YAML_ENV_NAME | ||
from feast.feature_server import get_app | ||
|
||
# Load RepoConfig | ||
config_base64 = os.environ[FEATURE_STORE_YAML_ENV_NAME] | ||
config_bytes = base64.b64decode(config_base64) | ||
|
||
# Create a new unique directory for writing feature_store.yaml | ||
repo_path = Path(tempfile.mkdtemp()) | ||
|
||
with open(repo_path / "feature_store.yaml", "wb") as f: | ||
f.write(config_bytes) | ||
|
||
# Initialize the feature store | ||
store = FeatureStore(repo_path=str(repo_path.resolve())) | ||
|
||
# Create the FastAPI app | ||
app = get_app(store) | ||
20 changes: 20 additions & 0 deletions
20
sdk/python/feast/infra/feature_servers/gcp_cloudrun/config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from pydantic import StrictBool | ||
from pydantic.typing import Literal | ||
|
||
from feast.repo_config import FeastConfigBaseModel | ||
|
||
|
||
class GcpCloudRunFeatureServerConfig(FeastConfigBaseModel): | ||
"""Feature server config for GCP CloudRun.""" | ||
|
||
type: Literal["gcp_cloudrun"] = "gcp_cloudrun" | ||
"""Feature server type selector.""" | ||
|
||
enabled: StrictBool = False | ||
"""Whether the feature server should be launched.""" | ||
|
||
public: StrictBool = True | ||
"""Whether the endpoint should be publicly accessible.""" | ||
Comment on lines
+13
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these used anywhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
auth: Literal["none", "api-key"] = "none" | ||
"""Authentication method for the endpoint.""" |
1 change: 1 addition & 0 deletions
1
sdk/python/feast/infra/feature_servers/gcp_cloudrun/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
gunicorn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the only diff between this and the aws lambda app the fact that that one uses mangum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I believe that is the only difference in the
app.py
file.