Skip to content

Commit cb908cc

Browse files
Merge pull request #499 from CodeForPhilly/fix_parameters
Fix parameters and "constants" - Closes #172 - Closes #466 - Closes #497 ---
2 parents fa8b692 + d707cc5 commit cb908cc

File tree

26 files changed

+576
-292
lines changed

26 files changed

+576
-292
lines changed

.github/workflows/pythonapp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
python -m pytest
4444
- name: Run App
4545
run: |
46-
streamlit run src/app.py &
46+
PARAMETERS=./defaults/cypress.cfg streamlit run src/app.py &
4747
- name: Cypress
4848
uses: cypress-io/github-action@v1
4949
with:

Dockerfile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
FROM python:3.7.7-slim-buster
2-
RUN mkdir /app
2+
ENV PARAMETERS=./defaults/webapp.cfg
33
WORKDIR /app
44
COPY README.md .
55
COPY setup.cfg .
66
COPY setup.py .
7-
COPY requirements.txt .
8-
# Creating an empty src dir is a (hopefully) temporary hack to improve layer caching and speed up image builds
9-
# todo fix once the Pipfile, setup.py, requirements.txt, pyprojec.toml build/dist story is figured out
10-
RUN mkdir src && pip install -q .
117
COPY .streamlit .streamlit
12-
COPY settings.cfg .
8+
COPY defaults defaults
139
COPY src src
10+
RUN pip install -q .
1411

1512
CMD ["streamlit", "run", "src/app.py"]
1613

Dockerfile.dash

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ WORKDIR /code
44

55
ARG PORT
66
ENV PORT $PORT
7+
ENV PARAMETERS=./defaults/webapp.cfg
78

8-
COPY requirements.txt requirements.txt
9-
RUN pip install -r requirements.txt
10-
9+
COPY README.md .
10+
COPY setup.py .
11+
COPY setup.cfg .
1112
COPY src src
13+
COPY defaults ./src/defaults
14+
RUN pip install -q .
1215

1316
# EXPOSE $PORT
1417

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
--current-hospitalized 14
1+
--current-hospitalized 69
22
--doubling-time 4.0
33
--hospitalized-days 7
44
--hospitalized-rate 0.025
55
--icu-days 9
66
--icu-rate 0.0075
77
--infectious-days 14
8-
--market_share 0.15
9-
--n-days 60
10-
--population 4119405
8+
--market-share 0.15
9+
--n-days 100
10+
--population 3600000
11+
--recovered 0
1112
--relative-contact-rate 0.3
1213
--ventilated-days 10
1314
--ventilated-rate 0.005

defaults/cypress.cfg

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--current-hospitalized 69
2+
--date-first-hospitalized 2020-03-07
3+
--doubling-time 4.0
4+
--hospitalized-days 7
5+
--hospitalized-rate 0.025
6+
--icu-days 9
7+
--icu-rate 0.0075
8+
--infectious-days 14
9+
--market-share 0.15
10+
--n-days 100
11+
--population 3600000
12+
--recovered 0
13+
--relative-contact-rate 0.3
14+
--ventilated-days 10
15+
--ventilated-rate 0.005

defaults/readme.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Webapps need default values for both date_first_hosptalized and doubling_time. The ui overrides one of them.
2+
3+
CLI needs either date_first_hospitalized xor doubling_time.

defaults/webapp.cfg

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--current-hospitalized 69
2+
--date-first-hospitalized 2020-03-07
3+
--doubling-time 4.0
4+
--hospitalized-days 7
5+
--hospitalized-rate 0.025
6+
--icu-days 9
7+
--icu-rate 0.0075
8+
--infectious-days 14
9+
--market-share 0.15
10+
--n-days 100
11+
--population 3600000
12+
--recovered 0
13+
--relative-contact-rate 0.3
14+
--ventilated-days 10
15+
--ventilated-rate 0.005

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Setup file for chime
22
"""
3-
__version__ = "1.1.2" # update VERSION in constants.py
3+
__version__ = "1.1.3" # update VERSION in constants.py
44
__author__ = "Predictive Healthcare @ Penn Medicine"
55

66
from os import path

src/app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
"""App."""
22

3+
import os
4+
35
import altair as alt # type: ignore
46
import streamlit as st # type: ignore
57

8+
from penn_chime.parameters import Parameters
69
from penn_chime.presentation import (
710
display_download_link,
811
display_footer,
912
display_header,
1013
display_sidebar,
1114
hide_menu_style,
1215
)
13-
from penn_chime.settings import get_defaults
1416
from penn_chime.models import SimSirModel
1517
from penn_chime.charts import (
1618
build_admits_chart,
@@ -26,7 +28,7 @@
2628
# In dev, this should be shown
2729
st.markdown(hide_menu_style, unsafe_allow_html=True)
2830

29-
d = get_defaults()
31+
d = Parameters.create(os.environ, [])
3032
p = display_sidebar(st, d)
3133
m = SimSirModel(p)
3234

src/chime_dash/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
dash instance defined here
55
"""
66

7-
from dash import Dash
7+
import os
88
from typing import TypeVar
9+
10+
from dash import Dash
11+
from penn_chime.parameters import Parameters
12+
913
from chime_dash.app.config import from_object
10-
from penn_chime.settings import get_defaults
1114
from chime_dash.app.pages.root import Root
1215
from chime_dash.app.utils.callbacks import wrap_callbacks
1316

@@ -31,7 +34,10 @@ def create_app(context: str = 'prod') -> DashAppInstance:
3134
Env = from_object(context)
3235

3336
LANGUAGE = Env.LANG
34-
body = Root(LANGUAGE, get_defaults())
37+
body = Root(
38+
LANGUAGE,
39+
Parameters.create(os.environ, []),
40+
)
3541

3642
App = Dash(
3743
__name__,

0 commit comments

Comments
 (0)