Skip to content

Commit 41e1584

Browse files
committed
params refactor
1 parent f00586e commit 41e1584

File tree

2 files changed

+27
-23
lines changed

2 files changed

+27
-23
lines changed

changehc/delphi_changehc/run.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
def retrieve_files(params, filedate):
2222
"""Return filenames of relevant files, downloading them if necessary
2323
"""
24-
if params["input_denom_file"] is None:
24+
files = params["input_files"]
25+
if files["denom"] is None:
2526

2627
## download recent files from FTP server
2728
logging.info("downloading recent files through SFTP")
@@ -37,12 +38,12 @@ def retrieve_files(params, filedate):
3738
flu_like_file = "%s/%s_Flu_Like_Patient_Count_By_County.dat.gz" % (params["cache_dir"],filedate)
3839
covid_like_file = "%s/%s_Covid_Like_Patient_Count_By_County.dat.gz" % (params["cache_dir"],filedate)
3940
else:
40-
denom_file = params["input_denom_file"]
41-
covid_file = params["input_covid_file"]
42-
flu_file = params["input_flu_file"]
43-
mixed_file = params["input_mixed_file"]
44-
flu_like_file = params["input_flu_like_file"]
45-
covid_like_file = params["input_covid_like_file"]
41+
denom_file = files["denom"]
42+
covid_file = files["covid"]
43+
flu_file = files["flu"]
44+
mixed_file = files["mixed"]
45+
flu_like_file = files["flu_like"]
46+
covid_like_file = files["covid_like"]
4647

4748
file_dict = {"denom": denom_file}
4849
if "covid" in params["types"]:
@@ -58,21 +59,22 @@ def retrieve_files(params, filedate):
5859
def make_asserts(params):
5960
"""Assert that for each type, filenames are either all present or all absent
6061
"""
62+
files = params["input_files"]
6163
if "covid" in params["types"]:
62-
assert (params["input_denom_file"] is None) == (params["input_covid_file"] is None), \
64+
assert (files["denom"] is None) == (files["covid"] is None), \
6365
"exactly one of denom and covid files are provided"
6466
if "cli" in params["types"]:
65-
if params["input_denom_file"] is None:
66-
assert params["input_flu_file"] is None and \
67-
params["input_mixed_file"] is None and \
68-
params["input_flu_like_file"] is None and \
69-
params["input_covid_like_file"] is None,\
67+
if files["denom"] is None:
68+
assert files["flu"] is None and \
69+
files["mixed"] is None and \
70+
files["flu_like"] is None and \
71+
files["covid_like"] is None,\
7072
"files must be all present or all absent"
7173
else:
72-
assert params["input_flu_file"] is not None and \
73-
params["input_mixed_file"] is not None and \
74-
params["input_flu_like_file"] is not None and \
75-
params["input_covid_like_file"] is not None,\
74+
assert files["flu"] is not None and \
75+
files["mixed"] is not None and \
76+
files["flu_like"] is not None and \
77+
files["covid_like"] is not None,\
7678
"files must be all present or all absent"
7779

7880

changehc/params.json.template

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"static_file_dir": "./static",
33
"export_dir": "./receiving",
44
"cache_dir": "./cache",
5-
"input_denom_file": null,
6-
"input_covid_file": null,
7-
"input_flu_file": null,
8-
"input_mixed_file": null,
9-
"input_flu_like_file": null,
10-
"input_covid_like_file": null,
5+
"input_files": {
6+
"denom": null,
7+
"covid": null,
8+
"flu": null,
9+
"mixed": null,
10+
"flu_like": null,
11+
"covid_like": null
12+
},
1113
"start_date": "2020-02-01",
1214
"end_date": null,
1315
"drop_date": null,

0 commit comments

Comments
 (0)