Skip to content

Commit 41dcef3

Browse files
author
Eric Smyth
committed
Merge branch 'develop' into dash_urls_and_callbacks
2 parents 3b63a81 + 2f96066 commit 41dcef3

38 files changed

+952
-655
lines changed

Dockerfile.dash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ARG PORT
66
ENV PORT $PORT
77

88
COPY requirements.txt requirements.txt
9-
RUN pip install -q -r requirements.txt
9+
RUN pip install -r requirements.txt
1010

1111
COPY src src
1212

Pipfile.lock

Lines changed: 19 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

e2e/cypress/integration/tests/steppers.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ context('Increment steppers', () => {
66
});
77

88
it('Increment regional population', () => {
9-
cy.contains('Hospitalized Admissions peaks at 301');
9+
cy.contains('Hospitalized Admissions peaks at 300');
1010

1111
cy.get('input.st-al').eq(0)
1212
.should('has.value', '3600000');
@@ -16,11 +16,11 @@ context('Increment steppers', () => {
1616
cy.get('input.st-al').eq(0)
1717
.should('has.value', '3600001');
1818

19-
cy.contains('Hospitalized Admissions peaks at 301');
19+
cy.contains('Hospitalized Admissions peaks at 300');
2020
});
2121

2222
it('Increment hospital market share', () => {
23-
cy.contains('Hospitalized Admissions peaks at 301');
23+
cy.contains('Hospitalized Admissions peaks at 300');
2424

2525
cy.get('input.st-al').eq(1)
2626
.should('has.value', '15');
@@ -30,11 +30,11 @@ context('Increment steppers', () => {
3030
cy.get('input.st-al').eq(1)
3131
.should('has.value', '15.1');
3232

33-
cy.contains('Hospitalized Admissions peaks at 303');
33+
cy.contains('Hospitalized Admissions peaks at 302');
3434
});
3535

3636
it('Increment doubling time', () => {
37-
cy.contains('Hospitalized Admissions peaks at 301');
37+
cy.contains('Hospitalized Admissions peaks at 300');
3838

3939
cy.get('input.st-al').eq(3)
4040
.should('has.value', '4');
@@ -44,6 +44,6 @@ context('Increment steppers', () => {
4444
cy.get('input.st-al').eq(3)
4545
.should('has.value', '4.25');
4646

47-
cy.contains('Hospitalized Admissions peaks at 273');
47+
cy.contains('Hospitalized Admissions peaks at 272');
4848
});
4949
});

k8s/app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
app: chime
2626
spec:
2727
containers:
28-
- image: docker.pkg.github.com/codeforphilly/chime/penn-chime:1.1.0
28+
- image: docker.pkg.github.com/codeforphilly/chime/penn-chime:1.1.2
2929
name: chime
3030
ports:
3131
- containerPort: 8000

requirements.txt

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1 @@
1-
streamlit
2-
pandas
3-
numpy
4-
pytest
5-
altair
6-
dash
7-
dash_bootstrap_components
8-
pyyaml
9-
gunicorn
10-
selenium
1+
-e .

setup.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
1-
# -*- coding: utf-8 -*-
21
"""Setup file for chime
32
"""
4-
__version__ = "1.1.0"
3+
__version__ = "1.1.2"
54
__author__ = "Predictive Healthcare @ Penn Medicine"
65

76
from os import path
7+
from setuptools import setup, find_packages, find_namespace_packages
88

9-
from setuptools import setup, find_namespace_packages
10-
11-
CWD = path.abspath(path.dirname(__file__))
12-
13-
with open(path.join(CWD, "README.md"), encoding="utf-8") as inp:
14-
LONG_DESCRIPTION = inp.read()
15-
16-
with open(path.join(CWD, "requirements.txt"), encoding="utf-8") as inp:
17-
REQUIREMENTS = [el.strip() for el in inp.read().split(",")]
189

1910
setup(
2011
name="penn_chime",
21-
python_requires=">=3.7",
2212
version=__version__,
23-
description="COVID-19 Hospital Impact Model for Epidemics",
24-
long_description=LONG_DESCRIPTION,
25-
long_description_content_type="text/markdown",
2613
author=__author__,
2714
author_email="",
15+
description="COVID-19 Hospital Impact Model for Epidemics",
2816
url="https://github.com/CodeForPhilly/chime",
2917
project_urls={
3018
"Bug Reports": "https://github.com/CodeForPhilly/chime/issues",
3119
"Source": "https://github.com/CodeForPhilly/chime",
3220
"Documentation": "https://codeforphilly.github.io/chime/",
3321
},
34-
package_dir={"": "src"},
35-
packages=find_namespace_packages(where="src", exclude=("tests")),
36-
install_requires=REQUIREMENTS,
22+
package_dir={'': 'src'},
23+
packages=find_namespace_packages(where='src', exclude=('tests')),
24+
install_requires=[
25+
"streamlit",
26+
"pandas",
27+
"numpy",
28+
"altair",
29+
"pytest",
30+
"dash",
31+
"dash_bootstrap_components",
32+
"pyyaml",
33+
"gunicorn",
34+
"selenium"
35+
],
3736
classifiers=[
3837
"Programming Language :: Python :: 3",
3938
"License :: OSI Approved :: MIT License",
4039
"Operating System :: OS Independent",
4140
],
42-
entry_points={"console_scripts": ["penn_chime=penn_chime.cli:main"]},
41+
python_requires='>=3.7',
42+
entry_points = {
43+
'console_scripts': ['penn_chime=penn_chime.cli:main'],
44+
},
4345
keywords=[],
4446
include_package_data=True,
4547
)
48+

src/app.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
write_definitions,
1313
write_footer,
1414
)
15-
from penn_chime.settings import DEFAULTS
15+
from penn_chime.settings import get_defaults
1616
from penn_chime.models import SimSirModel
1717
from penn_chime.charts import (
1818
build_admits_chart,
@@ -28,18 +28,19 @@
2828
# In dev, this should be shown
2929
st.markdown(hide_menu_style, unsafe_allow_html=True)
3030

31-
p = display_sidebar(st, DEFAULTS)
31+
d = get_defaults()
32+
p = display_sidebar(st, d)
3233
m = SimSirModel(p)
3334

3435
display_header(st, m, p)
3536

3637
if st.checkbox("Show more info about this tool"):
3738
notes = "The total size of the susceptible population will be the entire catchment area for our hospitals."
38-
display_more_info(st=st, model=m, parameters=p, defaults=DEFAULTS, notes=notes)
39+
display_more_info(st=st, model=m, parameters=p, defaults=d, notes=notes)
3940

4041
st.subheader("New Admissions")
4142
st.markdown("Projected number of **daily** COVID-19 admissions. \n\n _NOTE: Now including estimates of prior admissions for comparison._")
42-
admits_chart = build_admits_chart(alt=alt, admits_df=m.admits_df, max_y_axis=p.max_y_axis)
43+
admits_chart = build_admits_chart(alt=alt, admits_floor_df=m.admits_floor_df, max_y_axis=p.max_y_axis)
4344
st.altair_chart(admits_chart, use_container_width=True)
4445
st.markdown(build_descriptions(chart=admits_chart, labels=p.labels, suffix=" Admissions"))
4546
display_download_link(
@@ -53,15 +54,15 @@
5354
if not st.checkbox("Show Daily Counts"):
5455
admits_modulo = 7
5556
table_df = build_table(
56-
df=m.admits_df,
57+
df=m.admits_floor_df,
5758
labels=p.labels,
5859
modulo=admits_modulo)
5960
st.table(table_df)
6061

6162

6263
st.subheader("Admitted Patients (Census)")
6364
st.markdown("Projected **census** of COVID-19 patients, accounting for arrivals and discharges \n\n _NOTE: Now including estimates of prior census for comparison._")
64-
census_chart = build_census_chart(alt=alt, census_df=m.census_df, max_y_axis=p.max_y_axis)
65+
census_chart = build_census_chart(alt=alt, census_floor_df=m.census_floor_df, max_y_axis=p.max_y_axis)
6566
st.altair_chart(census_chart, use_container_width=True)
6667
st.markdown(build_descriptions(chart=census_chart, labels=p.labels, suffix=" Census"))
6768
display_download_link(
@@ -75,15 +76,15 @@
7576
if not st.checkbox("Show Daily Census Counts"):
7677
census_modulo = 7
7778
table_df = build_table(
78-
df=m.census_df,
79+
df=m.census_floor_df,
7980
labels=p.labels,
8081
modulo=census_modulo)
8182
st.table(table_df)
8283

8384

8485
st.subheader("Susceptible, Infected, and Recovered")
8586
st.markdown("The number of susceptible, infected, and recovered individuals in the hospital catchment region at any given moment")
86-
sim_sir_w_date_chart = build_sim_sir_w_date_chart(alt=alt, sim_sir_w_date_df=m.sim_sir_w_date_df)
87+
sim_sir_w_date_chart = build_sim_sir_w_date_chart(alt=alt, sim_sir_w_date_floor_df=m.sim_sir_w_date_floor_df)
8788
st.altair_chart(sim_sir_w_date_chart, use_container_width=True)
8889
display_download_link(
8990
st,
@@ -93,7 +94,7 @@
9394

9495
if st.checkbox("Show SIR Simulation in tabular form"):
9596
table_df = build_table(
96-
df=m.sim_sir_w_date_df,
97+
df=m.sim_sir_w_date_floor_df,
9798
labels=p.labels)
9899
st.table(table_df)
99100

src/chime_dash/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This directory provides the interface for the dash app.
44

5-
![Current interface](docs/assets/interface.png)
5+
![Current interface](docs/interface.png)
66

77
## Tree
88
Structure of the app

src/chime_dash/__init__.py

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,51 @@
1-
x = 1
1+
"""
2+
chime_dash/app
3+
4+
dash instance defined here
5+
"""
6+
7+
from dash import Dash
8+
from typing import TypeVar
9+
from chime_dash.app.config import from_object
10+
from penn_chime.settings import get_defaults
11+
from chime_dash.app.components import Body
12+
from chime_dash.app.utils.callbacks import wrap_callbacks
13+
14+
DashAppInstance = TypeVar('DashAppInstance')
15+
DEFAULTS = get_defaults()
16+
17+
18+
def create_app(context: str = 'prod') -> DashAppInstance:
19+
"""
20+
create_app initializes the app instance
21+
22+
Args:
23+
context (str, optional): One of either 'prod', 'dev', 'testing.
24+
Defaults to 'prod' where dash.Dash.run_server(debug=False).
25+
Change to 'dev' or 'test' to set debug to true.
26+
27+
Returns:
28+
Env: Config variables based on context argument received
29+
DashAppInstance: Dash instance with appropriate configuration settings
30+
"""
31+
32+
Env = from_object(context)
33+
34+
LANGUAGE = Env.LANG
35+
body = Body(LANGUAGE, DEFAULTS)
36+
37+
38+
App = Dash(
39+
__name__,
40+
external_stylesheets=body.external_stylesheets,
41+
external_scripts=body.external_scripts,
42+
)
43+
44+
App.title = Env.CHIME_TITLE
45+
App.layout = body.html
46+
wrap_callbacks(App)
47+
48+
49+
50+
return Env, App
51+

src/chime_dash/app/components/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
1212
from dash_html_components import Div
1313

1414
from penn_chime.parameters import Parameters
15-
from penn_chime.settings import DEFAULTS
15+
from penn_chime.settings import get_defaults
1616

1717
from chime_dash.app.utils.templates import read_localization_yml, read_localization_markdown
1818

19+
DEFAULTS = get_defaults()
20+
1921

2022
class Component(ABC):
2123
"""Base component for rendering dash html objects and registering callbacks

0 commit comments

Comments
 (0)