Callbacks not updating all outputs in production

I can’t figure this one out y’all. In a local environment my app runs and all the callbacks work as they should. Now that the calculator is in production only maybe half of my stuff updates during a callback. Anyone else experience this issue?

here’s my code:

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import numpy as np
import os

from dash.dependencies import Input, Output, State

app = dash.Dash(name)
server = app.server # this is the underlying Flask app

this_dir = os.path.dirname(os.path.realpath(file))
data_dir = os.path.join(this_dir, ‘static’)

app.css.append_css({
‘external_url’: ‘/static/style.css’,
})

min_insulation = pd.read_csv(os.path.join(data_dir, ‘minins3.csv’))
corners = pd.read_csv(os.path.join(data_dir, ‘corners.csv’))
wall_dist = pd.read_csv(os.path.join(data_dir, ‘dhw6.csv’))
min_depth = pd.read_csv(os.path.join(data_dir, ‘depth5.csv’))
afi_sites = pd.read_csv(os.path.join(data_dir, ‘afi2.csv’), index_col=‘Years’)
vert_wall_ins = pd.read_csv(os.path.join(data_dir, ‘minthermvert4.csv’))

cities = pd.DataFrame(afi_sites.columns)
cities.reset_index(level=0, inplace=True)
eps_v = 3.2 #vertical eps max effective Rvalue per inch
xps_v = 4.5 #vertical xps max effective Rvalue per inch
eps_h = 2.6 #horizontal eps max effective Rvalue per inch
xps_h = 4 #horizontal xps max effective Rvalue per inch
low = 15 #using the 6-15 (lowest on calc is 8.2)
high = 15.1 #using 15-28 (highest on calc is 20.3)
rmultiplier = 1.5 #used to calculate 50% more insulation for corners

def find_nearest(array, value):
array = np.asarray(array)
idx = (np.abs(array - value)).argmin()
return array[idx]

