diff --git a/vizro-core/changelog.d/20230921_075648_petar_pejovic_enable_custom_actions_unofficially.md b/vizro-core/changelog.d/20230921_075648_petar_pejovic_enable_custom_actions_unofficially.md new file mode 100644 index 000000000..ec3c663a6 --- /dev/null +++ b/vizro-core/changelog.d/20230921_075648_petar_pejovic_enable_custom_actions_unofficially.md @@ -0,0 +1,41 @@ + + + + +### Added + +- Add the ability to use custom actions. Currently in beta, expect this to break at any time. ([#46](https://github.com/mckinsey/vizro/pull/46)) + + + + + diff --git a/vizro-core/src/vizro/actions/_action_loop/_build_action_loop_callbacks.py b/vizro-core/src/vizro/actions/_action_loop/_build_action_loop_callbacks.py index a4fef6c78..34d04a572 100644 --- a/vizro-core/src/vizro/actions/_action_loop/_build_action_loop_callbacks.py +++ b/vizro-core/src/vizro/actions/_action_loop/_build_action_loop_callbacks.py @@ -7,7 +7,6 @@ from dash.exceptions import PreventUpdate from vizro._constants import ON_PAGE_LOAD_ACTION_PREFIX -from vizro.actions import action_functions from vizro.actions._action_loop._action_loop_utils import ( _get_actions_chains_on_registered_pages, _get_actions_on_registered_pages, @@ -88,10 +87,12 @@ def gateway(*gateway_triggers: List[dcc.Store]) -> List[Optional[str]]: ) logger.debug("=========== ACTION ===============") logger.debug(f"Triggered component: {triggered_actions_chains_ids[0]}.") + final_action_sequence = [ - {"Action ID": action.id, "Action name": action_functions[action.function._function]} + {"Action ID": action.id, "Action name": action.function._function.__name__} for action in model_manager[actions_chain_to_trigger].actions # type: ignore[attr-defined] ] + logger.debug(f"Actions to be executed as part of the triggered ActionsChain: {final_action_sequence}") return [action_dict["Action ID"] for action_dict in final_action_sequence] diff --git a/vizro-core/src/vizro/models/_action/_action.py b/vizro-core/src/vizro/models/_action/_action.py index 0bedbb8c6..0ac940867 100644 --- a/vizro-core/src/vizro/models/_action/_action.py +++ b/vizro-core/src/vizro/models/_action/_action.py @@ -5,7 +5,6 @@ from pydantic import Field import vizro.actions -from vizro.actions import action_functions from vizro.models import VizroBaseModel from vizro.models._models_utils import _log_call from vizro.models.types import CapturedCallable @@ -62,7 +61,7 @@ def build(self): logger.debug( f"Creating Callback mapping for Action ID {self.id} with " - f"function name: {action_functions[self.function._function]}" + f"function name: {self.function._function.__name__}" ) logger.debug("---------- INPUTS ----------") for name, object in callback_inputs.items():