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

Add caching functionality to dash backend #4

Open
wants to merge 2 commits into
base: mvp_dashboard
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ __pycache__/
# C extensions
*.so

# Caching Dir
# cache/

# Distribution / packaging
.Python
build/
Expand Down
12 changes: 11 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from dash.exceptions import PreventUpdate
from utils import visualizations
import flask
from flask_caching import Cache

# Plotly custom theme
import plotly.io as pio
Expand Down Expand Up @@ -40,7 +41,15 @@
server=server,
suppress_callback_exceptions=True,
external_stylesheets=[dbc.themes.LUX])



CACHE_CONFIG = {
'CACHE_TYPE': 'FileSystemCache',
'CACHE_DIR': './cache'
}
cache = Cache()
cache.init_app(app.server, config=CACHE_CONFIG)

app.title = "Eth2 Calculator"
app.layout = layout

Expand Down Expand Up @@ -98,6 +107,7 @@ def update_validator_adoption_sliders_by_scenarios(validator_dropdown):
Input("eip1559-basefee-slider", "value"),
Input("eip1559-validator-tips-slider", "value")]
)
@cache.memoize()
def update_output_graph(validator_adoption, pos_launch_date, eip1559_basefee, eip1559_validator_tips):
df_0, parameters = run_simulation(validator_adoption, pos_launch_date, eip1559_basefee, eip1559_validator_tips)
if validator_adoption not in [1.5, 3, 4.5]:
Expand Down
246 changes: 122 additions & 124 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,124 +1,122 @@
appdirs==1.4.4
appnope==0.1.2
argcomplete==1.12.3
argon2-cffi==20.1.0
async-generator==1.10
attrs==20.3.0
backcall==0.2.0
bleach==3.3.0
boto3==1.17.101
botocore==1.20.101
Brotli==1.0.9
brotlipy==0.7.0
certifi==2021.5.30
cffi==1.14.5
cfn-flip==1.2.3
chardet==4.0.0
chart-studio==1.1.0
click==7.1.2
dash==1.19.0
dash-auth==1.4.1
dash-bootstrap-components==0.12.0
dash-core-components==1.15.0
dash-html-components==1.1.2
dash-renderer==1.9.0
dash-table==4.11.2
debugpy==1.3.0
decorator==5.0.9
defusedxml==0.7.1
dill==0.3.3
diskcache==5.2.1
distlib==0.3.2
durationpy==0.5
entrypoints==0.3
filelock==3.0.12
Flask==1.1.2
Flask-Compress==1.9.0
Flask-SeaSurf==0.3.0
future==0.18.2
gunicorn==20.1.0
handler==1.3.0
hjson==3.0.2
idna==2.10
iniconfig==1.1.1
ipykernel==6.0.1
ipython==7.25.0
ipython-genutils==0.2.0
ipywidgets==7.6.3
itsdangerous==1.1.0
jedi==0.18.0
Jinja2==2.11.3
jmespath==0.10.0
jsonschema==3.2.0
jupyter-client==6.1.12
jupyter-core==4.7.1
jupyterlab-pygments==0.1.2
jupyterlab-widgets==1.0.0
kappa==0.6.0
MarkupSafe==1.1.1
matplotlib-inline==0.1.2
mistune==0.8.4
multiprocess==0.70.11.1
nbclient==0.5.3
nbconvert==6.1.0
nbformat==5.1.3
nest-asyncio==1.5.1
notebook==6.4.0
numpy==1.20.2
packaging==20.9
pandas==1.2.3
pandocfilters==1.4.3
parso==0.8.2
pathos==0.2.7
pep517==0.10.0
pexpect==4.8.0
pickleshare==0.7.5
pip-tools==6.2.0
pipenv==2021.5.29
placebo==0.9.0
plotly==4.14.3
pluggy==0.13.1
pox==0.2.9
ppft==1.6.6.3
prometheus-client==0.11.0
prompt-toolkit==3.0.19
ptyprocess==0.7.0
py==1.10.0
pycparser==2.20
Pygments==2.9.0
pyparsing==2.4.7
pyrsistent==0.18.0
pytest==6.2.3
python-dateutil==2.8.1
python-dotenv==0.18.0
python-slugify==5.0.2
pytz==2021.1
PyYAML==5.4.1
pyzmq==22.1.0
radcad==0.8.0
requests==2.25.1
retrying==1.3.3
s3transfer==0.4.2
scipy==1.6.2
Send2Trash==1.7.1
six==1.15.0
stochastic==0.6.0
tenacity==7.0.0
terminado==0.10.1
testpath==0.5.0
text-unidecode==1.3
toml==0.10.2
tornado==6.1
tqdm==4.61.1
traitlets==5.0.5
troposphere==2.7.1
ua-parser==0.10.0
urllib3==1.26.6
virtualenv==20.4.7
virtualenv-clone==0.5.4
wcwidth==0.2.5
webencodings==0.5.1
Werkzeug==1.0.1
widgetsnbextension==3.5.1
wsgi-request-logger==0.4.6
zappa==0.53.0
appdirs
appnope
argcomplete
argon2-cffi
async-generator
attrs
backcall
bleach
boto3
botocore
Brotli
brotlipy
certifi
cffi
cfn-flip
chardet
chart-studio
click
dash
dash-auth
dash-bootstrap-components
dash-core-components
dash-html-components
dash-renderer
dash-table
debugpy
decorator
defusedxml
dill
diskcache
distlib
durationpy
entrypoints
filelock
Flask
Flask-Compress
Flask-SeaSurf
future
gunicorn
handler
hjson
idna
iniconfig
ipykernel
ipython
ipython-genutils
ipywidgets
itsdangerous
jedi
Jinja2
jmespath
jsonschema
jupyter-client
jupyter-core
jupyterlab-pygments
jupyterlab-widgets
kappa
MarkupSafe
matplotlib-inline
mistune
multiprocess
nbclient
nbconvert
nbformat
nest-asyncio
notebook
numpy
packaging
pandas
pandocfilters
parso
pathos
pep517
pexpect
pickleshare
pip-tools
pipenv
placebo
plotly
pluggy
pox
ppft
prometheus-client
prompt-toolkit
ptyprocess
py
pycparser
Pygments
pyparsing
pyrsistent
pytest
python-dateutil
python-dotenv
python-slugify
pytz
PyYAML
pyzmq
radcad
requests
retrying
s3transfer
scipy
Send2Trash
six
stochastic
tenacity
terminado
testpath
text-unidecode
toml
tornado
tqdm
traitlets
troposphere
ua-parser
urllib3
virtualenv
virtualenv-clone
wcwidth
webencodings
Werkzeug
flask-caching