Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sihanwang41 committed Jul 12, 2022
1 parent 9534c71 commit c40b56a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 52 deletions.
2 changes: 0 additions & 2 deletions python/ray/serve/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ def bind(self, *args, **kwargs) -> Union[ClassNode, FunctionNode]:
other_args_to_resolve={
"deployment_schema": schema_shell,
"is_from_serve_deployment": True,
"version": self._version,
},
)
else:
Expand All @@ -198,7 +197,6 @@ def bind(self, *args, **kwargs) -> Union[ClassNode, FunctionNode]:
other_args_to_resolve={
"deployment_schema": schema_shell,
"is_from_serve_deployment": True,
"version": self._version,
},
)

Expand Down
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
7 changes: 1 addition & 6 deletions python/ray/serve/deployment_graph_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,7 @@ 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 @@ -210,7 +206,6 @@ 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
31 changes: 15 additions & 16 deletions python/ray/serve/tests/test_autoscaling_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,14 +820,15 @@ class A:
def __call__(self):
ray.get(signal.wait.remote())

handle = serve.run(A.bind())
A.deploy()
print("Deployed A.")

controller = serve_instance._controller
start_time = get_deployment_start_time(controller, A)

assert get_num_running_replicas(controller, A) == 0

handle = A.get_handle()
[handle.remote() for _ in range(1)]
print("Issued one request.")

Expand All @@ -837,21 +838,19 @@ def __call__(self):

first_deployment_replicas = get_running_replica_tags(controller, A)

serve.run(
A.options(
_autoscaling_config={
"metrics_interval_s": 0.1,
"min_replicas": 2,
"max_replicas": 10,
"look_back_period_s": 0.2,
"downscale_delay_s": 0.2,
"upscale_delay_s": 0.2,
},
_graceful_shutdown_timeout_s=1,
max_concurrent_queries=1000,
version="v1",
).bind()
)
A.options(
_autoscaling_config={
"metrics_interval_s": 0.1,
"min_replicas": 2,
"max_replicas": 10,
"look_back_period_s": 0.2,
"downscale_delay_s": 0.2,
"upscale_delay_s": 0.2,
},
_graceful_shutdown_timeout_s=1,
max_concurrent_queries=1000,
version="v1",
).deploy()
print("Redeployed A with min_replicas set to 2.")

wait_for_condition(lambda: get_num_running_replicas(controller, A) >= 2)
Expand Down
8 changes: 4 additions & 4 deletions python/ray/serve/tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def get_pids(expected, timeout=30):
serve.start(detached=True)
client = serve.context._connect()

serve.run(D.bind())
D.deploy()
pids1 = get_pids(1)

serve.run(D.options(num_replicas=3).bind(), _blocking=False)
D.options(num_replicas=3).deploy(_blocking=False)

# Check that a new replica has not started in 1.0 seconds. This
# doesn't guarantee that a new replica won't ever be started, but
Expand Down Expand Up @@ -189,10 +189,10 @@ def get_actor_distributions():

return set(map(len, node_to_actors.values()))

serve.run(f.options(num_replicas=3).bind())
f.options(num_replicas=3).deploy()
assert get_actor_distributions() == {2, 1}

serve.run(f.options(num_replicas=2).bind())
f.options(num_replicas=2).deploy()
assert get_actor_distributions() == {2}


Expand Down
30 changes: 15 additions & 15 deletions python/ray/serve/tests/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ def call():

return ret.split("|")[0], ret.split("|")[1]

serve.run(d.bind())
d.deploy()
val1, pid1 = call()
assert val1 == "1"

# Redeploying with the same version and code should do nothing.
serve.run(d.bind())
d.deploy()
val2, pid2 = call()
assert val2 == "1"
assert pid2 == pid1

# Redeploying with a new version should start a new actor.
serve.run(d.options(version="2").bind())
d.options(version="2").deploy()
val3, pid3 = call()
assert val3 == "1"
assert pid3 != pid2
Expand All @@ -49,14 +49,14 @@ def d(*args):
return f"2|{os.getpid()}"

# Redeploying with the same version and new code should do nothing.
serve.run(d.bind())
d.deploy()
val4, pid4 = call()
assert val4 == "1"
assert pid4 == pid3

# Redeploying with new code and a new version should start a new actor
# running the new code.
serve.run(d.options(version="3").bind())
d.options(version="3").deploy()
val5, pid5 = call()
assert val5 == "2"
assert pid5 != pid4
Expand Down Expand Up @@ -97,7 +97,7 @@ def call():

return ret.split("|")[0], ret.split("|")[1]

serve.run(v1.bind())
v1.deploy()
val1, pid1 = call()
assert val1 == "1"

Expand All @@ -106,23 +106,23 @@ def v2(*args):
return f"2|{os.getpid()}"

# Not specifying a version tag should cause it to always be updated.
serve.run(v2.bind())
v2.deploy()
val2, pid2 = call()
assert val2 == "2"
assert pid2 != pid1

serve.run(v2.bind())
v2.deploy()
val3, pid3 = call()
assert val3 == "2"
assert pid3 != pid2

# Specifying the version should stop updates from happening.
serve.run(v2.options(version="1").bind())
v2.options(version="1").deploy()
val4, pid4 = call()
assert val4 == "2"
assert pid4 != pid3

serve.run(v2.options(version="1").bind())
v2.options(version="1").deploy()
val5, pid5 = call()
assert val5 == "2"
assert pid5 == pid4
Expand Down Expand Up @@ -150,31 +150,31 @@ def call():
return ret.split("|")[0], ret.split("|")[1]

# First deploy with no user config set.
serve.run(D.bind())
D.deploy()
val1, pid1 = call()
assert val1 == "1"

# Now update the user config without changing versions. Actor should stay
# alive but return value should change.
serve.run(D.options(user_config={"ret": "2"}).bind())
D.options(user_config={"ret": "2"}).deploy()
val2, pid2 = call()
assert pid2 == pid1
assert val2 == "2"

# Update the user config without changing the version again.
serve.run(D.options(user_config={"ret": "3"}).bind())
D.options(user_config={"ret": "3"}).deploy()
val3, pid3 = call()
assert pid3 == pid2
assert val3 == "3"

# Update the version without changing the user config.
serve.run(D.options(version="2", user_config={"ret": "3"}).bind())
D.options(version="2", user_config={"ret": "3"}).deploy()
val4, pid4 = call()
assert pid4 != pid3
assert val4 == "3"

# Update the version and the user config.
serve.run(D.options(version="3", user_config={"ret": "4"}).bind())
D.options(version="3", user_config={"ret": "4"}).deploy()
val5, pid5 = call()
assert pid5 != pid4
assert val5 == "4"
Expand Down
4 changes: 2 additions & 2 deletions python/ray/serve/tests/test_deploy_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def call(route):
ret = requests.get(f"http://localhost:8000/{route}").text
return ret.split("|")[0], ret.split("|")[1]

serve.run(d.bind())
d.deploy()
val1, pid1 = call("old")
assert val1 == "1"

Expand All @@ -198,7 +198,7 @@ def check_switched():
assert pid2 == pid1
return True

serve.run(d.options(route_prefix="/new").bind())
d.options(route_prefix="/new").deploy()
wait_for_condition(check_switched)


Expand Down

0 comments on commit c40b56a

Please sign in to comment.