Sounds like you downloaded some updates as well when you tried to do it.
Try this:
import dash
from dash import register_page, callback, Input, Output, State, dcc, html, DiskcacheManager
import dash_bootstrap_components as dbc
from datetime import datetime, timedelta
import logging
from dateutil import relativedelta
import os
import dash_loading_spinners as dls
import pandas as pd
import src.sql_connections as sqlc
import src.wrangler as wr
import src.sqlite_functions as sqlf
register_page(__name__, path='/')
df = sqlf.query_engines()
current_day = datetime.now() - timedelta(hours=6)
day = current_day.strftime('%Y-%m-%d')
time = current_day.strftime('%H:%M')
current_day_and_time = f'{day}T{time}'
current_month = datetime.now().strftime('%b-%Y')
next_month = datetime.now() + relativedelta.relativedelta(months=1)
next_month = next_month.strftime('%b-%Y')
layout = html.Div([
dbc.Container([
# Region and Engine Dropdowns
dbc.Row([
html.Center([
html.H3('Select a Region and then an Engine')
],
style={'margin-top': '30px'})
]),
dbc.Row([
html.Center([
dcc.Dropdown(
id='region-drop',
options=df.region.unique(),
placeholder='Region',
style={'width': '160px', 'text-align': 'left'}),
dcc.Dropdown(
id='engine-drop',
options=[],
placeholder='Engine',
style={'width': '160px', 'text-align': 'left'})
],
style={'display': 'flex', 'justify-content': 'center', 'gap': '100px', 'margin-top': '20px'})
]),
# Report Info
dbc.Row([
html.Div([
html.Center(
html.H3(
'What meeting is this for?',
style={'margin-bottom': '20px', 'margin-top': '50px'}),),
dbc.RadioItems(
options=[
{'label': current_month, 'value': current_month},
{'label': next_month, 'value': next_month},
],
value=current_month,
id='report-options',
inline=True,
style={'display': 'flex', 'justify-content': 'center', 'gap': '50px'}
)
],
style={"margin-top": "20px", "margin-bottom": "20px"})
]),
# Date selection
dbc.Row([
html.Center([
html.H3('Choose an End Date'),
html.P('(Gets data going back a year from chosen date.)')
])
],
style={'margin-top': '50px'}),
dbc.Row([
html.Center([
dcc.Input(
type='datetime-local',
step='60',
min='2000-01-01T00:00',
max=datetime.now(),
value=datetime.now(),
id='start-date'
)
])
],
style={'margin-top': '10px'}),
dbc.Row([
html.Center([
dbc.Button(
'Generate Graph',
id='data-button',
n_clicks=0,
color='secondary',
external_link=True,
),
]),
dls.Scale(id='loading', show_initially=True)
],
style={'margin-top': '20px', 'margin-bottom': '30px'}),
dbc.Row([
html.Center([
dbc.Alert(
children=["Did not select all required information."],
color='danger',
id='error-alert',
is_open=False,
)
])
]),
html.Hr(),
dbc.Row([
html.Center([
dbc.Button(
'See Graphs for Previous Meetings',
id='prev-graph-button',
n_clicks=0,
color='secondary',
href='prev-graph',
outline=True
)
])
],
style={'margin-top': '30px'}),
dcc.Location(id='graph-redirect', pathname='/')
])
])
@callback(
Output('engine-drop', 'options'),
Input('region-drop', 'value'),
prevent_initial_call=True
)
def update_dropdowns(value):
logging.info(f'Region Dropdown Selection: {value}')
return df[df.region == value].name
@callback(
Output('store', 'data'),
Output('error-alert', 'is_open'),
Output('graph-redirect', 'pathname'),
Input('data-button', 'n_clicks'),
State('engine-drop', 'value'),
State('start-date', 'value'),
State('region-drop', 'value'),
State('report-options', 'value'),
background=True,
running =[
(Output('data-button', 'disabled'), True, False),
(Output('loading', 'visibility'), True, False)
]
)
def query_data(n1, engine, date, region, report):
if n1:
if engine == None or region == None:
store = {}
return store, True, dash.no_update
else:
logging.info(f'Engine Selected: {engine}')
logging.info(f'Creating report {report}')
logging.debug('Clicked Generate Graph Button')
logging.info(f'Year from Date: {date}')
logging.info("Retrieving Data")
data = sqlc.get_data_for_app(region=region, engine=engine, end_date=date)
data = wr.get_past_year(df=data, end_date=date)
logging.info('Saving for Graph')
store = {"df": data.to_dict('records'), "date": date, "engine": engine, "report": report}
logging.info('Data Saved to Store and Directed to Graph Page')
return store, False, '/graph'
return dash.no_update, dash.no_update, dash.no_update
Take a look at your packages, I had an issue when SQLAlchemy updated to an alpha version instead of the last stable.
Also, try updating dash to v2.8.