mirror of
https://github.com/vale981/ray
synced 2025-03-06 02:21:39 -05:00

This PR adds a serve ha test. The flow of the tests is: 1. check the kube ray build 2. start ray service 3. warm up the cluster 4. start killing nodes 5. get the stats and make sure it's good
50 lines
741 B
Python
50 lines
741 B
Python
from ray import serve
|
|
from ray.serve.drivers import DAGDriver
|
|
from ray.dag.input_node import InputNode
|
|
|
|
"""
|
|
We are building a DAG like this:
|
|
A -> B ----> C
|
|
\-> D --/
|
|
\-> E -/
|
|
"""
|
|
|
|
|
|
@serve.deployment
|
|
def a(val: int):
|
|
return val
|
|
|
|
|
|
@serve.deployment
|
|
def b(val: int):
|
|
return val + 1
|
|
|
|
|
|
@serve.deployment
|
|
def c(v1: int, v2: int, v3: int):
|
|
return sum([v1, v2, v3])
|
|
|
|
|
|
@serve.deployment
|
|
def d(val):
|
|
return val + 2
|
|
|
|
|
|
@serve.deployment
|
|
def e(val):
|
|
return val + 3
|
|
|
|
|
|
with InputNode() as user_input:
|
|
oa = a.bind(user_input)
|
|
ob = b.bind(oa)
|
|
od = d.bind(oa)
|
|
oe = e.bind(oa)
|
|
oc = c.bind(ob, od, oe)
|
|
|
|
|
|
def input_adapter(val: int):
|
|
return val
|
|
|
|
|
|
serve_entrypoint = DAGDriver.bind(oc, http_adapter=input_adapter)
|