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

fix: Run feature server w/o gunicorn on windows #4024

Merged
merged 4 commits into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
57 changes: 33 additions & 24 deletions sdk/python/feast/feature_server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import json
import sys
import threading
import traceback
import warnings
from typing import List, Optional

import gunicorn.app.base
import pandas as pd
from dateutil import parser
from fastapi import FastAPI, HTTPException, Request, Response, status
Expand Down Expand Up @@ -202,24 +202,27 @@ def materialize_incremental(body=Depends(get_body)):
return app


class FeastServeApplication(gunicorn.app.base.BaseApplication):
def __init__(self, store: "feast.FeatureStore", **options):
self._app = get_app(
store=store,
registry_ttl_sec=options.get("registry_ttl_sec", 5),
)
self._options = options
super().__init__()
if sys.platform != "win32":
import gunicorn.app.base

def load_config(self):
for key, value in self._options.items():
if key.lower() in self.cfg.settings and value is not None:
self.cfg.set(key.lower(), value)
class FeastServeApplication(gunicorn.app.base.BaseApplication):
def __init__(self, store: "feast.FeatureStore", **options):
self._app = get_app(
store=store,
registry_ttl_sec=options.get("registry_ttl_sec", 5),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this should probably a config parameter somewhere up top

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

)
self._options = options
super().__init__()

self.cfg.set("worker_class", "uvicorn.workers.UvicornWorker")
def load_config(self):
for key, value in self._options.items():
if key.lower() in self.cfg.settings and value is not None:
self.cfg.set(key.lower(), value)

def load(self):
return self._app
self.cfg.set("worker_class", "uvicorn.workers.UvicornWorker")

def load(self):
return self._app


def start_server(
Expand All @@ -231,11 +234,17 @@ def start_server(
keep_alive_timeout: int,
registry_ttl_sec: int = 5,
):
FeastServeApplication(
store=store,
bind=f"{host}:{port}",
accesslog=None if no_access_log else "-",
workers=workers,
keepalive=keep_alive_timeout,
registry_ttl_sec=registry_ttl_sec,
).run()
if sys.platform != "win32":
FeastServeApplication(
store=store,
bind=f"{host}:{port}",
accesslog=None if no_access_log else "-",
workers=workers,
keepalive=keep_alive_timeout,
registry_ttl_sec=registry_ttl_sec,
).run()
else:
import uvicorn

app = get_app(store, registry_ttl_sec)
uvicorn.run(app, host=host, port=port, access_log=(not no_access_log))
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"typeguard>=4.0.0",
"fastapi>=0.68.0",
"uvicorn[standard]>=0.14.0,<1",
"gunicorn",
"gunicorn; platform_system != 'Windows'",
# https://github.com/dask/dask/issues/10996
"dask>=2021.1.0,<2024.3.0",
"bowler", # Needed for automatic repo upgrades
Expand Down
Loading