aws / aws/amazon-sagemaker-examples
Plotly Dash host/proxy issue in SageMaker
- Dominant language
- Jupyter Notebook
- Stars
- 11k
- Forks
- 7k
- Avg merge
- 8h 29m
- Merged PRs (30d)
- 8
Description
Hi, is it possible to use Plotly's Dash framework in a SageMaker notebook (standard or lab)? Dash offers 3 different modes, `inline` (in cell), `external` (new tab), and `jupyterlab` (new frame), but I've been unsuccessful in deploying all three. I suspect there's a compatibility issue with the proxy address SageMaker uses, but have not been able to get to the root of the issue.
Code example:
```python
import plotly.express as px
from jupyter_dash import JupyterDash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
# Load Data
df = px.data.tips()
# Build App
app = JupyterDash(__name__)
app.layout = html.Div([
html.H1("JupyterDash Demo"),
dcc.Graph(id='graph'),
html.Label([
"colorscale",
dcc.Dropdown(
id='colorscale-dropdown', clearable=False,
value='plasma', options=[
{'label': c, 'value': c}
for c in px.colors.named_colorscales()
])
]),
])
# Define callback to update graph
@app.callback(
Output('graph', 'figure'),
[Input("colorscale-dropdown", "value")]
)
def update_figure(colorscale):
return px.scatter(
df, x="total_bill", y="tip", color="size",
color_continuous_scale=colorscale,
render_mode="webgl", title="Tips"
)
# Run app and display result inline in the notebook
app.run_server(mode='inline')
```
Dash has a large community, and the ability to design python-native interactive dashboards for model evaluation and other use cases I believe makes this worth finding a solution for.
Contributor guide
Research direction
Start by running the provided Python example in SageMaker standard and lab notebooks, testing the inline, external, and jupyterlab modes through app.run_server. Compare the proxy URLs and resulting behavior; done means identifying a reproducible compatibility cause and documenting or implementing a supported resolution for the affected modes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, jupyter-notebook, python
- Domain
- cloud, machine-learning, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100