Skip to content

Commit 324a2f8

Browse files
authored
Merge pull request #929 from cmu-delphi/main
Deploy correct hush for SirCAL to production
2 parents 9408852 + 5c74cb6 commit 324a2f8

File tree

7 files changed

+28
-16
lines changed

7 files changed

+28
-16
lines changed

_delphi_utils_python/delphi_utils/validator/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ Please update the follow settings:
5353

5454
* `common`: global validation settings
5555
* `data_source`: should match the [formatting](https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html) as used in COVIDcast API calls
56-
* `end_date`: specifies the last date to be checked; if set to "latest", `end_date` will always be the current date
57-
* `span_length`: specifies the number of days before the `end_date` to check. `span_length` should be long enough to contain all recent source data that is still in the process of being updated (i.e. in the backfill period), for example, if the data source of interest has a 2-week lag before all reports are in for a given date, `scan_length` should be 14 days
56+
* `end_date`: specifies the last date to be checked; this can be specified as `YYYY-MM-DD` or as `today-{num}`. The latter is interpretted as `num` days before the current date (with `today-0` being today).
57+
* `span_length`: specifies the number of days before the `end_date` to check. `span_length` should be long enough to contain all recent source data that is still in the process of being updated (i.e. in the backfill period), for example, if the data source of interest has a 2-week lag before all reports are in for a given date, `span_length` should be 14 days
5858
* `suppressed_errors`: list of objects specifying errors that have been manually verified as false positives or acceptable deviations from expected. These errors can be specified with the following variables, where omitted values are interpreted as a wildcard, i.e., not specifying a date applies to all dates:
5959
* `check_name` (required): name of the check, as specified in the validation output
6060
* `date`: date in `YYYY-MM-DD` format

_delphi_utils_python/delphi_utils/validator/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ def __post_init__(self):
3535
def from_params(cls, end_date_str: str, span_length_int: int):
3636
"""Create a TimeWindow from param representations of its members."""
3737
span_length = timedelta(days=span_length_int)
38-
if end_date_str == "latest":
39-
end_date = date.today()
38+
if end_date_str.startswith("today-"):
39+
days_back = timedelta(days=int(end_date_str[6:]))
40+
end_date = date.today() - days_back
4041
else:
4142
end_date = datetime.strptime(end_date_str, '%Y-%m-%d').date()
4243
return cls(end_date, span_length)

_delphi_utils_python/tests/validator/test_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,8 @@ def test_string_init(self):
4545
"""Test that TimeWindows can be derived from strings."""
4646
window = TimeWindow.from_params("2020-08-23", 366)
4747
assert window.start_date == date(2019, 8, 23)
48-
latest_window = TimeWindow.from_params("latest", 1897)
48+
latest_window = TimeWindow.from_params("today-0", 1897)
4949
assert latest_window.start_date == date(2014, 12, 5)
50+
latest_window = TimeWindow.from_params("today-10", 3)
51+
assert latest_window.end_date == date(2020, 2, 4)
52+
assert latest_window.start_date == date(2020, 2, 1)

ansible/templates/sir_complainsalot-params-prod.json.j2

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"channel": "#sir-complains-a-lot",
32
"log_filename": "/var/log/indicators/sircal.log",
43
"slack_token": "{{ sir_complainsalot_slack_token }}",
54
"sources": {

facebook/delphiFacebook/R/binary.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,9 @@ get_binary_indicators <- function() {
115115
"smoothed_wvaccine_likely_govt_health", "weight", "v_vaccine_likely_govt_health", 6, compute_binary_response, jeffreys_binary,
116116
"smoothed_vaccine_likely_politicians", "weight_unif", "v_vaccine_likely_politicians", 6, compute_binary_response, jeffreys_binary,
117117
"smoothed_wvaccine_likely_politicians", "weight", "v_vaccine_likely_politicians", 6, compute_binary_response, jeffreys_binary,
118-
118+
"smoothed_vaccine_likely_doctors", "weight_unif", "v_vaccine_likely_doctors", 6, compute_binary_response, jeffreys_binary,
119+
"smoothed_wvaccine_likely_doctors", "weight", "v_vaccine_likely_doctors", 6, compute_binary_response, jeffreys_binary,
120+
119121
# vaccine hesitancy reasons
120122
"smoothed_hesitancy_reason_sideeffects", "weight_unif", "v_hesitancy_reason_sideeffects", 6, compute_binary_response, jeffreys_binary,
121123
"smoothed_whesitancy_reason_sideeffects", "weight", "v_hesitancy_reason_sideeffects", 6, compute_binary_response, jeffreys_binary,

facebook/delphiFacebook/R/variables.R

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,16 +342,25 @@ code_vaccines <- function(input_data) {
342342

343343
if ("V4_1" %in% names(input_data)) {
344344
input_data$v_vaccine_likely_friends <- input_data$V4_1 == 1
345-
input_data$v_vaccine_likely_local_health <- input_data$V4_2 == 1
346345
input_data$v_vaccine_likely_who <- input_data$V4_3 == 1
347346
input_data$v_vaccine_likely_govt_health <- input_data$V4_4 == 1
348347
input_data$v_vaccine_likely_politicians <- input_data$V4_5 == 1
348+
349+
if (wave < 8) {
350+
input_data$v_vaccine_likely_local_health <- input_data$V4_2 == 1
351+
input_data$v_vaccine_likely_doctors <- NA_real_
352+
} else {
353+
input_data$v_vaccine_likely_local_health <- NA_real_
354+
input_data$v_vaccine_likely_doctors <- input_data$V4_2 == 1
355+
}
356+
349357
} else {
350358
input_data$v_vaccine_likely_friends <- NA_real_
351359
input_data$v_vaccine_likely_local_health <- NA_real_
352360
input_data$v_vaccine_likely_who <- NA_real_
353361
input_data$v_vaccine_likely_govt_health <- NA_real_
354362
input_data$v_vaccine_likely_politicians <- NA_real_
363+
input_data$v_vaccine_likely_doctors <- NA_real_
355364
}
356365

357366
if ("V5a" %in% names(input_data) && "V5b" %in% names(input_data) && "V5c" %in% names(input_data)) {

sir_complainsalot/delphi_sir_complainsalot/run.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,13 @@ def split_complaints(complaints, n=49):
5050

5151

5252
def report_complaints(all_complaints, slack_notifier):
53-
"""Post complaints to Slack."""
54-
if not slack_notifier:
55-
print("(dry-run)")
56-
return
53+
"""Log complaints and optionally post to Slack."""
5754

5855
for complaints in split_complaints(all_complaints):
59-
blocks = format_complaints_aggregated_by_source(complaints)
60-
print(f"blocks: {len(blocks)}")
61-
slack_notifier.post_message(blocks)
56+
blocks = format_and_log_complaints_aggregated_by_source(complaints)
57+
58+
if slack_notifier:
59+
slack_notifier.post_message(blocks)
6260

6361
def get_maintainers_block(complaints):
6462
"""Build a Slack block to alert maintainers to pay attention."""
@@ -79,7 +77,7 @@ def get_maintainers_block(complaints):
7977
return maintainers_block
8078

8179

82-
def format_complaints_aggregated_by_source(complaints):
80+
def format_and_log_complaints_aggregated_by_source(complaints):
8381
"""Build formatted Slack message for posting to the API, aggregating
8482
complaints by source to reduce the number of blocks."""
8583

0 commit comments

Comments
 (0)