python/ray/serve/pipeline/json_serde.py
def dagnode_from_json(input_json: Any) -> Union[DAGNode, RayServeHandle, Any]:
    """
    Decode a DAGNode from given input json dictionary. JSON serialization is
    only used and enforced in ray serve from ray core API authored DAGNode(s).

    Covers both RayServeHandle and DAGNode types.

    Assumptions:
        - User object's JSON dict does not have keys that collide with our
            reserved DAGNODE_TYPE_KEY
        - RayServeHandle and Deployment can be re-constructed without losing
            states needed for their functionality or correctness.
        - DAGNode type can be re-constructed with new stable_uuid upon each
            deserialization without effective correctness of execution.
            - Only exception is ClassNode used as parent of ClassMethodNode
                that we perserve the same parent node.
        - .options() does not contain any DAGNode type
    """
    # Deserialize RayServeHandle type
    if SERVE_HANDLE_JSON_KEY in input_json:
        return serve_handle_from_json_dict(input_json)
    # Base case for plain objects
    elif DAGNODE_TYPE_KEY not in input_json:
        return input_json
    elif input_json[DAGNODE_TYPE_KEY] == RayServeDAGHandle.__name__:
        return RayServeDAGHandle(input_json["dag_node_json"])
    elif input_json[DAGNODE_TYPE_KEY] == "DeploymentSchema":
        return DeploymentSchema.parse_obj(input_json["schema"])
    elif input_json[DAGNODE_TYPE_KEY] == RayServeLazySyncHandle.__name__:
        return RayServeLazySyncHandle(
            input_json["deployment_name"],
            HandleOptions(input_json["handle_options_method_name"]),
        )
    # Deserialize DAGNode type
    elif input_json[DAGNODE_TYPE_KEY] == InputNode.__name__:
        return InputNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == InputAtrributeNode.__name__:
        return InputAtrributeNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == ClassMethodNode.__name__:
        return ClassMethodNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == DeploymentNode.__name__:
        return DeploymentNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == DeploymentMethodNode.__name__:
        return DeploymentMethodNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == DeploymentFunctionNode.__name__:
        return DeploymentFunctionNode.from_json(input_json)
    else:
        # Class and Function nodes require original module as body.
        module_name, attr_name = parse_import_path(input_json["import_path"])
        module = getattr(import_module(module_name), attr_name)
        if input_json[DAGNODE_TYPE_KEY] == FunctionNode.__name__:
            return FunctionNode.from_json(input_json, module)
        elif input_json[DAGNODE_TYPE_KEY] == ClassNode.__name__:
            return ClassNode.from_json(input_json, module)

    Decode a DAGNode from given input json dictionary. JSON serialization is
    only used and enforced in ray serve from ray core API authored DAGNode(s).

    Covers both RayServeHandle and DAGNode types.

    Assumptions:
        - User object's JSON dict does not have keys that collide with our
            reserved DAGNODE_TYPE_KEY
        - RayServeHandle and Deployment can be re-constructed without losing
            states needed for their functionality or correctness.
        - DAGNode type can be re-constructed with new stable_uuid upon each
            deserialization without effective correctness of execution.
            - Only exception is ClassNode used as parent of ClassMethodNode
                that we perserve the same parent node.
        - .options() does not contain any DAGNode type
    
Decode a DAGNode from given input json dictionary. JSON serialization is
only used and enforced in ray serve from ray core API authored DAGNode(s).



