@@ -26,27 +26,33 @@ def run_module():
26
26
27
27
logging .basicConfig (level = logging .DEBUG )
28
28
29
- ## download recent files from FTP server
30
- logging .info ("downloading recent files through SFTP" )
31
- download (params ["cache_dir" ], params ["ftp_conn" ])
32
-
33
- ## get end date from input file
34
29
# the filenames are expected to be in the format:
35
30
# Denominator: "YYYYMMDD_All_Outpatients_By_County.dat.gz"
36
31
# Numerator: "YYYYMMDD_Covid_Outpatients_By_County.dat.gz"
37
32
33
+ assert (params ["input_denom_file" ] is None ) == (params ["input_covid_file" ] is None ), \
34
+ "exactly one of denom and covid files are provided"
35
+
38
36
if params ["drop_date" ] is None :
39
- dropdate_denom = datetime .strptime (
40
- Path (params ["input_denom_file" ]).name .split ("_" )[0 ], "%Y%m%d"
41
- )
42
-
43
- dropdate_covid = datetime .strptime (
44
- Path (params ["input_covid_file" ]).name .split ("_" )[0 ], "%Y%m%d"
45
- )
46
- assert dropdate_denom == dropdate_covid , "different drop dates for data files"
47
- dropdate_dt = dropdate_denom
37
+ # files are dropped about 8pm the day after the issue date
38
+ dropdate_dt = (datetime .now () - timedelta (days = 1 ,hours = 20 ))
39
+ dropdate_dt = dropdate_dt .replace (hour = 0 ,minute = 0 ,second = 0 ,microsecond = 0 )
48
40
else :
49
41
dropdate_dt = datetime .strptime (params ["drop_date" ], "%Y-%m-%d" )
42
+ filedate = dropdate_dt .strftime ("%Y%m%d" )
43
+
44
+ if params ["input_denom_file" ] is None :
45
+
46
+ ## download recent files from FTP server
47
+ logging .info ("downloading recent files through SFTP" )
48
+ download (params ["cache_dir" ], params ["ftp_conn" ])
49
+
50
+ input_denom_file = "%s/%s_All_Outpatients_By_County.dat.gz" % (params ["cache_dir" ],filedate )
51
+ input_covid_file = "%s/%s_Covid_Outpatients_By_County.dat.gz" % (params ["cache_dir" ],filedate )
52
+ else :
53
+ input_denom_file = params ["input_denom_file" ]
54
+ input_covid_file = params ["input_covid_file" ]
55
+
50
56
dropdate = str (dropdate_dt .date ())
51
57
52
58
# range of estimates to produce
@@ -93,8 +99,8 @@ def run_module():
93
99
params ["se" ]
94
100
)
95
101
su_inst .update_sensor (
96
- params [ " input_denom_file" ] ,
97
- params [ " input_covid_file" ] ,
102
+ input_denom_file ,
103
+ input_covid_file ,
98
104
params ["export_dir" ]
99
105
)
100
106
logging .info ("finished %s" , geo )
0 commit comments