You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When returning a list containing a tuple to a div child, the whole page will break and callbacks will stop.
This is OK, but the error that's returned does not provide good feedback on the actual problem. Would be nice if dash raised an error that says "hey stop putting weird data types inside other weird data types"
So this format works:
[string, string, html.Br(),string…etc]
this does NOT work:
[string, string,tuple, html.Br(),…etc]
To replicate:
Run this code and try and put garbage data into the editable table. like "fdsafdsafds" or something.
This will trigger the exception and try and return a list in the format ['test',html.Br(),'test',e.args] and the page will break because e.args is a tuple
import dash
from dash.dependencies import Input, Output,State
import dash_table
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
app = dash.Dash(__name__)
params = [
'Weight', 'Torque', 'Width', 'Height',
'Efficiency', 'Power', 'Displacement'
]
app.layout = html.Div(id='wrapper', children=[
dash_table.DataTable(
id='table-editing-simple',
columns=(
[{'id': 'Model', 'name': 'Model'}] +
[{'id': p, 'name': p} for p in params]
),
data=[
dict(Model=i, **{param: 0 for param in params})
for i in range(1, 5)
],
editable=True
),
dcc.Graph(id='table-editing-simple-output'),
html.Button('Ifdsafdsa',id='input')
])
def checkThisValue(value):
if float(value)>100:
value=100
elif float(value)<0:
value=0
return value
@app.callback(
Output('wrapper', 'children'),[Input('input','n_clicks')],
[State('table-editing-simple', 'data'), State('table-editing-simple', 'columns')])
def display_output(n_clicks,rows, columns):
try:
for row in rows:
for key,value in row.items():
print(checkThisValue(value))
except Exception as e:
message=['test',html.Br(),'test',e.args] #e.args is a tuple so this will break
return(message)
df = pd.DataFrame(rows, columns=[c['name'] for c in columns])
return [
dash_table.DataTable(
id='table-editing-simple',
columns=columns,
data=rows,
editable=True
),
dcc.Graph(id='table-editing-simple-output',figure={
'data': [{
'type': 'parcoords',
'dimensions': [{
'label': col['name'],
'values': df[col['id']]
} for col in columns]
}]
}),
html.Button('Ifdsafdsa',id='input')
]
if __name__ == '__main__':
app.run_server(debug=True)
The text was updated successfully, but these errors were encountered:
When returning a list containing a tuple to a div child, the whole page will break and callbacks will stop.
This is OK, but the error that's returned does not provide good feedback on the actual problem. Would be nice if dash raised an error that says "hey stop putting weird data types inside other weird data types"
So this format works:
[string, string, html.Br(),string…etc]
this does NOT work:
[string, string,tuple, html.Br(),…etc]
To replicate:
Run this code and try and put garbage data into the editable table. like "fdsafdsafds" or something.
This will trigger the exception and try and return a list in the format ['test',html.Br(),'test',e.args] and the page will break because e.args is a tuple
The text was updated successfully, but these errors were encountered: