MCPcopy
hub / github.com/ray-project/ray / ClassMethodNode

Class ClassMethodNode

python/ray/dag/class_node.py:156–320  ·  view source on GitHub ↗

Represents an actor method invocation in a Ray function DAG.

Source from the content-addressed store, hash-verified

154
155@DeveloperAPI
156class ClassMethodNode(DAGNode):
157 """Represents an actor method invocation in a Ray function DAG."""
158
159 def __init__(
160 self,
161 method_name: str,
162 method_args: Tuple[Any],
163 method_kwargs: Dict[str, Any],
164 method_options: Dict[str, Any],
165 other_args_to_resolve: Dict[str, Any],
166 ):
167 self._bound_args = method_args or []
168 self._bound_kwargs = method_kwargs or {}
169 self._bound_options = method_options or {}
170 self._method_name: str = method_name
171 # Parse other_args_to_resolve and assign to variables
172 self._parent_class_node: Union[
173 ClassNode, ReferenceType["ray._private.actor.ActorHandle"]
174 ] = other_args_to_resolve.get(PARENT_CLASS_NODE_KEY)
175 # Used to track lineage of ClassMethodCall to preserve deterministic
176 # submission and execution order.
177 self._prev_class_method_call: Optional[
178 ClassMethodNode
179 ] = other_args_to_resolve.get(PREV_CLASS_METHOD_CALL_KEY, None)
180 # The index/order when bind() is called on this class method
181 self._bind_index: Optional[int] = other_args_to_resolve.get(
182 BIND_INDEX_KEY, None
183 )
184 # Represent if the ClassMethodNode is a class method output. If True,
185 # the node is a placeholder for a return value from the ClassMethodNode
186 # that returns multiple values. If False, the node is a class method call.
187 self._is_class_method_output: bool = other_args_to_resolve.get(
188 IS_CLASS_METHOD_OUTPUT_KEY, False
189 )
190 # Represents the return value from the upstream ClassMethodNode that
191 # returns multiple values. If the node is a class method call, this is None.
192 self._class_method_output: Optional[_ClassMethodOutput] = None
193 if self._is_class_method_output:
194 # Set the upstream ClassMethodNode and the output index of the return
195 # value from `method_args`.
196 self._class_method_output = _ClassMethodOutput(
197 method_args[0], method_args[1]
198 )
199
200 # The actor creation task dependency is encoded as the first argument,
201 # and the ordering dependency as the second, which ensures they are
202 # executed prior to this node.
203 super().__init__(
204 method_args,
205 method_kwargs,
206 method_options,
207 other_args_to_resolve=other_args_to_resolve,
208 )
209
210 def _copy_impl(
211 self,
212 new_args: List[Any],
213 new_kwargs: Dict[str, Any],

Callers 7

_bindMethod · 0.90
test_two_actorsMethod · 0.90
bindMethod · 0.85
_copy_implMethod · 0.85

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…