Skip to content
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

app.callbacks #8

Open
austinmw opened this issue Oct 6, 2020 · 0 comments
Open

app.callbacks #8

austinmw opened this issue Oct 6, 2020 · 0 comments

Comments

@austinmw
Copy link

austinmw commented Oct 6, 2020

Hi, I'm able to run the first tutorial example in an AWS SageMaker notebook by modifying show_app and app as follows:

def show_app(app, port = 8000, 
             width = 800, 
             height = 500, 
             offline = True):
    
    def get_notebook_name():
        log_path = '/opt/ml/metadata/resource-metadata.json'
        with open(log_path, 'r') as logs:
            _logs = json.load(logs)
        return _logs['ResourceName']    

    url = f'https://{get_notebook_name().lower()}.notebook.us-east-1.sagemaker.aws/proxy/{port}'
        
    iframe = f'<a href="{url}" target="_new">Open in new window</a><hr><iframe src="{url}" width={width} height={height}></iframe>'    
    display.display_html(iframe, raw = True)
    if offline:
        app.css.config.serve_locally = True
        app.scripts.config.serve_locally = True
    return app.run_server(debug=False,
                          port=port)

app = dash.Dash(requests_pathname_prefix='/proxy/8000/')

However callbacks functionality doesn't seem to work. Is there any network settings I'm missing that would have to be modified for callbacks?

Here's a minimal non-working example:

app.layout = html.Div([
    dcc.Input(id='my-id', value='initial value', type="text"),
    html.Div(id='my-div')
])

@app.callback(
    Output(component_id='my-div', component_property='children'),
    [Input(component_id='my-id', component_property='value')],
)
def update_output_div(input_value):
    return 'You\'ve entered "{}"'.format(input_value)

Which results in this error:

Exception on /_dash-update-component [POST]
Traceback (most recent call last):
File "/home/ec2-user/anaconda3/envs/python3/lib/python3.6/site-packages/werkzeug/serving.py", line 124, in read_chunk_len
_len = int(line.strip(), 16)
ValueError: invalid literal for int() with base 16: '{"output":"my-div.children","outputs":{"id":"my-div","property":"children"},"inputs":[{"id":"my-id","property":"value","value":"initial value"}],"changedPropIds":[]}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant