◐ Shell
reader mode source ↗
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
10 changes: 10 additions & 0 deletions sdk/python/feast/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,14 @@ def init_command(project_directory, minimal: bool, template: str):
show_default=True,
help="Timeout for keep alive",
)
@click.pass_context
def serve_command(
ctx: click.Context,
Expand All @@ -673,6 +681,7 @@ def serve_command(
no_feature_log: bool,
workers: int,
keep_alive_timeout: int,
):
"""Start a feature server locally on a given port."""
store = create_feature_store(ctx)
Expand All @@ -685,6 +694,7 @@ def serve_command(
no_feature_log=no_feature_log,
workers=workers,
keep_alive_timeout=keep_alive_timeout,
)


Expand Down
33 changes: 31 additions & 2 deletions sdk/python/feast/feature_server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import traceback
import warnings
from typing import List, Optional
Expand Down Expand Up @@ -44,14 +45,37 @@ class MaterializeIncrementalRequest(BaseModel):
feature_views: Optional[List[str]] = None


def get_app(store: "feast.FeatureStore"):
proto_json.patch()

app = FastAPI()

async def get_body(request: Request):
return await request.body()

@app.post("/get-online-features")
def get_online_features(body=Depends(get_body)):
try:
Expand Up @@ -180,7 +204,10 @@ def materialize_incremental(body=Depends(get_body)):

class FeastServeApplication(gunicorn.app.base.BaseApplication):
def __init__(self, store: "feast.FeatureStore", **options):
self._app = get_app(store=store)
self._options = options
super().__init__()

Expand All @@ -202,11 +229,13 @@ def start_server(
no_access_log: bool,
workers: int,
keep_alive_timeout: int,
):
FeastServeApplication(
store=store,
bind=f"{host}:{port}",
accesslog=None if no_access_log else "-",
workers=workers,
keepalive=keep_alive_timeout,
).run()
2 changes: 2 additions & 0 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2228,6 +2228,7 @@ def serve(
no_feature_log: bool,
workers: int,
keep_alive_timeout: int,
) -> None:
"""Start the feature consumption server locally on a given port."""
type_ = type_.lower()
@@ -2243,6 +2244,7 @@ def serve(
no_access_log=no_access_log,
workers=workers,
keep_alive_timeout=keep_alive_timeout,
)

@log_exceptions_and_usage
Expand Down
Toggle all file notes Toggle all file annotations