Skip to content

Commit 1497520

Browse files
authored
Merge branch 'develop' into PhilMiller/model-performance
2 parents d328da3 + 4a29aab commit 1497520

File tree

10 files changed

+299
-201
lines changed

10 files changed

+299
-201
lines changed

.github/workflows/pythonapp.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ on:
1515
jobs:
1616
build:
1717
runs-on: ubuntu-latest
18-
1918
steps:
2019
- uses: actions/checkout@v2
2120
- name: Set up Python 3.8
@@ -33,6 +32,11 @@ jobs:
3332
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
3433
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3534
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
35+
- name: Check formatting with black
36+
run: |
37+
# exit if any files still need formatting
38+
bash script/format --check
39+
continue-on-error: true
3640
- name: Test with pytest
3741
run: |
3842
pip install pytest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Editors
22
.idea/
3+
.vscode/settings.json
34

45
# Environments
56
.env

Pipfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ url = "https://pypi.org/simple"
44
verify_ssl = true
55

66
[dev-packages]
7+
black = "==19.10b0"
8+
pytest = "*"
79

810
[packages]
911
streamlit = "*"
1012
pandas = "*"
1113
numpy = "*"
12-
pytest = "*"
1314
altair = "*"
1415
dash = "*"
1516
dash-bootstrap-components = "*"
@@ -18,3 +19,6 @@ PyYAML = "*"
1819

1920
[requires]
2021
python_version = "3.7"
22+
23+
[pipenv]
24+
allow_prereleases = true

Pipfile.lock

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

docs/contributing/app-dev.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ See [Streamlit's Getting Started guide](https://docs.streamlit.io/getting_starte
2323

2424
```bash
2525
pipenv shell
26-
pipenv install
26+
pipenv sync --dev
2727
streamlit run src/app.py
2828
```
2929

k8s.preprod/app-ingress.yaml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,13 @@ metadata:
1313
# allow requests larger than 1MiB
1414
nginx.ingress.kubernetes.io/proxy-body-size: "0"
1515
nginx.ingress.kubernetes.io/configuration-snippet: |
16-
location / {
17-
sub_filter </head>
18-
'<!-- Google Tag Manager -->
19-
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
20-
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
21-
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
22-
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
23-
})(window,document,'script','dataLayer','GTM-KBZ6ZKX');</script>
24-
<!-- End Google Tag Manager -->';
25-
sub_filter </body>
26-
'<!-- Google Tag Manager (noscript) -->
27-
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KBZ6ZKX"
28-
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
29-
<!-- End Google Tag Manager (noscript) -->'
30-
sub_filter_once on;
31-
}
16+
# Inject Google Tag Manager:
17+
18+
proxy_set_header Accept-Encoding ""; # upstream compression must be disabled
19+
20+
sub_filter '</head>' '<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({"gtm.start": new Date().getTime(),event:"gtm.js"});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!="dataLayer"?"&l="+l:"";j.async=true;j.src="https://www.googletagmanager.com/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f); })(window,document,"script","dataLayer","GTM-KBZ6ZKX");</script></head>';
21+
22+
sub_filter '</body>' '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KBZ6ZKX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript></body>';
3223
spec:
3324
tls:
3425
- hosts:
@@ -62,7 +53,6 @@ metadata:
6253
proxy_cache_bypass $http_x_purge;
6354
proxy_cache_key $proxy_upstream_name$request_uri;
6455
proxy_cache_lock on;
65-
proxy_cache_use_stale updating;
6656
add_header X-Cache-Status $upstream_cache_status;
6757
spec:
6858
rules:

k8s.prod/app-ingress.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ metadata:
1212
certmanager.k8s.io/cluster-issuer: letsencrypt-prod
1313
# allow requests larger than 1MiB
1414
nginx.ingress.kubernetes.io/proxy-body-size: "0"
15+
nginx.ingress.kubernetes.io/configuration-snippet: |
16+
# Inject Google Tag Manager:
17+
18+
proxy_set_header Accept-Encoding ""; # upstream compression must be disabled
19+
20+
sub_filter '</head>' '<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({"gtm.start": new Date().getTime(),event:"gtm.js"});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!="dataLayer"?"&l="+l:"";j.async=true;j.src="https://www.googletagmanager.com/gtm.js?id="+i+dl;f.parentNode.insertBefore(j,f); })(window,document,"script","dataLayer","GTM-KBZ6ZKX");</script></head>';
21+
22+
sub_filter '</body>' '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KBZ6ZKX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript></body>';
1523
spec:
1624
tls:
1725
- hosts:
@@ -71,7 +79,6 @@ metadata:
7179
proxy_cache_bypass $http_x_purge;
7280
proxy_cache_key $proxy_upstream_name$request_uri;
7381
proxy_cache_lock on;
74-
proxy_cache_use_stale updating;
7582
add_header X-Cache-Status $upstream_cache_status;
7683
spec:
7784
rules:

script/format

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
# script/format: Format python code
4+
5+
set -e
6+
cd "$(dirname "$0")/.."
7+
8+
FILES_TO_FORMAT="src/ tests/ setup.py"
9+
10+
if [ "$1" = "--check" ]; then
11+
python -m black --check ${FILES_TO_FORMAT}
12+
else
13+
python -m black ${FILES_TO_FORMAT}
14+
fi

setup.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,17 @@
2222
package_dir={'': 'src'},
2323
packages=find_namespace_packages(where='src', exclude=('tests')),
2424
install_requires=[
25-
"streamlit",
26-
"pandas",
27-
"numpy",
2825
"altair",
29-
"pytest",
26+
"black",
27+
"gunicorn",
3028
"dash",
3129
"dash_bootstrap_components",
30+
"numpy",
31+
"pandas",
32+
"pytest",
3233
"pyyaml",
33-
"gunicorn",
34-
"selenium"
34+
"selenium",
35+
"streamlit",
3536
],
3637
classifiers=[
3738
"Programming Language :: Python :: 3",

src/penn_chime/parameters.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(
5757
relative_contact_rate: float,
5858
mitigation_date: Optional[date] = None,
5959
ventilated: Disposition,
60-
current_date: date = date.today(),
60+
current_date: Optional[date] = None,
6161
date_first_hospitalized: Optional[date] = None,
6262
doubling_time: Optional[float] = None,
6363
infectious_days: int = 14,
@@ -69,7 +69,6 @@ def __init__(
6969
region: Optional[Regions] = None,
7070
):
7171
self.current_hospitalized = Positive(value=current_hospitalized)
72-
7372
Rate(value=hospitalized.rate), Rate(value=icu.rate), Rate(value=ventilated.rate)
7473
StrictlyPositive(value=hospitalized.days), StrictlyPositive(value=icu.days),
7574
StrictlyPositive(value=ventilated.days)
@@ -87,8 +86,10 @@ def __init__(
8786
else:
8887
raise AssertionError('population or regions must be provided.')
8988

89+
if current_date is None:
90+
current_date = date.today()
9091
self.current_date = Date(value=current_date)
91-
92+
9293
self.date_first_hospitalized = OptionalDate(value=date_first_hospitalized)
9394
self.doubling_time = OptionalStrictlyPositive(value=doubling_time)
9495

0 commit comments

Comments
 (0)