import ray
from fastapi import FastAPI
from ray import serve
app = FastAPI()
ray.init(address="auto", namespace="serve")
serve.start(detached=True)
@serve.deployment(route_prefix="/api1",
ray_actor_options={},
max_concurrent_queries=100,
_autoscaling_config={
"min_replicas": 1,
"max_replicas": 3,
"target_num_ongoing_requests_per_replica": 10},
version="v1")
@serve.ingress(app)
class FastAPIWrapper1:
@app.post("/subpath")
def method(self):
return "Hello 1!"
@app.post("/one")
def one(self):
return "the one"
@serve.deployment(route_prefix="/api2",
ray_actor_options={},
max_concurrent_queries=100,
_autoscaling_config={
"min_replicas": 1,
"max_replicas": 3,
"target_num_ongoing_requests_per_replica": 10},
version="v1")
@serve.ingress(app)
class FastAPIWrapper2:
@app.post("/subpath")
def method(self):
return "Hello 2!"
@serve.deployment(route_prefix="/api3",
ray_actor_options={},
max_concurrent_queries=100,
_autoscaling_config={
"min_replicas": 1,
"max_replicas": 3,
"target_num_ongoing_requests_per_replica": 10},
version="v1" )
@serve.ingress(app)
class FastAPIWrapper3:
@app.post("/subpath")
def method(self):
return "Hello 3!"
@serve.deployment(route_prefix="/api4",
ray_actor_options={},
max_concurrent_queries=100,
_autoscaling_config={
"min_replicas": 1,
"max_replicas": 3,
"target_num_ongoing_requests_per_replica": 10},
version="v1" )
@serve.ingress(app)
class FastAPIWrapper4:
@app.post("/subpath")
def method(self):
return "Hello 4!"
FastAPIWrapper1.deploy()
FastAPIWrapper2.deploy()
FastAPIWrapper3.deploy()
FastAPIWrapper4.deploy()
When using the above code with ray 1.9.2, python 3.8.10 and fastapi 0.68.1
#ray start --head
#python3 sample.py
This results is leaking of method one from FastAPIWrapper1 to FastAPIWrapper2 instance.
This shows in http://localhost:8000/api2/docs and the “one” method is actually callable from http://localhost:8000/api2/.
Please advice on this.