User object's JSON dict does not have keys that collide with our
reserved DAGNODE_TYPE_KEY
RayServeHandle and Deployment can be re-constructed without losing
states needed for their functionality or correctness.
DAGNode type can be re-constructed with new stable_uuid upon each
deserialization without effective correctness of execution.
Only exception is ClassNode used as parent of ClassMethodNode
that we perserve the same parent node.
.options() does not contain any DAGNode type
Decode a DAGNode from given input json dictionary . JSON serialization is only used and enforced in ray serve from ray core API authored DAGNode ( s ) . User object ' s JSON dict does not have keys that collide with our reserved DAGNODE_TYPE_KEY RayServeHandle and Deployment can be re - constructed without losing states needed for their functionality or correctness . DAGNode type can be re - constructed with new stable_uuid upon each deserialization without effective correctness of execution . Only exception is ClassNode used as parent of ClassMethodNode that we perserve the same parent node . . options () does not contain any DAGNode type
def dagnode_from_json(input_json: Any) -> Union[DAGNode, RayServeHandle, Any]:
    if SERVE_HANDLE_JSON_KEY in input_json:
        return serve_handle_from_json_dict(input_json)
    elif DAGNODE_TYPE_KEY not in input_json:
        return input_json
    elif input_json[DAGNODE_TYPE_KEY] == RayServeDAGHandle.__name__:
        return RayServeDAGHandle(input_json["dag_node_json"])
    elif input_json[DAGNODE_TYPE_KEY] == "DeploymentSchema":
        return DeploymentSchema.parse_obj(input_json["schema"])
    elif input_json[DAGNODE_TYPE_KEY] == RayServeLazySyncHandle.__name__:
        return RayServeLazySyncHandle(
            input_json["deployment_name"],
            HandleOptions(input_json["handle_options_method_name"]),
        )
    elif input_json[DAGNODE_TYPE_KEY] == InputNode.__name__:
        return InputNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == InputAtrributeNode.__name__:
        return InputAtrributeNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == ClassMethodNode.__name__:
        return ClassMethodNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == DeploymentNode.__name__:
        return DeploymentNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == DeploymentMethodNode.__name__:
        return DeploymentMethodNode.from_json(input_json)
    elif input_json[DAGNODE_TYPE_KEY] == DeploymentFunctionNode.__name__:
        return DeploymentFunctionNode.from_json(input_json)
    else:
        module_name, attr_name = parse_import_path(input_json["import_path"])
        module = getattr(import_module(module_name), attr_name)
        if input_json[DAGNODE_TYPE_KEY] == FunctionNode.__name__:
            return FunctionNode.from_json(input_json, module)
        elif input_json[DAGNODE_TYPE_KEY] == ClassNode.__name__:
            return ClassNode.from_json(input_json, module)
def dagnode_from_json ( input_json : Any ) -> Union [ DAGNode , RayServeHandle , Any ] : if SERVE_HANDLE_JSON_KEY in input_json : return serve_handle_from_json_dict ( input_json ) elif DAGNODE_TYPE_KEY not in input_json : return input_json elif input_json [ DAGNODE_TYPE_KEY ] == RayServeDAGHandle . __name__ : return RayServeDAGHandle ( input_json [ "dag_node_json" ] ) elif input_json [ DAGNODE_TYPE_KEY ] == "DeploymentSchema" : return DeploymentSchema . parse_obj ( input_json [ "schema" ] ) elif input_json [ DAGNODE_TYPE_KEY ] == RayServeLazySyncHandle . __name__ : return RayServeLazySyncHandle ( input_json [ "deployment_name" ] , HandleOptions ( input_json [ "handle_options_method_name" ] ) , ) elif input_json [ DAGNODE_TYPE_KEY ] == InputNode . __name__ : return InputNode . from_json ( input_json ) elif input_json [ DAGNODE_TYPE_KEY ] == InputAtrributeNode . __name__ : return InputAtrributeNode . from_json ( input_json ) elif input_json [ DAGNODE_TYPE_KEY ] == ClassMethodNode . __name__ : return ClassMethodNode . from_json ( input_json ) elif input_json [ DAGNODE_TYPE_KEY ] == DeploymentNode . __name__ : return DeploymentNode . from_json ( input_json ) elif input_json [ DAGNODE_TYPE_KEY ] == DeploymentMethodNode . __name__ : return DeploymentMethodNode . from_json ( input_json ) elif input_json [ DAGNODE_TYPE_KEY ] == DeploymentFunctionNode . __name__ : return DeploymentFunctionNode . from_json ( input_json ) else : module_name , attr_name = parse_import_path ( input_json [ "import_path" ] ) module = getattr ( import_module ( module_name ) , attr_name ) if input_json [ DAGNODE_TYPE_KEY ] == FunctionNode . __name__ : return FunctionNode . from_json ( input_json , module ) elif input_json [ DAGNODE_TYPE_KEY ] == ClassNode . __name__ : return ClassNode . from_json ( input_json , module )
Decode a DAGNode from given input json dictionary.
Decode a DAGNode from given input json dictionary .
"""
    Decode a DAGNode from given input json dictionary. JSON serialization is
    only used and enforced in ray serve from ray core API authored DAGNode(s).

    Covers both RayServeHandle and DAGNode types.

    Assumptions:
        - User object's JSON dict does not have keys that collide with our
            reserved DAGNODE_TYPE_KEY
        - RayServeHandle and Deployment can be re-constructed without losing
            states needed for their functionality or correctness.
        - DAGNode type can be re-constructed with new stable_uuid upon each
            deserialization without effective correctness of execution.
            - Only exception is ClassNode used as parent of ClassMethodNode
                that we perserve the same parent node.
        - .options() does not contain any DAGNode type
    """ # Deserialize RayServeHandle type # Base case for plain objects # Deserialize DAGNode type # Class and Function nodes require original module as body.
input_json
Any