Overview
DAGNode is the abstract base class for all nodes in a Ray Serve deployment graph, providing bound arguments, options, a stable UUID, and recursive tree traversal logic.
Description
DAGNode implements the DAGNodeBase interface and provides the core infrastructure for building directed acyclic graphs of deployments. It stores bound arguments, bound options, and additional arguments to resolve, each assigned at construction time. The class implements recursive traversal via applyRecursive(), which uses an internal CachingFn to avoid duplicate processing of shared nodes in the graph. The copy() method preserves the stable UUID across node copies to maintain identity consistency.
Usage
Use DAGNode as the base class when implementing custom node types in the deployment graph composition system. Concrete subclasses (such as ClassNode or InputNode) extend this class to represent specific computation units in multi-deployment pipelines.
Code Reference
Source Location
- Repository: Ray
- File:
java/serve/src/main/java/io/ray/serve/dag/DAGNode.java
Signature
public abstract class DAGNode implements DAGNodeBase {
public DAGNode(
Object[] args,
Map<String, Object> options,
Map<String, Object> otherArgsToResolve)
public <T> T applyRecursive(Function<DAGNodeBase, T> fn)
public <T> DAGNodeBase applyAndReplaceAllChildNodes(Function<DAGNodeBase, T> fn)
public DAGNodeBase copy(
Object[] newArgs,
Map<String, Object> newOptions,
Map<String, Object> newOtherArgsToResolve)
}
Import
import io.ray.serve.dag.DAGNode;
I/O Contract
Constructor Parameters
| Parameter |
Type |
Description
|
args |
Object[] |
Bound arguments for the node (defaults to empty array if null)
|
options |
Map<String, Object> |
Bound options for the node (defaults to empty map if null)
|
otherArgsToResolve |
Map<String, Object> |
Additional arguments resolved at graph build time (defaults to empty map if null)
|
Key Methods
| Method |
Return Type |
Description
|
applyRecursive(fn) |
T |
Recursively applies a function to the entire DAG, using caching to avoid reprocessing shared nodes
|
applyAndReplaceAllChildNodes(fn) |
DAGNodeBase |
Applies a function to all child DAGNodeBase arguments and returns a copy with replaced children
|
copy(newArgs, newOptions, newOtherArgsToResolve) |
DAGNodeBase |
Creates a copy of the node with new arguments while preserving the stable UUID
|
getBoundArgs() |
Object[] |
Returns the bound arguments
|
getBoundOptions() |
Map<String, Object> |
Returns the bound options
|
getBoundOtherArgsToResolve() |
Map<String, Object> |
Returns additional arguments to resolve
|
getStableUuid() |
String |
Returns the stable UUID identifying this node across copies
|
Abstract Methods (to implement in subclasses)
| Method |
Return Type |
Description
|
copyImpl(newArgs, newOptions, newOtherArgsToResolve) |
DAGNodeBase |
Subclass-specific copy logic that creates a new instance with the given parameters
|
Usage Examples
// DAGNode is abstract; usage is via concrete subclasses.
// Example of recursive traversal over a deployment graph:
DAGNode rootNode = buildDeploymentGraph();
// Apply a transformation to every node in the graph
Object result = rootNode.applyRecursive(node -> {
// Process each node (shared nodes are visited only once due to caching)
System.out.println("Visiting node: " + node.getStableUuid());
return processNode(node);
});
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.