Skip to content

[Serve] Support generics for DeploymentHandle type hints #52654

@marwan116

Description

@marwan116

Description

It would be great to support generics for DeploymentHandle type hints so linters can catch incorrect remote call args / response handling.

Use case

It would be great to support generics for DeploymentHandle type hints so linters can catch incorrect remote call args / response handling.

For example take this code:

@serve.deployment
@serve.ingress(fastapi_app)
class DeploymentA:
    def __init__(
        self, deployment_b: DeploymentHandle, deployment_c: DeploymentHandle
    ) -> None:
        self.deployment_b = deployment_b
        self.deployment_c = deployment_c

It would be nice if it can be specified more granularly as:

@serve.deployment
@serve.ingress(fastapi_app)
class DeploymentA:
    def __init__(
        self, deployment_b: DeploymentHandle[B], deployment_c: DeploymentHandle[C]
    ) -> None:
        self.deployment_b = deployment_b
        self.deployment_c = deployment_c

Metadata

Metadata

Assignees

Labels

P1Issue that should be fixed within a few weekscommunity-backlogenhancementRequest for new feature and/or capabilityserveRay Serve Related Issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions