Skip to content

Release 0.1.4 #1138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c818bc6
clarify old_item requirements for replacements
nmdefries Jul 9, 2021
0ba761d
add timezone to date metadata field descriptions
nmdefries Jul 9, 2021
e84c4bc
update replacements mapping
nmdefries Jul 12, 2021
7ac4439
change write procedure to display correctly in Excel
nmdefries Jul 13, 2021
abc6200
Revert "Revert "Add workflow to automate fb package testing""
nmdefries Jul 13, 2021
ead5d60
remove 'suggested' dependencies
nmdefries Jul 12, 2021
4ee90dd
format choice coding as json string
nmdefries Jul 15, 2021
e058518
Merge branch 'main' into fb-package-codebook-feedback
nmdefries Jul 15, 2021
69fcb6a
remove choices for other_text items
nmdefries Jul 16, 2021
2f5dfb0
Merge pull request #1126 from cmu-delphi/bot/sync-prod-main
krivard Jul 19, 2021
ede2410
Merge pull request #1118 from cmu-delphi/survey-ci-reduce-packages
krivard Jul 19, 2021
7667b5e
Add missing sources to sirCAL
krivard Jul 19, 2021
d1702c2
create function to get every fourth date of input
nmdefries Apr 9, 2021
aac1d79
fetch filenames that meet active/dormant criteria
nmdefries Apr 16, 2021
0517cb4
update tests
nmdefries Apr 16, 2021
0292c1b
output list of input files to txt
nmdefries Apr 26, 2021
cfc5e91
remove saved input txt file from testing
nmdefries Apr 26, 2021
996f0d0
Adjust nchs-mortality max_age in sirCAL
krivard Jul 20, 2021
e7dcded
replace deprecated arg in write_csv
nmdefries Jul 20, 2021
24f0afc
Fix nchs-mortality max age in both files
krivard Jul 20, 2021
6fd189f
Merge pull request #1127 from cmu-delphi/krivard/update-sircal-extent
krivard Jul 20, 2021
07f606d
Modify summary for alerts
qx-teo Jul 20, 2021
4ba5467
prevent readr from being updated
nmdefries Jul 20, 2021
9cce594
correct filename date reference to end date
nmdefries Jul 20, 2021
cbff6b0
simplify func to get every fourth data file
nmdefries Jul 20, 2021
472ff22
deduplicate keep_dates if a multiple of 4
nmdefries Jul 20, 2021
8734663
remove empty test file
nmdefries Jul 20, 2021
d2eb278
explicitly install desired readr version if missing
nmdefries Jul 20, 2021
a561e94
switch to daily caching
nmdefries Jul 20, 2021
22dc189
Merge pull request #1129 from cmu-delphi/contingency-write-csv-path-fix
krivard Jul 21, 2021
5f5f014
update test filename expectations
nmdefries Jul 21, 2021
1568b88
set expectation for skipped filename test
nmdefries Jul 21, 2021
5bd0aa8
Merge branch 'main' into survey-ci-daily-caching
nmdefries Jul 21, 2021
b32a4dc
compare sets instead of sorting for robustness
nmdefries Jul 21, 2021
12d0f65
Merge branch 'main' into contingency-autoset-input-files
nmdefries Jul 21, 2021
c18b666
comments
nmdefries Jul 21, 2021
9eb588b
Merge pull request #1109 from cmu-delphi/fb-package-codebook-feedback
krivard Jul 21, 2021
48c1ca0
Merge pull request #1130 from cmu-delphi/validator-summary-alert
krivard Jul 21, 2021
f8b46ea
Merge pull request #1133 from cmu-delphi/survey-ci-daily-caching
krivard Jul 21, 2021
e9b90cd
Merge pull request #1132 from cmu-delphi/contingency-autoset-input-files
krivard Jul 22, 2021
b183661
Remove smoothed version of cumulative signals
chinandrew Jul 23, 2021
efde789
fix logic
chinandrew Jul 24, 2021
8f1e70f
Add combo test
chinandrew Jul 24, 2021
3bca88e
fix indent
chinandrew Jul 24, 2021
488a9d1
fix test
chinandrew Jul 24, 2021
3b5a791
Merge pull request #1136 from cmu-delphi/remove-7dav-cumulative
krivard Jul 26, 2021
ac9660d
chore: release 0.1.4
krivard Jul 26, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Python package

on:
push:
branches: [ main, prod, 'release/*' ]
branches: [ main, prod ]
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
branches: [ main, prod ]
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/r-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
#
# See https://github.com/r-lib/actions/tree/master/examples#readme for
# additional example workflows available for the R community.

name: R facebook survey

on:
push:
branches: [ main, prod ]
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
branches: [ main, prod ]

jobs:
build:
runs-on: ubuntu-20.04
if: github.event.pull_request.draft == false
strategy:
matrix:
r-version: [4.0]
defaults:
run:
working-directory: facebook/delphiFacebook

steps:
- uses: actions/checkout@v2
- name: Set up R ${{ matrix.r-version }}
uses: r-lib/actions/setup-r@v1
with:
r-version: ${{ matrix.r-version }}
- name: Install linux dependencies
run: |
sudo apt-get install libcurl4-openssl-dev
- name: Get date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-r-facebook-survey-${{ steps.get-date.outputs.date }}
restore-keys: |
${{ runner.os }}-r-facebook-survey-
- name: Install R dependencies
run: |
if ( packageVersion("readr") != "1.4.0" ) {
install.packages("devtools")
devtools::install_version("readr", version = "1.4.0")
}
install.packages("remotes")
remotes::update_packages(c("rcmdcheck", "mockr"), upgrade="always")
dependency_list <- remotes::dev_package_deps(dependencies=TRUE)
remotes::update_packages(dependency_list$package[dependency_list$package != "readr"], upgrade="always")
shell: Rscript {0}
- name: Check
run: |
rcmdcheck::rcmdcheck(args = c("--no-manual", "--test-dir=unit-tests"), error_on = "error")
shell: Rscript {0}
2 changes: 1 addition & 1 deletion _delphi_utils_python/.bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.3
current_version = 0.1.4
commit = False
tag = False
tag_name = delphi-utils/v{new_version}
Expand Down
2 changes: 1 addition & 1 deletion _delphi_utils_python/delphi_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
from .signal import add_prefix
from .nancodes import Nans

__version__ = "0.1.3"
__version__ = "0.1.4"
32 changes: 20 additions & 12 deletions _delphi_utils_python/delphi_utils/validator/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
class ValidationReport:
"""Class for reporting the results of validation."""

def __init__(self, errors_to_suppress: List[ValidationFailure]):
def __init__(self, errors_to_suppress: List[ValidationFailure], data_source: str = ""):
"""Initialize a ValidationReport.

Parameters
----------
errors_to_suppress: List[ValidationFailure]
List of ValidationFailures to ignore.
data_source: str
Name of data source as obtained from params

Attributes
----------
errors_to_suppress: List[ValidationFailure]
See above
data_source: str
See above
num_suppressed: int
Number of errors suppressed
total_checks: int
Expand All @@ -31,12 +35,12 @@ def __init__(self, errors_to_suppress: List[ValidationFailure]):
Errors raised from validation failures not found in `self.errors_to_suppress`
"""
self.errors_to_suppress = errors_to_suppress
self.data_source = data_source
self.num_suppressed = 0
self.total_checks = 0
self.raised_errors = []
self.raised_warnings = []
self.unsuppressed_errors = []
self.summary = ""

def add_raised_error(self, error):
"""Add an error to the report.
Expand Down Expand Up @@ -74,21 +78,25 @@ def add_raised_warning(self, warning):
"""
self.raised_warnings.append(warning)

def set_summary(self):
"""Represent summary of report as a string."""
out_str = f"{self.total_checks} checks run\n"
out_str += f"{len(self.unsuppressed_errors)} checks failed\n"
out_str += f"{self.num_suppressed} checks suppressed\n"
out_str += f"{len(self.raised_warnings)} warnings\n"
self.summary = out_str

def log(self, logger=None):
"""Log errors and warnings."""
if logger is None:
logger = get_structured_logger(__name__)

self.set_summary()
logger.info(self.summary)
if self.success():
logger.info("Validation run successful",
data_source = self.data_source,
checks_run = self.total_checks,
checks_failed = len(self.unsuppressed_errors),
checks_suppressed = self.num_suppressed,
warnings = len(self.raised_warnings))
else:
logger.info("Validation run unsuccessful",
data_source = self.data_source,
checks_run = self.total_checks,
checks_failed = len(self.unsuppressed_errors),
checks_suppressed = self.num_suppressed,
warnings = len(self.raised_warnings))
for error in self.unsuppressed_errors:
logger.critical(str(error))
for warning in self.raised_warnings:
Expand Down
3 changes: 2 additions & 1 deletion _delphi_utils_python/delphi_utils/validator/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self, params):
# Date/time settings
self.time_window = TimeWindow.from_params(validation_params["common"]["end_date"],
validation_params["common"]["span_length"])
self.data_source = validation_params["common"].get("data_source", "")

self.static_validation = StaticValidator(validation_params)
self.dynamic_validation = DynamicValidator(validation_params)
Expand All @@ -51,7 +52,7 @@ def validate(self):
Returns:
- ValidationReport collating the validation outcomes
"""
report = ValidationReport(self.suppressed_errors)
report = ValidationReport(self.suppressed_errors, self.data_source)
frames_list = load_all_files(self.export_dir, self.time_window.start_date,
self.time_window.end_date)
self.static_validation.validate(frames_list, report)
Expand Down
2 changes: 1 addition & 1 deletion _delphi_utils_python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

setup(
name="delphi_utils",
version="0.1.3",
version="0.1.4",
description="Shared Utility Functions for Indicators",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
4 changes: 0 additions & 4 deletions _delphi_utils_python/tests/validator/test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ def test_str(self):
report.add_raised_warning(ImportWarning("right import"))
report.add_raised_error(self.ERROR_1)
report.add_raised_error(self.ERROR_2)
report.set_summary()

assert report.summary ==\
"3 checks run\n1 checks failed\n1 checks suppressed\n2 warnings\n"

def test_log(self):
"""Test that the logs contain all failures and warnings."""
Expand Down
12 changes: 12 additions & 0 deletions ansible/templates/sir_complainsalot-params-prod.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
"max_age":6,
"maintainers": ["U01AP8GSWG3","U01069KCRS7"],
"retired-signals": ["raw_pct_negative","smoothed_pct_negative","raw_tests_per_device","smoothed_tests_per_device"]
},
"nchs-mortality": {
"max_age":16,
"maintainers": []
},
"covid-act-now": {
"max_age":5,
"maintainers": []
},
"hhs": {
"max_age":8,
"maintainers": []
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ def run_module(params):
variants = [tuple((metric, geo_res)+sensor_signal(metric, sensor, smoother))
for (metric, geo_res, sensor, smoother) in
product(METRICS, GEO_RESOLUTIONS, SENSORS, SMOOTH_TYPES)]
variants = [i for i in variants if not ("7dav" in i[2] and "cumulative" in i[2])]
params = configure(variants, params)
logger = get_structured_logger(
__name__, filename=params["common"].get("log_filename"),
Expand Down
Empty file.
49 changes: 48 additions & 1 deletion combo_cases_and_deaths/tests/test_run.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
"""Tests for running combo cases and deaths indicator."""
from datetime import date
from itertools import product
import os
import unittest
from unittest.mock import patch, call
import pandas as pd
import numpy as np

from delphi_combo_cases_and_deaths.run import (
extend_raw_date_range, get_updated_dates,
run_module,
extend_raw_date_range,
get_updated_dates,
sensor_signal,
combine_usafacts_and_jhu,
compute_special_geo_dfs,
Expand Down Expand Up @@ -244,6 +247,50 @@ def test_no_nation_jhu(mock_covidcast_signal):
"sample_size": [None]},)
)

@patch("delphi_combo_cases_and_deaths.run.combine_usafacts_and_jhu")
def test_output_files(mock_combine):
params = {
"common": {
"export_dir": "./receiving"
},
"indicator": {
"export_start_date": [2020, 4, 1],
"source":"indicator-combination",
"wip_signal": ""
}
}
mock_combine.return_value = pd.DataFrame(
{
"geo_id": ["01000"],
"val": [10],
"timestamp": [pd.to_datetime("2021-01-04")],
"issue": [pd.to_datetime("2021-01-04")],
"se": 0,
"sample_size": 0
},
index=[1]
)
run_module(params)
csv_files = [f for f in os.listdir("receiving") if f.endswith(".csv")]
dates = ["20210104"]
geos = ["county", "hrr", "msa", "state", "hhs", "nation"]

# enumerate metric names.
metrics = []
for event, span, stat in product(["deaths", "confirmed"],
["cumulative", "incidence"],
["num", "prop"]):
metrics.append("_".join([event, span, stat]))
metrics.append("_".join([event, "7dav", span, stat]))

expected_files = []
for date in dates:
for geo in geos:
for metric in metrics:
if "7dav" in metric and "cumulative" in metric:
continue
expected_files += [date + "_" + geo + "_" + metric + ".csv"]
assert set(csv_files) == set(expected_files)

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion facebook/contingency-combine.R
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ write_rollup <- function(newly_seen_files, seen_file, output_df, output_file) {

args <- commandArgs(TRUE)

if (length(args) < 2) {
if (length(args) != 2) {
stop("Usage: Rscript contingency-combine.R path/to/individual/files/ path/to/rollup/files/")
}

Expand Down
1 change: 1 addition & 0 deletions facebook/delphiFacebook/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export(get_filenames_in_range)
export(get_range_prev_full_month)
export(get_range_prev_full_period)
export(get_range_prev_full_week)
export(get_sparse_filenames)
export(jeffreys_se)
export(join_weights)
export(load_archive)
Expand Down
Loading