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

Class InputAttributeNode

python/ray/dag/input_node.py:185–296  ·  view source on GitHub ↗

Represents partial access of user input based on an index (int), object attribute or dict key (str). Examples: .. code-block:: python with InputNode() as dag_input: a = dag_input[0] b = dag_input.x ray_dag = add.bind(a,

Source from the content-addressed store, hash-verified

183
184@DeveloperAPI
185class InputAttributeNode(DAGNode):
186 """Represents partial access of user input based on an index (int),
187 object attribute or dict key (str).
188
189 Examples:
190
191 .. code-block:: python
192
193 with InputNode() as dag_input:
194 a = dag_input[0]
195 b = dag_input.x
196 ray_dag = add.bind(a, b)
197
198 # This makes a = 1 and b = 2
199 ray_dag.execute(1, x=2)
200
201 with InputNode() as dag_input:
202 a = dag_input[0]
203 b = dag_input[1]
204 ray_dag = add.bind(a, b)
205
206 # This makes a = 2 and b = 3
207 ray_dag.execute(2, 3)
208
209 # Alternatively, you can input a single object
210 # and the inputs are automatically indexed from the object:
211 # This makes a = 2 and b = 3
212 ray_dag.execute([2, 3])
213 """
214
215 def __init__(
216 self,
217 dag_input_node: InputNode,
218 key: Union[int, str],
219 accessor_method: str,
220 input_type: str = None,
221 ):
222 self._dag_input_node = dag_input_node
223 self._key = key
224 self._accessor_method = accessor_method
225 super().__init__(
226 [],
227 {},
228 {},
229 {
230 "dag_input_node": dag_input_node,
231 "key": key,
232 "accessor_method": accessor_method,
233 # Type of the input tied to this node. Used by
234 # gradio_visualize_graph.GraphVisualizer to determine which Gradio
235 # component should be used for this node.
236 "result_type_string": input_type,
237 },
238 )
239
240 def _copy_impl(
241 self,
242 new_args: List[Any],

Callers 3

__getattr__Method · 0.85
__getitem__Method · 0.85
_copy_implMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…