# Deployments and fastapi docs

**URL:** <https://discuss.ray.io/t/deployments-and-fastapi-docs/5017>\
**Category:** Ray Serve\
**Created:** [February 11, 2022, 1:30pm UTC](https://discuss.ray.io/t/deployments-and-fastapi-docs/5017 "2022-02-11T13:30:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtor](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@dtor](https://discuss.ray.io/u/dtor)\
**Post date:** [February 11, 2022, 1:30pm UTC](https://discuss.ray.io/t/deployments-and-fastapi-docs/5017/1 "2022-02-11T13:30:04Z")

</div>

```auto
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](http://localhost:8000/api2/docs) and the “one” method is actually callable from [http://localhost:8000/api2/](http://localhost:8000/api2/).

Please advice on this.

---

<div class="post-metadata">

**Author:** ![architkulkarni](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/architkulkarni/32/10_2.png) [@architkulkarni](https://discuss.ray.io/u/architkulkarni)\
**Post date:** [February 12, 2022, 1:19am UTC](https://discuss.ray.io/t/deployments-and-fastapi-docs/5017/2 "2022-02-12T01:19:22Z")

</div>

> [@dtor](#):
>
> ```auto
> 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()
> 
> ```

Thanks for the detailed reproduction! I indeed reproduced this in 1.9.2, but it seems to have been fixed in the latest master build. I recommend trying a [nightly wheel](https://docs.ray.io/en/latest/installation.html#daily-releases-nightlies), or Ray 1.10.0.

---

<div class="post-metadata">

**Author:** ![dtor](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@dtor](https://discuss.ray.io/u/dtor)\
**Post date:** [February 12, 2022, 1:38pm UTC](https://discuss.ray.io/t/deployments-and-fastapi-docs/5017/3 "2022-02-12T13:38:44Z")

</div>

Hello,

Thank you for the response.  
My findings are 1.10.x still has this problem.  
However the nighly build does not  
" ray-2.0.0.dev0-cp38-cp38-manylinux2014\_x86\_64.whl "

---

<div class="post-metadata">

**Author:** ![dtor](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@dtor](https://discuss.ray.io/u/dtor)\
**Post date:** [February 12, 2022, 2:01pm UTC](https://discuss.ray.io/t/deployments-and-fastapi-docs/5017/4 "2022-02-12T14:01:16Z")

</div>

I have a question regarding installing the .whl for nightly using pip.  
I want to know if it’s possible to install a local.whl.

pip3 install --find-links=/ -U ‘ray[default] @ /ray-2.0.0.dev0-cp38-cp38-manylinux2014\_x86\_64.whl’

This results in a “does not exist”.

Thanks

---

<div class="post-metadata">

**Author:** ![architkulkarni](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/architkulkarni/32/10_2.png) [@architkulkarni](https://discuss.ray.io/u/architkulkarni)\
**Post date:** [February 14, 2022, 6:36pm UTC](https://discuss.ray.io/t/deployments-and-fastapi-docs/5017/5 "2022-02-14T18:36:50Z")

</div>

Yes, it it is possible to pip install a local whl file! I’m not sure about the “does not exist” error, maybe double-check the filepath? I’m also unfamiliar with the --find-links option.