app.layout = html.Div(children=[
html.Div([
html.H1(children=‘Frost Protected Shallow Foundation Insulation’),
html.Label(‘These foundation recommendations are not for permafrost. If you have a permafrost site please consult with an engineer’),
html.Br(),
html.Br(),
#step one - determine site AFI
html.Label(‘Select the location nearest the construction site’),
dcc.Dropdown(
id=‘city’,
options=[{‘label’: i, ‘value’: i} for i in cities[0]],
value = ‘’,
),
html.Br(),
html.Label(‘Air Freezing Index’),dcc.Input(id=‘afi’, type=‘text’),
html.Br(),
#step two - calculate the R-value of the floor system cross section
html.Label(‘Foundation Type:’),
dcc.RadioItems(id=‘foundation’,
options=[
{‘label’: ‘4" concrete’, ‘value’:‘4’},
{‘label’: ‘6" concrete’, ‘value’:‘6’},
],
value=’’,
),
html.Br(),
html.Label(‘Insulation Thickness:’),
dcc.RadioItems(id=‘thickness’,
options=[
{‘label’: ‘2"’, ‘value’:‘2’},
{‘label’: ‘4"’, ‘value’:‘4’},
],
value=’’,
),
html.Br(),
html.Label(‘Insulation Type:’),html.Abbr("   “, title=“this selection assumes you are using the same insulation type throughout”),
dcc.RadioItems(id=‘insulation’,
options=[
{‘label’: ‘EPS’, ‘value’:‘EPS’},
{‘label’: ‘XPS’, ‘value’:‘XPS’},
],
value=’’,
),
html.Br(),
html.Label(‘Floor R-value (Rf)’),
dcc.Input(id=‘Rf’, type=‘text’),
html.Br(),
#step 3 - determine the required R-value of Vertical Wall Insulation
html.Label(‘Vertical Insulation R-value (Rv)’),
dcc.Input(id=‘Rv’, type=‘text’),
html.Br(),
#step 4 - select vertical wall insulation
html.Label(‘Recomended vertical wall insulation (inches)’),
html.Br(),
html.Label(‘Inches’),
dcc.Input(id=‘EPS_XPS’, type=‘text’),
html.Br(),
#step 5 - select foundation depth or horizontal insulation
html.Label(‘Minimum foundation depth’),
dcc.Input(id=‘mfd’, type=‘text’),
html.Br(),
html.Label(‘Horizontal Wall Insulation Projection Distance (Dhw) in feet and associated minimum thermal resistance (Rhw)’),
html.Br(),
html.Label(‘Dhw’),dcc.Input(id=‘Dhw’,type=‘text’),
html.Label(’ Rhw’),dcc.Input(id=‘Rhw’, type=‘text’),
html.Br(),
# step 6 - select thickness of horizontal insulation for walls
html.Label(‘Horizontal Wall Insulation thickness (inches)’),
html.Br(),
html.Label(‘Rhw Inches’),dcc.Input(id=‘Rhw_in’, type=‘text’),
html.Br(),
# step 7 - foundation depth or horizontal insulation at corners
html.Label(‘Corner Zone Length (inches)’),
dcc.Input(id=‘Lc’, type=‘text’),
html.Br(),
html.Label(‘Recommended R-value for horizontal corner insulation:’),html.Abbr(”   ", title=“Corner zones are colder because heat may excape from both the adjoining cold faces of the foundation system. To combat this add 50% more corner insulation and keep the same projection all around - adding enough extra insulation R-value (50% more) at corners without the need for extending insulation further.”),
html.Br(),
html.Label(‘Corner Zone Insulation R-value (Rhc)’),
dcc.Input(id=‘Rhc’, type=‘text’),
html.Br(),
html.Label(‘Corner Zone Length (in)’),
dcc.Input(id=‘Dc’, type=‘text’),
], id=‘right’, style={‘float’:‘left’,‘width’:‘80%’,‘display’:‘inline block’},),
html.Div([html.Br(),html.Label(‘What is the total R-value of the ground insulation currently installed?’),
dcc.Input(id=‘total_ground_rv’, type=‘number’),
], id=‘radiant_div’, style={‘display’: ‘none’}),
html.Div([html.Br(),
html.Label(‘Increased Perimeter Insulation due to presence of Ground Insulation’),
html.Br(),
html.Label(‘Revised Vertical Insulation R-value (Rv)’),dcc.Input(id=‘rf_Rv’,type=‘text’),
html.Br(),
html.Label(‘Revised Horizontal Wall Insulation R-value (Rhw)’),dcc.Input(id=‘rf_Rhw’,type=‘text’),
html.Br(),
html.Label(‘Revised Corner Zone Insulation R-value (Rhc)’),dcc.Input(id=‘rf_Rhc’,type=‘text’)], id=‘perimeter_insulation’, style={‘display’: ‘none’}),
#images
html.Div([
html.Img(id=‘perimeter’,src=’/static/perimeter_diagram.jpg’),
html.Br(),
html.Img(id=‘footing’,src=’/static/footing_diagram.jpg’),
html.Br(),
html.Img(id=‘index’,src=’/static/index_diagram.jpg’),
html.Br()
], id=‘left’, style={‘float’:‘right’,‘width’:‘20%’,‘display’:‘inline block’}, )
])

#step 1
@app.callback(Output(‘afi’, ‘value’), [Input(‘city’,‘value’)])
def findafi(city):
life = 100
afi = afi_sites.loc[life,city]
return afi

#step 5
@app.callback(Output(‘mfd’,‘value’), [Input(‘afi’,‘value’)])
def findminfounddepth(afi):
nearest_afi_depth = find_nearest(min_depth[‘AFI’], afi)
min_dep = min_depth.query(‘AFI == @nearest_afi_depth’)
mfd = min_dep.iloc[0][‘mfd’]
return mfd

#step 2
@app.callback(Output(‘Rf’, ‘value’), [Input(‘foundation’, ‘value’), Input(‘thickness’, ‘value’), Input(‘insulation’, ‘value’)])
def findfloorrv(foundation, thickness, insulation):
if insulation == ‘EPS’:
found = (float(foundation) * 0.05)
insul = eps_v * int(thickness)
Rf = found + insul
Rf = np.round(Rf,1)
elif insulation == ‘XPS’:
found = (float(foundation) * 0.05)
insul = xps_v * int(thickness)
Rf = found + insul
Rf = np.round(Rf,1)
return Rf

#step 3
@app.callback(Output(‘Rv’,‘value’), [Input(‘afi’,‘value’), Input(‘Rf’,‘value’)])
def finvvertical(afi,Rf):
if Rf <= low:
nearest_afi_vert = find_nearest(vert_wall_ins[‘AFI’], afi)
Rv = vert_wall_ins.query(“AFI == @nearest_afi_vert”).low.values[0]
Rv = np.round(Rv,2)
elif Rf >= high:
nearest_afi_vert = find_nearest(vert_wall_ins[‘AFI’], afi)
Rv = vert_wall_ins.query(“AFI == @nearest_afi_vert”).high.values[0]
Rv = np.round(Rv,2)
return Rv

#step 4
@app.callback(Output(‘EPS_XPS’,‘value’), [Input(‘Rv’,‘value’), Input(‘insulation’,‘value’)])
def findinsinches(Rv,insulation):
if insulation == ‘EPS’:
EPS_XPS = Rv / eps_v
EPS_XPS = np.round(EPS_XPS,0)
elif insulation == ‘XPS’:
EPS_XPS = Rv / xps_v
EPS_XPS = np.round(EPS_XPS,0)
return EPS_XPS

@app.callback(Output(‘Dhw’,‘value’), [Input(‘afi’,‘value’)])
def finddhw(afi):
nearest_afi_dhw = find_nearest(wall_dist[‘AFI’], afi)
if 0 <= nearest_afi_dhw <= 3000:
Dhw = 1
elif nearest_afi_dhw <=3999:
Dhw = 2
elif nearest_afi_dhw <=4499:
Dhw = 3
elif nearest_afi_dhw >=4500:
Dhw = 4
return Dhw

@app.callback(Output(‘Rhw’,‘value’), [Input(‘afi’,‘value’), Input(‘Dhw’,‘value’)])
def findrhw(afi,Dhw):
if Dhw == 1:
nearest_afi_rhw = find_nearest(wall_dist[‘AFI’], afi)
rhw_results = wall_dist.query(‘AFI == @nearest_afi_rhw’)
Rhw = rhw_results.iloc[0][‘one’]
elif Dhw == 2:
nearest_afi_rhw = find_nearest(wall_dist[‘AFI’], afi)
rhw_results = wall_dist.query(‘AFI == @nearest_afi_rhw’)
Rhw = rhw_results.iloc[0][‘two’]
elif Dhw == 3:
nearest_afi_rhw = find_nearest(wall_dist[‘AFI’], afi)
rhw_results = wall_dist.query(‘AFI == @nearest_afi_rhw’)
Rhw = rhw_results.iloc[0][‘three’]
elif Dhw == 4:
nearest_afi_rhw = find_nearest(wall_dist[‘AFI’], afi)
rhw_results = wall_dist.query(‘AFI == @nearest_afi_rhw’)
Rhw = rhw_results.iloc[0][‘four’]
return Rhw

#step 6
@app.callback(Output(‘Rhw_in’,‘value’), [Input(‘Rhw’,‘value’), Input(‘insulation’,‘value’)])
def findhorizontal(Rhw, insulation):
if insulation == ‘EPS’:
Rhw_in = Rhw / eps_h
Rhw_in = np.round(Rhw_in,0)
elif insulation == ‘XPS’:
Rhw_in = Rhw / xps_h
Rhw_in = np.round(Rhw_in,0)
return Rhw_in

#step 7
@app.callback(Output(‘Lc’,‘value’), [Input(‘afi’,‘value’)])
def findcorner(afi):
nearest_afi_corner = find_nearest(min_depth[‘AFI’], afi)
lc_results = min_depth.query(‘AFI == @nearest_afi_corner’)
Lc = lc_results.iloc[0][‘lc’]
return Lc

@app.callback(Output(‘Rhc’,‘value’), [Input(‘Rhw’,‘value’)])
def findcornerins(Rhw):
Rhc = rmultiplier * Rhw
Rhc = np.round(Rhc,2)
return Rhc

@app.callback(Output(‘Dc’,‘value’), [Input(‘Dhw’,‘value’)])
def findcornerlength(Dhw):
Dc = Dhw * 12 #to get inches instead of feet
return Dc

if name == ‘main’:
app.run_server(host=“0.0.0.0”)

It’s running on webfaction here http://cchrc.webfactional.com/

I remedied this by wrapping everything into a few callbacks instead of as many as I had in the original. Consider this closed.

2 Likes