Skip to content

Commit 352dd6c

Browse files
authored
Add --host as an option for feast serve (#2078)
Today the value is hardcoded to 127.0.0.1. This will enable uses to specify the host that they want to use for feast serve. Signed-off-by: Gunnar Sv Sigurbjörnsson <gunnar.sigurbjornsson@gmail.com>
1 parent 8c82133 commit 352dd6c

3 files changed

Lines changed: 18 additions & 7 deletions

File tree

sdk/python/feast/cli.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,16 +474,27 @@ def init_command(project_directory, minimal: bool, template: str):
474474

475475
@cli.command("serve")
476476
@click.option(
477-
"--port", "-p", type=click.INT, default=6566, help="Specify a port for the server"
477+
"--host",
478+
"-h",
479+
type=click.STRING,
480+
default="127.0.0.1",
481+
help="Specify a host for the server [default: 127.0.0.1]",
482+
)
483+
@click.option(
484+
"--port",
485+
"-p",
486+
type=click.INT,
487+
default=6566,
488+
help="Specify a port for the server [default: 6566]",
478489
)
479490
@click.pass_context
480-
def serve_command(ctx: click.Context, port: int):
491+
def serve_command(ctx: click.Context, host: str, port: int):
481492
"""[Experimental] Start a the feature consumption server locally on a given port."""
482493
repo = ctx.obj["CHDIR"]
483494
cli_check_repo(repo)
484495
store = FeatureStore(repo_path=str(repo))
485496

486-
store.serve(port)
497+
store.serve(host, port)
487498

488499

489500
@cli.command("serve_transformations")

sdk/python/feast/feature_server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ async def get_online_features(request: Request):
6161
return app
6262

6363

64-
def start_server(store: "feast.FeatureStore", port: int):
64+
def start_server(store: "feast.FeatureStore", host: str, port: int):
6565
app = get_app(store)
6666
click.echo(
6767
"This is an "
6868
+ click.style("experimental", fg="yellow", bold=True, underline=True)
6969
+ " feature. It's intended for early testing and feedback, and could change without warnings in future releases."
7070
)
71-
uvicorn.run(app, host="127.0.0.1", port=port)
71+
uvicorn.run(app, host=host, port=port)

sdk/python/feast/feature_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,12 +1360,12 @@ def _get_feature_views_to_use(
13601360
return views_to_use
13611361

13621362
@log_exceptions_and_usage
1363-
def serve(self, port: int) -> None:
1363+
def serve(self, host: str, port: int) -> None:
13641364
"""Start the feature consumption server locally on a given port."""
13651365
if not flags_helper.enable_python_feature_server(self.config):
13661366
raise ExperimentalFeatureNotEnabled(flags.FLAG_PYTHON_FEATURE_SERVER_NAME)
13671367

1368-
feature_server.start_server(self, port)
1368+
feature_server.start_server(self, host, port)
13691369

13701370
@log_exceptions_and_usage
13711371
def get_feature_server_endpoint(self) -> Optional[str]:

0 commit comments

Comments
 (0)