Esempio n. 1
0
def get_multi_instantiation_class_deployment_in_init_args_dag():
    with InputNode() as dag_input:
        m1 = Model.bind(2)
        m2 = Model.bind(3)
        combine = Combine.bind(m1, m2=m2)
        ray_dag = combine.__call__.bind(dag_input)

    return ray_dag, dag_input
Esempio n. 2
0
def get_multi_instantiation_class_nested_deployment_arg_dag():
    with PipelineInputNode(preprocessor=request_to_data_int) as dag_input:
        m1 = Model.bind(2)
        m2 = Model.bind(3)
        combine = Combine.bind(m1, m2={NESTED_HANDLE_KEY: m2}, m2_nested=True)
        ray_dag = combine.__call__.bind(dag_input)

    return ray_dag, dag_input
Esempio n. 3
0
def get_multi_instantiation_class_deployment_in_init_args_dag():
    with PipelineInputNode(preprocessor=request_to_data_int) as dag_input:
        m1 = Model.bind(2)
        m2 = Model.bind(3)
        combine = Combine.bind(m1, m2=m2)
        ray_dag = combine.__call__.bind(dag_input)

    return ray_dag, dag_input
Esempio n. 4
0
def test_simple_class_node_json_serde(serve_instance):
    """
    Test the following behavior
        1) Ray DAG node can go through full JSON serde cycle
        2) Ray DAG node and deserialized DAG node produces same actor instances
            with same method call output
        3) Ray DAG node can go through multiple rounds of JSON serde and still
            provides the same value as if it's only JSON serde once
    Against following test cases
        - Simple class with no args
        - Simple class with only args, all primitive types
        - Simple class with args + kwargs, all primitive types
        - Simple chain of class method calls, all primitive types
    """
    original_dag_node = ClassHello.bind()
    _test_json_serde_helper(
        original_dag_node,
        executor_fn=_test_execution_class_node_ClassHello,
        expected_json_dict={
            DAGNODE_TYPE_KEY: "ClassNode",
            "import_path": "ray.serve.pipeline.tests.resources.test_modules.ClassHello",
            "args": [],
            "kwargs": {},
            "options": {},
            "other_args_to_resolve": {},
            "uuid": original_dag_node.get_stable_uuid(),
        },
    )

    original_dag_node = Model.bind(1)
    _test_json_serde_helper(
        original_dag_node,
        executor_fn=_test_execution_class_node_Model,
        expected_json_dict={
            DAGNODE_TYPE_KEY: "ClassNode",
            "import_path": "ray.serve.pipeline.tests.resources.test_modules.Model",
            "args": [1],
            "kwargs": {},
            "options": {},
            "other_args_to_resolve": {},
            "uuid": original_dag_node.get_stable_uuid(),
        },
    )

    original_dag_node = Model.bind(1, ratio=0.5)
    _test_json_serde_helper(
        original_dag_node,
        executor_fn=_test_execution_class_node_Model,
        expected_json_dict={
            DAGNODE_TYPE_KEY: "ClassNode",
            "import_path": "ray.serve.pipeline.tests.resources.test_modules.Model",
            "args": [1],
            "kwargs": {"ratio": 0.5},
            "options": {},
            "other_args_to_resolve": {},
            "uuid": original_dag_node.get_stable_uuid(),
        },
    )
Esempio n. 5
0
def get_func_class_with_class_method_dag():
    with PipelineInputNode(preprocessor=request_to_data_obj) as dag_input:
        m1 = Model.bind(1)
        m2 = Model.bind(2)
        m1_output = m1.forward.bind(dag_input[0])
        m2_output = m2.forward.bind(dag_input[1])
        ray_dag = combine.bind(m1_output,
                               m2_output,
                               kwargs_output=dag_input[2])

    return ray_dag, dag_input
Esempio n. 6
0
def get_func_class_with_class_method_dag():
    with InputNode() as dag_input:
        m1 = Model.bind(1)
        m2 = Model.bind(2)
        m1_output = m1.forward.bind(dag_input[0])
        m2_output = m2.forward.bind(dag_input[1])
        ray_dag = combine.bind(m1_output,
                               m2_output,
                               kwargs_output=dag_input[2])

    return ray_dag, dag_input
Esempio n. 7
0
def test_multi_instantiation_class_nested_deployment_arg(serve_instance):
    with InputNode() as dag_input:
        m1 = Model.bind(2)
        m2 = Model.bind(3)
        combine = Combine.bind(m1, m2={NESTED_HANDLE_KEY: m2}, m2_nested=True)
        ray_dag = combine.__call__.bind(dag_input)

    (
        serve_root_dag,
        deserialized_serve_root_dag_node,
    ) = _test_deployment_json_serde_helper(ray_dag, input=1, expected_num_deployments=3)
    assert ray.get(serve_root_dag.execute(1)) == ray.get(
        deserialized_serve_root_dag_node.execute(1)
    )
Esempio n. 8
0
def get_shared_deployment_handle_dag():
    with PipelineInputNode(preprocessor=request_to_data_int) as dag_input:
        m = Model.bind(2)
        combine = Combine.bind(m, m2=m)
        ray_dag = combine.__call__.bind(dag_input)

    return ray_dag, dag_input
Esempio n. 9
0
def get_shared_deployment_handle_dag():
    with InputNode() as dag_input:
        m = Model.bind(2)
        combine = Combine.bind(m, m2=m)
        ray_dag = combine.__call__.bind(dag_input)

    return ray_dag, dag_input
Esempio n. 10
0
def test_nested_deployment_node_json_serde(serve_instance):
    with InputNode() as dag_input:
        m1 = Model.bind(2)
        m2 = Model.bind(3)

        m1_output = m1.forward.bind(dag_input)
        m2_output = m2.forward.bind(dag_input)

        ray_dag = combine.bind(m1_output, m2_output)
    (
        serve_root_dag,
        deserialized_serve_root_dag_node,
    ) = _test_deployment_json_serde_helper(ray_dag, input=1, expected_num_deployments=2)
    assert ray.get(serve_root_dag.execute(1)) == ray.get(
        deserialized_serve_root_dag_node.execute(1)
    )
Esempio n. 11
0
def test_chain_of_values():
    with InputNode() as dag_input:
        out = fn.bind(1)
        out_2 = fn.bind(out, incr=2)
        out_val = fn.bind(out_2, incr=3)
        model = Model.bind(out_val)
        ray_dag = model.forward.bind(dag_input)

    json_serialized = json.dumps(ray_dag, cls=DAGNodeEncoder)
    deserialized_dag_node = json.loads(json_serialized, object_hook=dagnode_from_json)

    assert ray.get(deserialized_dag_node.execute(2)) == ray.get(ray_dag.execute(2))
Esempio n. 12
0
def get_simple_class_with_class_method_dag():
    with PipelineInputNode(preprocessor=request_to_data_int) as dag_input:
        model = Model.bind(2, ratio=0.3)
        ray_dag = model.forward.bind(dag_input)

    return ray_dag, dag_input
Esempio n. 13
0
def get_simple_class_with_class_method_dag():
    with InputNode() as dag_input:
        model = Model.bind(2, ratio=0.3)
        ray_dag = model.forward.bind(dag_input)

    return ray_dag, dag_input