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

Delay fit evaluation button #21

Open
ckoerber opened this issue Oct 19, 2021 · 1 comment
Open

Delay fit evaluation button #21

ckoerber opened this issue Oct 19, 2021 · 1 comment
Labels
Low priority An issue that can be tackled eventually, maybe

Comments

@ckoerber
Copy link
Owner

ckoerber commented Oct 19, 2021

On some occasions, if the fit takes very long, users might want to change several parameters before initiating a new fit.

Also, probably rather relevant for meta-configs, some combinations for meta parameters might not be valid (for example x_min > x_max).

To counter running fits in such scenarios @walkloud suggest to include a "stop fit" switch which, when enabled, delays until disabled again.

@ckoerber ckoerber added the Low priority An issue that can be tackled eventually, maybe label Oct 20, 2021
@ckoerber
Copy link
Owner Author

ckoerber commented Oct 20, 2021

https://community.plotly.com/t/is-there-a-way-to-only-update-on-a-button-press-for-apps-where-updates-are-slow/4679/6

Seems relevant:

import dash
from dash.dependencies import Input, Output, State
import dash_html_components as html
import dash_core_components as dcc

app = dash.Dash()

app.layout = html.Div([
    html.Button('Click Me', id='button'),
    html.H3(id='button-clicks'),

    html.Hr(),

    html.Label('Input 1'),
    dcc.Input(id='input-1'),

    html.Label('Input 2'),
    dcc.Input(id='input-2'),

    html.Label('Slider 1'),
    dcc.Slider(id='slider-1'),

    html.Button(id='button-2'),

    html.Div(id='output')
])

@app.callback(
    Output('button-clicks', 'children'),
    [Input('button', 'n_clicks')])
def clicks(n_clicks):
    return 'Button has been clicked {} times'.format(n_clicks)

@app.callback(
    Output('output', 'children'),
    [Input('button-2', 'n_clicks')],
    state=[State('input-1', 'value'),
     State('input-2', 'value'),
     State('slider-1', 'value')])
def compute(n_clicks, input1, input2, slider1):
    return 'A computation based off of {}, {}, and {}'.format(
        input1, input2, slider1
    )

if __name__ == '__main__':
    app.run_server(debug=True)

I.e., instead of Input to trigger the callback, the second callback uses form values from States.

The thing which makes this relatively hard is that the callback inputs are created when initializing the app, so I would think this needs to be a static configuration option not a dynamic switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Low priority An issue that can be tackled eventually, maybe
Projects
None yet
Development

No branches or pull requests

1 participant