# ServeHandle with named deployment

**URL:** <https://discuss.ray.io/t/servehandle-with-named-deployment/6970>\
**Category:** Ray Serve\
**Created:** [July 26, 2022, 10:21am UTC](https://discuss.ray.io/t/servehandle-with-named-deployment/6970 "2022-07-26T10:21:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdz](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jdz/32/2927_2.png) [@jdz](https://discuss.ray.io/u/jdz)\
**Post date:** [July 26, 2022, 10:21am UTC](https://discuss.ray.io/t/servehandle-with-named-deployment/6970/1 "2022-07-26T10:21:56Z")

</div>

**How severe does this issue affect your experience of using Ray?**

- Medium: It contributes to significant difficulty to complete my task, but I can work around it.

Hi,  
I’m using deployments for models from a model registry (MLflow). I’m using the example code from the [docs](https://docs.ray.io/en/latest/serve/ml-models.html#integration-with-model-registries). I have multiple models, and my deployments are named.

```python
@serve.deployment
class MLflowDeployment:
    def __init__ (self, model_uri):
        self.model = mlflow.pyfunc.load_model(model_uri=model_uri)

    async def __call__ (self, request):
        ...
        return self.model.predict(...)

MLflowDeployment.options(name="my_mlflow_model_1").deploy("model:/model1/1")
MLflowDeployment.options(name="my_mlflow_model_2").deploy("model:/model2/1")

```

I’d like to use the ServeHandle feature with those deployments.  
How can I get the handle with named deployments? I looks like the `get_handle` method doesn’t have a name parameter. Did I miss something?

```python
handle = MLflowDeployment.get_handle() # missing name param?

```

By looking into the `get_handle` method, I see it uses the internal API. As a workaround, should I call it directly with my name?

```python
get_global_client().get_handle(self._name, missing_ok=True, sync=sync)
get_global_client().get_handle("my_mlflow_model_1", missing_ok=True, sync=sync)

```

Thank you, Jonathan

EDIT: the same question applies to delete a deployment by name.

---

<div class="post-metadata">

**Author:** ![simon-mo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/simon-mo/32/9_2.png) [@simon-mo](https://discuss.ray.io/u/simon-mo)\
**Post date:** [July 26, 2022, 8:35pm UTC](https://discuss.ray.io/t/servehandle-with-named-deployment/6970/2 "2022-07-26T20:35:58Z")

</div>

Try `serve.get_deployment(NAME).get_handle()`

[https://docs.ray.io/en/latest/serve/core-apis.html#creating-a-deployment:~:text=You%20can%20also%20list%20all%20available%20deployments%20and%20dynamically%20get%20references%20to%20them%3A](https://docs.ray.io/en/latest/serve/core-apis.html#creating-a-deployment:~:text=You%20can%20also%20list%20all%20available%20deployments%20and%20dynamically%20get%20references%20to%20them%3A)

---

<div class="post-metadata">

**Author:** ![jdz](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/jdz/32/2927_2.png) [@jdz](https://discuss.ray.io/u/jdz)\
**Post date:** [July 28, 2022, 2:41pm UTC](https://discuss.ray.io/t/servehandle-with-named-deployment/6970/3 "2022-07-28T14:41:50Z")

</div>

Thanks, that’s what I was missing. It works well!
