Skip to content

Commit

Permalink
Removing fetching action function name from action_functions dictiona…
Browse files Browse the repository at this point in the history
…ry. (#46)
  • Loading branch information
petar-qb authored Sep 21, 2023
1 parent 87bcbc1 commit ebba3ed
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--
A new scriv changelog fragment.
Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Removed
- A bullet item for the Removed category.
-->

### 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))

<!--
### Changed
- A bullet item for the Changed category.
-->
<!--
### Deprecated
- A bullet item for the Deprecated category.
-->
<!--
### Fixed
- A bullet item for the Fixed category.
-->
<!--
### Security
- A bullet item for the Security category.
-->
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]

Expand Down
3 changes: 1 addition & 2 deletions vizro-core/src/vizro/models/_action/_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit ebba3ed

Please sign in to comment.