Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
sihanwang41 committed Jul 12, 2022
1 parent dae9fe0 commit 34259f5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 99 deletions.
7 changes: 0 additions & 7 deletions python/ray/serve/deployment_function_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ def __init__(
func_options,
other_args_to_resolve=other_args_to_resolve,
)
version = (
self._bound_other_args_to_resolve["version"]
if "version" in self._bound_other_args_to_resolve
else None
)
if "deployment_schema" in self._bound_other_args_to_resolve:
deployment_schema: DeploymentSchema = self._bound_other_args_to_resolve[
"deployment_schema"
Expand Down Expand Up @@ -63,7 +58,6 @@ def __init__(
init_args=(),
init_kwargs={},
route_prefix=route_prefix,
version=version,
)
else:
self._deployment: Deployment = Deployment(
Expand All @@ -74,7 +68,6 @@ def __init__(
init_kwargs=dict(),
ray_actor_options=func_options,
_internal=True,
version=version,
)
# TODO (jiaodong): Polish with async handle support later
self._deployment_handle = RayServeLazySyncHandle(self._deployment.name)
Expand Down
6 changes: 6 additions & 0 deletions python/ray/serve/deployment_graph_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,11 @@ def replace_with_handle(node):
deployment_schema: DeploymentSchema = dag_node._bound_other_args_to_resolve[
"deployment_schema"
]
version = (
dag_node._bound_other_args_to_resolve["version"]
if "version" in dag_node._bound_other_args_to_resolve
else None
)
deployment_shell: Deployment = schema_to_deployment(deployment_schema)

# Prefer user specified name to override the generated one.
Expand All @@ -205,6 +210,7 @@ def replace_with_handle(node):
init_args=replaced_deployment_init_args,
init_kwargs=replaced_deployment_init_kwargs,
route_prefix=route_prefix,
version=version,
)

return DeploymentNode(
Expand Down
91 changes: 0 additions & 91 deletions python/ray/serve/deployment_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,98 +29,7 @@ def __init__(
ray_actor_options,
other_args_to_resolve=other_args_to_resolve,
)
<<<<<<< HEAD
self._deployment = deployment
=======
# Deployment can be passed into other DAGNodes as init args. This is
# supported pattern in ray DAG that user can instantiate and pass class
# instances as init args to others.

# However in ray serve we send init args via .remote() that requires
# pickling, and all DAGNode types are not picklable by design.

# Thus we need convert all DeploymentNode used in init args into
# deployment handles (executable and picklable) in ray serve DAG to make
# serve DAG end to end executable.
# TODO(jiaodong): This part does some magic for DAGDriver and will throw
# error with weird pickle replace table error. Move this out.
def replace_with_handle(node):
if isinstance(node, DeploymentNode):
return RayServeLazySyncHandle(node._deployment.name)
elif isinstance(node, DeploymentExecutorNode):
return node._deployment_handle

(
replaced_deployment_init_args,
replaced_deployment_init_kwargs,
) = self.apply_functional(
[deployment_init_args, deployment_init_kwargs],
predictate_fn=lambda node: isinstance(
node,
# We need to match and replace all DAGNodes even though they
# could be None, because no DAGNode replacement should run into
# re-resolved child DAGNodes, otherwise with KeyError
(
DeploymentNode,
DeploymentMethodNode,
DeploymentFunctionNode,
DeploymentExecutorNode,
DeploymentFunctionExecutorNode,
DeploymentMethodExecutorNode,
),
),
apply_fn=replace_with_handle,
)

version = (
self._bound_other_args_to_resolve["version"]
if "version" in self._bound_other_args_to_resolve
else None
)
if "deployment_schema" in self._bound_other_args_to_resolve:
deployment_schema: DeploymentSchema = self._bound_other_args_to_resolve[
"deployment_schema"
]
deployment_shell = schema_to_deployment(deployment_schema)

# Prefer user specified name to override the generated one.
if (
inspect.isclass(func_or_class)
and deployment_shell.name != func_or_class.__name__
):
deployment_name = deployment_shell.name

# Set the route prefix, prefer the one user supplied,
# otherwise set it to /deployment_name
if (
deployment_shell.route_prefix is None
or deployment_shell.route_prefix != f"/{deployment_shell.name}"
):
route_prefix = deployment_shell.route_prefix
else:
route_prefix = f"/{deployment_name}"

self._deployment = deployment_shell.options(
func_or_class=func_or_class,
name=deployment_name,
init_args=replaced_deployment_init_args,
init_kwargs=replaced_deployment_init_kwargs,
route_prefix=route_prefix,
version=version,
)
else:
self._deployment: Deployment = Deployment(
func_or_class,
deployment_name,
# TODO: (jiaodong) Support deployment config from user input
DeploymentConfig(),
init_args=replaced_deployment_init_args,
init_kwargs=replaced_deployment_init_kwargs,
ray_actor_options=ray_actor_options,
_internal=True,
version=version,
)
>>>>>>> 206a2613b (Clean up more tests)
self._deployment_handle = RayServeLazySyncHandle(self._deployment.name)

def _copy_impl(
Expand Down
1 change: 0 additions & 1 deletion python/ray/serve/tests/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from ray import serve
from ray.serve.exceptions import RayServeException
from ray.serve.utils import get_random_letters
from pydantic import ValidationError


@pytest.mark.parametrize("use_handle", [True, False])
Expand Down

0 comments on commit 34259f5

Please sign in to comment.