-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback graph robustness #1416
Merged
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5616d1b
handle arbitrary properties (eg `width`) in dagre callback graph layout
alexcjohnson 2b1a106
more robust callback graph layouts
alexcjohnson 72132c2
fix callback graph test for new node IDs
alexcjohnson 0856de2
Merge branch 'dev' into callback-graph-robustness
alexcjohnson 84f0db0
changelog for callback graph robustness fix
alexcjohnson db0d5a5
Test the callback graph against a component with a `width` prop
53916e4
trigger build
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
@plotly/dash-test-components/src/components/WidthComponent.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import PropTypes from 'prop-types'; | ||
import React, { Fragment } from 'react'; | ||
|
||
const WidthComponent = props => (<Fragment> | ||
{props.width} | ||
</Fragment>); | ||
|
||
WidthComponent.propTypes = { | ||
id: PropTypes.string, | ||
width: PropTypes.number | ||
}; | ||
|
||
WidthComponent.defaultProps = { | ||
width: 0 | ||
}; | ||
|
||
export default WidthComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,10 @@ | |
import dash_core_components as dcc | ||
import dash_html_components as html | ||
import dash | ||
from dash.dependencies import Input, Output | ||
import dash.testing.wait as wait | ||
|
||
from dash_test_components import WidthComponent | ||
from ...assets.todo_app import todo_app | ||
|
||
|
||
|
@@ -102,7 +104,7 @@ def test_dvui003_callback_graph(dash_duo): | |
|
||
pos = dash_duo.driver.execute_script( | ||
""" | ||
const pos = store.getState().profile.graphLayout.positions['new-item.value']; | ||
const pos = store.getState().profile.graphLayout.positions['new-item.Xvalue']; | ||
pos.y -= 100; | ||
return pos.y; | ||
""" | ||
|
@@ -119,7 +121,36 @@ def test_dvui003_callback_graph(dash_duo): | |
# the manually moved node is still in its new position | ||
assert pos == dash_duo.driver.execute_script( | ||
""" | ||
const pos = store.getState().profile.graphLayout.positions['new-item.value']; | ||
const pos = store.getState().profile.graphLayout.positions['new-item.Xvalue']; | ||
return pos.y; | ||
""" | ||
) | ||
|
||
|
||
def test_dvui004_width_props(dash_duo): | ||
app = dash.Dash(__name__) | ||
|
||
app.layout = html.Div( | ||
[html.Button(["Click me!"], id="btn"), WidthComponent(id="width")] | ||
) | ||
|
||
@app.callback(Output("width", "width"), Input("btn", "n_clicks")) | ||
def get_width(n_clicks): | ||
n_clicks = n_clicks if n_clicks is not None else 0 | ||
|
||
return (n_clicks + 1) * 10 | ||
|
||
dash_duo.start_server( | ||
app, | ||
debug=True, | ||
use_reloader=False, | ||
use_debugger=True, | ||
dev_tools_hot_reload=False, | ||
) | ||
|
||
dash_duo.find_element(".dash-debug-menu").click() | ||
sleep(1) # wait for debug menu opening animation | ||
dash_duo.find_element(".dash-debug-menu__button--callbacks").click() | ||
sleep(3) # wait for callback graph to draw | ||
|
||
assert dash_duo.get_logs() == [] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some test with a callback involving a |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callback graph fails against components with
width
prop.. simple component withwidth