Skip to content

Commit 8eb5e60

Browse files
authored
Merge branch 'develop' into develop
2 parents 6aaadae + 90998ad commit 8eb5e60

37 files changed

+1010
-456
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

k8s/app.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,52 @@ spec:
2727
containers:
2828
- image: docker.pkg.github.com/codeforphilly/chime/penn-chime:1.1.2
2929
name: chime
30+
env:
31+
- name: GAPI_CRED_TYPE
32+
valueFrom:
33+
secretKeyRef:
34+
name: google-api-creds
35+
key: type
36+
- name: GAPI_CRED_PROJECT_ID
37+
valueFrom:
38+
secretKeyRef:
39+
name: google-api-creds
40+
key: project_id
41+
- name: GAPI_CRED_PRIVATE_KEY_ID
42+
valueFrom:
43+
secretKeyRef:
44+
name: google-api-creds
45+
key: private_key_id
46+
- name: GAPI_CRED_PRIVATE_KEY
47+
valueFrom:
48+
secretKeyRef:
49+
name: google-api-creds
50+
key: private_key
51+
- name: GAPI_CRED_CLIENT_EMAIL
52+
valueFrom:
53+
secretKeyRef:
54+
name: google-api-creds
55+
key: client_email
56+
- name: GAPI_CRED_CLIENT_ID
57+
valueFrom:
58+
secretKeyRef:
59+
name: google-api-creds
60+
key: client_id
61+
- name: GAPI_CRED_AUTH_PROVIDER_X509_CERT_URL
62+
valueFrom:
63+
secretKeyRef:
64+
name: google-api-creds
65+
key: auth_provider_x509_cert_url
66+
- name: GAPI_CRED_CLIENT_X509_CERT_URL
67+
valueFrom:
68+
secretKeyRef:
69+
name: google-api-creds
70+
key: client_x509_cert_url
3071
ports:
3172
- containerPort: 8000
3273
name: http
3374
protocol: TCP
75+
3476
imagePullSecrets:
3577
- name: regcred
3678

setup.py

Lines changed: 3 additions & 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
@@ -33,6 +33,8 @@
3333
"pyyaml",
3434
"selenium",
3535
"streamlit",
36+
"gspread",
37+
"oauth2client"
3638
],
3739
classifiers=[
3840
"Programming Language :: Python :: 3",

src/app.py

Lines changed: 6 additions & 4 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

@@ -36,7 +38,7 @@
3638
st.markdown("Projected number of **daily** COVID-19 admissions. \n\n _NOTE: Now including estimates of prior admissions for comparison._")
3739
admits_chart = build_admits_chart(alt=alt, admits_floor_df=m.admits_floor_df, max_y_axis=p.max_y_axis)
3840
st.altair_chart(admits_chart, use_container_width=True)
39-
st.markdown(build_descriptions(chart=admits_chart, labels=p.labels, suffix=" Admissions"))
41+
st.markdown(build_descriptions(chart=admits_chart, labels=p.labels, prefix="admits_", suffix=" Admissions"))
4042
display_download_link(
4143
st,
4244
filename=f"{p.current_date}_projected_admits.csv",
@@ -58,7 +60,7 @@
5860
st.markdown("Projected **census** of COVID-19 patients, accounting for arrivals and discharges \n\n _NOTE: Now including estimates of prior census for comparison._")
5961
census_chart = build_census_chart(alt=alt, census_floor_df=m.census_floor_df, max_y_axis=p.max_y_axis)
6062
st.altair_chart(census_chart, use_container_width=True)
61-
st.markdown(build_descriptions(chart=census_chart, labels=p.labels, suffix=" Census"))
63+
st.markdown(build_descriptions(chart=census_chart, labels=p.labels, prefix="census_", suffix=" Census"))
6264
display_download_link(
6365
st,
6466
filename=f"{p.current_date}_projected_census.csv",

0 commit comments

Comments
 (0)