Prepare callback-related data.
(self, g, body: CallbackExecutionBody)
| 1537 | return g |
| 1538 | |
| 1539 | def _prepare_callback(self, g, body: CallbackExecutionBody): |
| 1540 | """Prepare callback-related data.""" |
| 1541 | output = body["output"] |
| 1542 | try: |
| 1543 | cb = self.callback_map[output] |
| 1544 | func = cb["callback"] |
| 1545 | g.background_callback_manager = ( |
| 1546 | cb.get("manager") or self._background_manager |
| 1547 | ) |
| 1548 | g.ignore_register_page = cb.get("background", False) |
| 1549 | |
| 1550 | # Add args_grouping |
| 1551 | inputs_state_indices = cb["inputs_state_indices"] |
| 1552 | inputs_state = convert_to_AttributeDict(g.inputs_list + g.states_list) |
| 1553 | |
| 1554 | if cb.get("no_output"): |
| 1555 | g.outputs_list = [] |
| 1556 | elif not g.outputs_list: |
| 1557 | # Legacy support for older renderers |
| 1558 | split_callback_id(output) |
| 1559 | |
| 1560 | # Update args_grouping attributes |
| 1561 | for s in inputs_state: |
| 1562 | # check for pattern matching: list of inputs or state |
| 1563 | if isinstance(s, list): |
| 1564 | for pattern_match_g in s: |
| 1565 | update_args_group( |
| 1566 | pattern_match_g, body.get("changedPropIds", []) |
| 1567 | ) |
| 1568 | update_args_group(s, body.get("changedPropIds", [])) |
| 1569 | |
| 1570 | g.args_grouping, g.using_args_grouping = self._prepare_grouping( |
| 1571 | inputs_state, inputs_state_indices |
| 1572 | ) |
| 1573 | g.outputs_grouping, g.using_outputs_grouping = self._prepare_grouping( |
| 1574 | g.outputs_list, cb.get("outputs_indices", []) |
| 1575 | ) |
| 1576 | except KeyError as e: |
| 1577 | raise KeyError(f"Callback function not found for output '{output}'.") from e |
| 1578 | return func |
| 1579 | |
| 1580 | def _prepare_grouping(self, data_list, indices): |
| 1581 | """Prepare grouping logic for inputs or outputs.""" |
no test coverage detected