plotly / jupyter-dash

OBSOLETE - Dash v2.11+ has Jupyter support built in!
https://dash.plotly.com/dash-in-jupyter
MIT License
959 stars 233 forks source link

AWS SageMaker #39

Open austinmw opened 4 years ago

austinmw commented 4 years ago

Has anyone been able to get Dash working in an AWS SageMaker Jupyter notebook or or lab environment? I've been unsuccessful with all three modes of inline, external, jupyterlab.

To access a basic Flask app, the web address in SageMaker is ...aws/proxy/<port>/ which I think may be causing a compatibility issue with the host/port settings of Dash.

The closest I was able to get was with the external mode, where the sample got stuck displaying "Loading..."

I also created an issue on SM repo: https://github.com/aws/amazon-sagemaker-examples/issues/1595

kwtneo commented 3 years ago

hi Austin, did you manage to figure this out? Am trying to get it to run as well but no joy. With inline i'm getting a 127.0.0.1 refused to connect.

dblue0406 commented 3 years ago

I'm also running into the same problem. I have tried all three and tried to make sure my versions all match (Jupyterlab >2.0.0, node and npm are all updated) Have you figured this out?

kjsr7 commented 3 years ago

@austinmw Facing the same problem. Have you found a solution for this?

tsiq-maxime commented 3 years ago

Facing the same problem

MichaelTiemann commented 3 years ago

Me too.

kr-hansen commented 3 years ago

Same here!

rsandler00 commented 3 years ago

Same!

aleksabs commented 3 years ago

Would really appreciate a solution to this!!

agt64 commented 3 years ago

I think its related to the proxy too, and unfortunately will probably move development outside of sagemaker unless someone has found a work around.

freytheviking commented 2 years ago

Giving this another bump. Super high value!

austinlasseter commented 2 years ago

Same here. It would be great to have an answer to this.

thomaskelm commented 1 year ago

@austinmw if you are still hitting this issue, one workaround is to set the following parameter requests_pathname_prefix to be equal to /proxy/*port-number* in your JupyterDash object (or Dash more generally).

To expand on why it is stuck on loading, since Dash is a react based app and it loads most of the visuals after the page has already loaded. When it is trying to load the visuals (through other API calls to dash), it is looking for those artifacts at the root of the sagemaker instance (which sagemaker won't allow/ isn't expecting). So you need to set the requests pathname prefix to essentially make all of those artifacts go through the proxy.

As a concrete example of what is happening:

before you change the requests path it was trying to pull a javascript library called foobar.js from this url: https://sagemaker-url.sagemaker.aws/foobar.js

but it should be using this url: https://sagemaker-url.sagemaker.aws/proxy/*port-number*/foobar.js

this is what it would look like for the default port config when you define your app.

app = JupyterDash(__name__ , requests_pathname_prefix='/proxy/8050/')
drewbell commented 1 year ago

Hi, I'm having the same problem, where I can't get dash working on sagemaker. Below is what I'm trying from this other thread. I see "Dash is running on http://127.0.0.1:8050/proxy/8050" printed, but I get the sad paper page with "127.0.0.1 refused to connect".

Setting requests_pathname_prefix to /proxy/*port-number* didn't appear to be working for me. @thomaskelm would you mind posting a basic example so I can double check what I'm doing, or if the code below looks okay, what else should I be checking?

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__, requests_pathname_prefix='/proxy/8050')
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')
rickydxz commented 1 year ago

Hi everyone, the same issue I am having, even when adding the sugested parameter. This is an interesting topic.

yangwu1227 commented 1 year ago

Hi, I'm having the same problem, where I can't get dash working on sagemaker. Below is what I'm trying from this other thread. I see "Dash is running on http://127.0.0.1:8050/proxy/8050" printed, but I get the sad paper page with "127.0.0.1 refused to connect".

Setting requests_pathname_prefix to /proxy/*port-number* didn't appear to be working for me. @thomaskelm would you mind posting a basic example so I can double check what I'm doing, or if the code below looks okay, what else should I be checking?

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__, requests_pathname_prefix='/proxy/8050')
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')

@drewbell Try run_server with 'localhost' or '0.0.0.0'. If you provisioned your SageMaker instance using a vpc and specified inbound rules, make sure it is accessible.