Skip to content

Commit 1d40b14

Browse files
Copilotharupy
authored andcommitted
Fix Starlette 1.0 compatibility in mlflow/pyfunc/scoring_server/__init__.py (mlflow#21908)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: harupy <17039389+harupy@users.noreply.github.com> (cherry picked from commit cd2cea0)
1 parent 71af766 commit 1d40b14

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

mlflow/pyfunc/scoring_server/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,9 +508,7 @@ async def timeout_middleware(request: Request, call_next):
508508
media_type="application/json",
509509
)
510510

511-
@app.route("/ping", methods=["GET"])
512-
@app.route("/health", methods=["GET"])
513-
async def ping(request: Request):
511+
async def ping():
514512
"""
515513
Determine if the container is working and healthy.
516514
We declare it healthy if we can load the model successfully.
@@ -519,14 +517,17 @@ async def ping(request: Request):
519517
status = 200 if health else 404
520518
return Response(content="\n", status_code=status, media_type="application/json")
521519

522-
@app.route("/version", methods=["GET"])
523-
async def version(request: Request):
520+
app.get("/ping")(ping)
521+
app.get("/health")(ping)
522+
523+
@app.get("/version")
524+
async def version():
524525
"""
525526
Returns the current mlflow version.
526527
"""
527528
return Response(content=VERSION, status_code=200, media_type="application/json")
528529

529-
@app.route("/invocations", methods=["POST"])
530+
@app.post("/invocations")
530531
@_async_catch_mlflow_exception
531532
async def transformation(request: Request):
532533
"""

0 commit comments

Comments
 (0)