Calls the `GraphComponent` run method when the node executes in the graph. Args: *inputs_from_previous_nodes: The output of all parent nodes. Each is a dictionary with a single item mapping the node's name to its output. If the node couldn't be re
(
self, *inputs_from_previous_nodes: Union[Tuple[Text, Any], Text]
)
| 429 | return Resource(self._node_name) |
| 430 | |
| 431 | def __call__( |
| 432 | self, *inputs_from_previous_nodes: Union[Tuple[Text, Any], Text] |
| 433 | ) -> Tuple[Text, Any]: |
| 434 | """Calls the `GraphComponent` run method when the node executes in the graph. |
| 435 | |
| 436 | Args: |
| 437 | *inputs_from_previous_nodes: The output of all parent nodes. Each is a |
| 438 | dictionary with a single item mapping the node's name to its output. |
| 439 | If the node couldn't be resolved and has no output, the node name is |
| 440 | provided instead of a tuple. |
| 441 | |
| 442 | Returns: |
| 443 | The node name and its output. |
| 444 | """ |
| 445 | # filter out arguments that dask couldn't lookup |
| 446 | received_inputs: Dict[Text, Any] = {} |
| 447 | for i in inputs_from_previous_nodes: |
| 448 | if isinstance(i, tuple): |
| 449 | node_name, node_output = i |
| 450 | received_inputs[node_name] = node_output |
| 451 | else: |
| 452 | logger.warning( |
| 453 | f"Node '{i}' was not resolved, there is no putput. " |
| 454 | f"Another component should have provided this as an " |
| 455 | f"output." |
| 456 | ) |
| 457 | |
| 458 | kwargs = {} |
| 459 | for input_name, input_provider_node_name in self._inputs.items(): |
| 460 | if input_provider_node_name not in received_inputs: |
| 461 | raise GraphRunError( |
| 462 | f"Missing input to run node '{self._node_name}'. " |
| 463 | f"Expected input '{input_provider_node_name}' to " |
| 464 | f"provide parameter '{input_name}'." |
| 465 | ) |
| 466 | kwargs[input_name] = received_inputs[input_provider_node_name] |
| 467 | |
| 468 | input_hook_outputs = self._run_before_hooks(kwargs) |
| 469 | |
| 470 | if not self._eager: |
| 471 | constructor_kwargs = rasa.shared.utils.common.minimal_kwargs( |
| 472 | kwargs, self._constructor_fn |
| 473 | ) |
| 474 | self._load_component(**constructor_kwargs) |
| 475 | run_kwargs = { |
| 476 | k: v for k, v in kwargs.items() if k not in constructor_kwargs |
| 477 | } |
| 478 | else: |
| 479 | run_kwargs = kwargs |
| 480 | |
| 481 | logger.debug( |
| 482 | f"Node '{self._node_name}' running " |
| 483 | f"'{self._component_class.__name__}.{self._fn_name}'." |
| 484 | ) |
| 485 | |
| 486 | try: |
| 487 | output = self._fn(self._component, **run_kwargs) |
| 488 | except InvalidConfigException: |
nothing calls this directly
no test coverage detected