@@ -23,72 +23,73 @@ def run_module():
23
23
start_time = time .time ()
24
24
params = read_params ()
25
25
logger = get_structured_logger (
26
- __name__ , filename = params .get ("log_filename" ),
27
- log_exceptions = params .get ("log_exceptions" , True ))
26
+ __name__ , filename = params [ "common" ] .get ("log_filename" ),
27
+ log_exceptions = params [ "common" ] .get ("log_exceptions" , True ))
28
28
29
29
# handle range of estimates to produce
30
30
# filename expected to have format: EDI_AGG_INPATIENT_DDMMYYYY_HHMM{timezone}.csv.gz
31
- if params ["drop_date" ] is None :
31
+ if params ["indicator" ][ " drop_date" ] is None :
32
32
dropdate_dt = datetime .strptime (
33
- Path (params ["input_file" ]).name .split ("_" )[3 ], "%d%m%Y" )
33
+ Path (params ["indicator" ][ " input_file" ]).name .split ("_" )[3 ], "%d%m%Y" )
34
34
else :
35
- dropdate_dt = datetime .strptime (params ["drop_date" ], "%Y-%m-%d" )
35
+ dropdate_dt = datetime .strptime (params ["indicator" ][ " drop_date" ], "%Y-%m-%d" )
36
36
37
37
# produce estimates for n_backfill_days
38
38
# most recent n_waiting_days won't be est
39
- enddate_dt = dropdate_dt - timedelta (days = params ["n_waiting_days" ])
40
- startdate_dt = enddate_dt - timedelta (days = params ["n_backfill_days" ])
39
+ enddate_dt = dropdate_dt - timedelta (days = params ["indicator" ][ " n_waiting_days" ])
40
+ startdate_dt = enddate_dt - timedelta (days = params ["indicator" ][ " n_backfill_days" ])
41
41
enddate = str (enddate_dt .date ())
42
42
startdate = str (startdate_dt .date ())
43
43
dropdate = str (dropdate_dt .date ())
44
44
45
45
# now allow manual overrides
46
- if params ["end_date" ] is not None :
47
- enddate = params ["end_date" ]
48
- if params ["start_date" ] is not None :
49
- startdate = params ['start_date' ]
46
+ if params ["indicator" ][ " end_date" ] is not None :
47
+ enddate = params ["indicator" ][ " end_date" ]
48
+ if params ["indicator" ][ " start_date" ] is not None :
49
+ startdate = params ["indicator" ][ 'start_date' ]
50
50
51
51
# print out information
52
52
logger .info ("Loaded params" ,
53
53
startdate = startdate ,
54
54
enddate = enddate ,
55
55
dropdate = dropdate ,
56
- n_backfill_days = params ["n_backfill_days" ],
57
- n_waiting_days = params ["n_waiting_days" ],
58
- geos = params ["geos" ],
59
- outpath = params ["export_dir" ],
60
- parallel = params ["parallel" ],
61
- weekday = params ["weekday" ],
62
- write_se = params ["write_se" ])
56
+ n_backfill_days = params ["indicator" ][ " n_backfill_days" ],
57
+ n_waiting_days = params ["indicator" ][ " n_waiting_days" ],
58
+ geos = params ["indicator" ][ " geos" ],
59
+ outpath = params ["common" ][ " export_dir" ],
60
+ parallel = params ["indicator" ][ " parallel" ],
61
+ weekday = params ["indicator" ][ " weekday" ],
62
+ write_se = params ["indicator" ][ " write_se" ])
63
63
64
64
# generate indicator csvs
65
- for geo in params ["geos" ]:
66
- for weekday in params ["weekday" ]:
65
+ for geo in params ["indicator" ][ " geos" ]:
66
+ for weekday in params ["indicator" ][ " weekday" ]:
67
67
if weekday :
68
68
logger .info ("starting weekday adj" , geo = geo )
69
69
else :
70
70
logger .info ("starting no weekday adj" , geo = geo )
71
71
72
72
signal_name = Config .signal_weekday_name if weekday else Config .signal_name
73
- if params ["write_se" ]:
74
- assert params ["obfuscated_prefix" ] is not None , \
73
+ if params ["indicator" ][ " write_se" ]:
74
+ assert params ["indicator" ][ " obfuscated_prefix" ] is not None , \
75
75
"supply obfuscated prefix in params.json"
76
- signal_name = params ["obfuscated_prefix" ] + "_" + signal_name
76
+ signal_name = params ["indicator" ][ " obfuscated_prefix" ] + "_" + signal_name
77
77
78
78
logger .info ("Updating signal name" , signal_name = signal_name )
79
79
updater = ClaimsHospIndicatorUpdater (
80
80
startdate ,
81
81
enddate ,
82
82
dropdate ,
83
83
geo ,
84
- params ["parallel" ],
84
+ params ["indicator" ][ " parallel" ],
85
85
weekday ,
86
- params ["write_se" ],
86
+ params ["indicator" ][ " write_se" ],
87
87
signal_name
88
88
)
89
- updater .update_indicator (params ["input_file" ], params ["export_dir" ])
89
+ updater .update_indicator (params ["indicator" ]["input_file" ],
90
+ params ["common" ]["export_dir" ])
90
91
logger .info ("finished updating" , geo = geo )
91
-
92
+
92
93
elapsed_time_in_seconds = round (time .time () - start_time , 2 )
93
94
logger .info ("Completed indicator run" ,
94
95
elapsed_time_in_seconds = elapsed_time_in_seconds )
0 commit comments