forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Serve] Separate internal API and Public API (ray-project#26804)
Signed-off-by: Rohan138 <[email protected]>
- Loading branch information
1 parent
7c05145
commit ba3aa20
Showing
5 changed files
with
103 additions
and
38 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from ray.serve.context import get_global_client | ||
from ray.serve.deployment import Deployment | ||
from typing import Dict | ||
|
||
|
||
def get_deployment(name: str): | ||
"""Dynamically fetch a handle to a Deployment object. | ||
Args: | ||
name(str): name of the deployment. This must have already been | ||
deployed. | ||
Returns: | ||
Deployment | ||
""" | ||
try: | ||
( | ||
deployment_info, | ||
route_prefix, | ||
) = get_global_client().get_deployment_info(name) | ||
except KeyError: | ||
raise KeyError( | ||
f"Deployment {name} was not found. Did you call Deployment.deploy()?" | ||
) | ||
return Deployment( | ||
deployment_info.replica_config.deployment_def, | ||
name, | ||
deployment_info.deployment_config, | ||
version=deployment_info.version, | ||
init_args=deployment_info.replica_config.init_args, | ||
init_kwargs=deployment_info.replica_config.init_kwargs, | ||
route_prefix=route_prefix, | ||
ray_actor_options=deployment_info.replica_config.ray_actor_options, | ||
_internal=True, | ||
) | ||
|
||
|
||
def list_deployments() -> Dict[str, Deployment]: | ||
"""Returns a dictionary of all active deployments. | ||
Dictionary maps deployment name to Deployment objects. | ||
""" | ||
infos = get_global_client().list_deployments() | ||
|
||
deployments = {} | ||
for name, (deployment_info, route_prefix) in infos.items(): | ||
deployments[name] = Deployment( | ||
deployment_info.replica_config.deployment_def, | ||
name, | ||
deployment_info.deployment_config, | ||
version=deployment_info.version, | ||
init_args=deployment_info.replica_config.init_args, | ||
init_kwargs=deployment_info.replica_config.init_kwargs, | ||
route_prefix=route_prefix, | ||
ray_actor_options=deployment_info.replica_config.ray_actor_options, | ||
_internal=True, | ||
) | ||
|
||
return deployments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters