Skip to content

Commit

Permalink
App: Force plugin server to use localhost (#18976)
Browse files Browse the repository at this point in the history
(cherry picked from commit ec374ab)
  • Loading branch information
ethanwharris authored and Borda committed Nov 14, 2023
1 parent cd4c47a commit 771324c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/lightning/app/plugin/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,9 @@ async def _healthz() -> Dict[str, str]:
return {"status": "ok"}


def _start_plugin_server(host: str, port: int) -> None:
def _start_plugin_server(port: int) -> None:
"""Start the plugin server which can be used to dispatch apps or run plugins."""

fastapi_service = FastAPI()

fastapi_service.add_middleware(
Expand All @@ -216,4 +217,9 @@ def _start_plugin_server(host: str, port: int) -> None:
fastapi_service.post("/v1/runs")(_run_plugin)
fastapi_service.get("/healthz", status_code=200)(_healthz)

uvicorn.run(app=fastapi_service, host=host, port=port, log_level="error")
uvicorn.run(
app=fastapi_service,
host="127.0.0.1",
port=port,
log_level="error",
)
2 changes: 1 addition & 1 deletion tests/tests_app/plugin/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create_test_client(app, **_):

mock_uvicorn.run.side_effect = create_test_client

_start_plugin_server("0.0.0.0", 8888) # noqa: S104
_start_plugin_server(8888)

return test_client["client"]

Expand Down

0 comments on commit 771324c

Please sign in to comment.