Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## Added
- [#3395](https://github.com/plotly/dash/pull/3396) Add position argument to hooks.devtool
- [#3403](https://github.com/plotly/dash/pull/3403) Add app_context to get_app, allowing to get the current app in routes.
- [#3407](https://github.com/plotly/dash/pull/3407) Add `hidden` to callback arguments, hiding the callback from appearing in the devtool callback graph.

## Fixed
- [#3395](https://github.com/plotly/dash/pull/3395) Fix Components added through set_props() cannot trigger related callback functions. Fix [#3316](https://github.com/plotly/dash/issues/3316)
Expand Down
9 changes: 8 additions & 1 deletion dash/_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def _invoke_callback(func, *args, **kwargs): # used to mark the frame for the d
GLOBAL_INLINE_SCRIPTS = []


# pylint: disable=too-many-locals
# pylint: disable=too-many-locals,too-many-arguments
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need to suppress "too many arguments"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is set at max 12 that was reached by this function.

def callback(
*_args,
background: bool = False,
Expand All @@ -78,6 +78,7 @@ def callback(
cache_ignore_triggered=True,
on_error: Optional[Callable[[Exception], Any]] = None,
optional: Optional[bool] = False,
hidden: Optional[bool] = False,
**_kwargs,
) -> Callable[..., Any]:
"""
Expand Down Expand Up @@ -162,6 +163,8 @@ def callback(
to access the original callback inputs, states and output.
:param optional:
Mark all dependencies as not required on the initial layout checks.
:param hidden:
Hide the callback from the devtools callbacks tab.
"""

background_spec = None
Expand Down Expand Up @@ -217,6 +220,7 @@ def callback(
running=running,
on_error=on_error,
optional=optional,
hidden=hidden,
)


Expand Down Expand Up @@ -263,6 +267,7 @@ def insert_callback(
dynamic_creator: Optional[bool] = False,
no_output=False,
optional=False,
hidden=False,
):
if prevent_initial_call is None:
prevent_initial_call = config_prevent_initial_callbacks
Expand All @@ -287,6 +292,7 @@ def insert_callback(
"dynamic_creator": dynamic_creator,
"no_output": no_output,
"optional": optional,
"hidden": hidden,
}
if running:
callback_spec["running"] = running
Expand Down Expand Up @@ -631,6 +637,7 @@ def register_callback(
running=running,
no_output=not has_output,
optional=_kwargs.get("optional", False),
hidden=_kwargs.get("hidden", False),
)

# pylint: disable=too-many-locals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ function generateElements(graphs, profile, extraLinks) {
});
}

(graphs.callbacks || []).forEach((callback, i) => {
(graphs.callbacks || []).reduce((visibleIndex, callback) => {
if (callback.hidden) {
return visibleIndex;
}

const cb = `__dash_callback__.${callback.output}`;
const cbProfile = profile.callbacks[callback.output] || {};
const count = cbProfile.count || 0;
Expand All @@ -87,7 +91,7 @@ function generateElements(graphs, profile, extraLinks) {
elements.push({
data: {
id: cb,
label: `callback.${i}`,
label: `callback.${visibleIndex}`,
type: 'callback',
mode: callback.clientside_function ? 'client' : 'server',
count: count,
Expand All @@ -97,21 +101,23 @@ function generateElements(graphs, profile, extraLinks) {
}
});

callback.outputs.map(({id, property}) => {
callback.outputs.forEach(({id, property}) => {
const nodeId = recordNode(id, property);
recordEdge(cb, nodeId, 'output');
});

callback.inputs.map(({id, property}) => {
callback.inputs.forEach(({id, property}) => {
const nodeId = recordNode(id, property);
recordEdge(nodeId, cb, 'input');
});

callback.state.map(({id, property}) => {
callback.state.forEach(({id, property}) => {
const nodeId = recordNode(id, property);
recordEdge(nodeId, cb, 'state');
});
});

return visibleIndex + 1;
}, 0);

// pull together props in the same component
if (extraLinks) {
Expand Down