Skip to content

Commit 1001ba9

Browse files
authored
Merge pull request #1878 from cmu-delphi/release/indicators_v0.3.44_utils_v0.3.19
Release covidcast-indicators 0.3.44
2 parents 33dba2e + c9d2147 commit 1001ba9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+78
-2481
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.3.43
2+
current_version = 0.3.44
33
commit = True
44
message = chore: bump covidcast-indicators to {new_version}
55
tag = False

.github/ISSUE_TEMPLATE/data_quality_issue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Data quality issue
33
about: Missing data, weird data, broken data
44
title: ''
55
labels: 'data quality'
6-
assignees: 'krivard'
6+
assignees: 'nolangormley'
77
---
88

99
**Actual Behavior:**

.github/workflows/create-delphi-utils-release.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/create-release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
bump2version --list ${{ github.event.inputs.versionName }} | grep ^new_version | sed -r s,"^.*=",,
6262
- name: Copy version to indicator directory
6363
run: |
64-
indicator_list=("changehc" "claims_hosp" "doctor_visits" "dsew_community_profile" "google_symptoms" "hhs_hosp" "nchs_mortality" "nowcast" "quidel_covidtest" "sir_complainsalot")
64+
indicator_list=("changehc" "claims_hosp" "doctor_visits" "google_symptoms" "hhs_hosp" "nchs_mortality" "nowcast" "quidel_covidtest" "sir_complainsalot")
6565
for path in ${indicator_list[@]}; do
6666
echo "current_version = ${{ steps.indicators.outputs.version }}" > $path/version.cfg
6767
done
@@ -72,8 +72,8 @@ jobs:
7272
base: prod
7373
title: Release covidcast-indicators ${{ steps.indicators.outputs.version }}
7474
labels: chore
75-
reviewers: krivard
76-
assignees: krivard
75+
reviewers: melange396
76+
assignees: melange396
7777
body: |
7878
Releasing:
7979
* covidcast-indicators ${{ steps.indicators.outputs.version }}

.github/workflows/publish-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
base: main
121121
title: 'chore: sync prod->main'
122122
labels: chore
123-
reviewers: krivard
124-
assignees: krivard
123+
reviewers: melange396
124+
assignees: melange396
125125
body: |
126126
Syncing Prod->Main.

.github/workflows/python-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
if: github.event.pull_request.draft == false
1717
strategy:
1818
matrix:
19-
packages: [_delphi_utils_python, changehc, claims_hosp, doctor_visits, dsew_community_profile, google_symptoms, hhs_hosp, nchs_mortality, nowcast, quidel_covidtest, sir_complainsalot]
19+
packages: [_delphi_utils_python, changehc, claims_hosp, doctor_visits, google_symptoms, hhs_hosp, nchs_mortality, nowcast, quidel_covidtest, sir_complainsalot]
2020
defaults:
2121
run:
2222
working-directory: ${{ matrix.packages }}

.github/workflows/release-delphi-utils.yml

Lines changed: 0 additions & 108 deletions
This file was deleted.

Jenkinsfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
- TODO: #527 Get this list automatically from python-ci.yml at runtime.
1111
*/
1212

13-
def indicator_list = ["backfill_corrections", "changehc", "claims_hosp", "google_symptoms", "hhs_hosp", "nchs_mortality", "quidel_covidtest", "sir_complainsalot", "dsew_community_profile", "doctor_visits"]
13+
def indicator_list = ["backfill_corrections", "changehc", "claims_hosp", "google_symptoms", "hhs_hosp", "nchs_mortality", "quidel_covidtest", "sir_complainsalot", "doctor_visits"]
1414
def build_package_main = [:]
1515
def build_package_prod = [:]
1616
def deploy_staging = [:]

_delphi_utils_python/.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.3.18
2+
current_version = 0.3.19
33
commit = True
44
message = chore: bump delphi_utils to {new_version}
55
tag = False

_delphi_utils_python/delphi_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
from .nancodes import Nans
1616
from .weekday import Weekday
1717

18-
__version__ = "0.3.18"
18+
__version__ = "0.3.19"

_delphi_utils_python/delphi_utils/validator/datafetcher.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import pandas as pd
1111
import numpy as np
1212
import covidcast
13-
from .. import read_params
1413
from .errors import APIDataFetchError, ValidationFailure
1514

1615
FILENAME_REGEX = re.compile(
@@ -103,15 +102,13 @@ def load_csv(path):
103102
})
104103

105104

106-
def get_geo_signal_combos(data_source):
105+
def get_geo_signal_combos(data_source, api_key):
107106
"""
108107
Get list of geo type-signal type combinations that we expect to see.
109108
110109
Cross references based on combinations reported available by COVIDcast metadata.
111110
"""
112-
params = read_params()
113-
assert "validation" in params
114-
api_key = ("epidata", params["validation"]["common"]["api_credentials"])
111+
api_key = ("epidata", api_key)
115112
# Maps data_source name with what's in the API, lists used in case of multiple names
116113
meta_response = requests.get("https://api.covidcast.cmu.edu/epidata/covidcast/meta",
117114
auth=api_key)
@@ -166,14 +163,13 @@ def fetch_api_reference(data_source, start_date, end_date, geo_type, signal_type
166163
api_df = covidcast.signal(
167164
data_source, signal_type, start_date, end_date, geo_type)
168165

169-
if not isinstance(api_df, pd.DataFrame):
170-
custom_msg = "Error fetching data from " + str(start_date) + \
171-
" to " + str(end_date) + \
172-
" for data source: " + data_source + \
173-
", signal type: " + signal_type + \
174-
", geo type: " + geo_type
166+
error_context = f"when fetching reference data from {start_date} to {end_date} " +\
167+
f"for data source: {data_source}, signal type: {signal_type}, geo type: {geo_type}"
175168

176-
raise APIDataFetchError(custom_msg)
169+
if api_df is None:
170+
raise APIDataFetchError("Error: no API data was returned " + error_context)
171+
if not isinstance(api_df, pd.DataFrame):
172+
raise APIDataFetchError("Error: API return value was not a dataframe " + error_context)
177173

178174
column_names = ["geo_id", "val",
179175
"se", "sample_size", "time_value"]
@@ -220,12 +216,15 @@ def get_one_api_df(data_source, min_date, max_date,
220216
dict_lock.release()
221217

222218

223-
def threaded_api_calls(data_source, min_date, max_date, geo_signal_combos, n_threads=32):
219+
MAX_ALLOWED_THREADS = 32
220+
221+
def threaded_api_calls(data_source, min_date, max_date,
222+
geo_signal_combos, n_threads=MAX_ALLOWED_THREADS):
224223
"""Get data from API for all geo-signal combinations in a threaded way."""
225-
if n_threads > 32:
226-
n_threads = 32
227-
print("Warning: Don't run more than 32 threads at once due "
228-
+ "to API resource limitations")
224+
if n_threads > MAX_ALLOWED_THREADS:
225+
n_threads = MAX_ALLOWED_THREADS
226+
warnings.warn("Warning: instead of requested thread count, using " + \
227+
f"only {MAX_ALLOWED_THREADS} threads due to API resource limitations")
229228

230229
output_dict = dict()
231230
dict_lock = threading.Lock()

_delphi_utils_python/delphi_utils/validator/dynamic.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import re
66
import pandas as pd
77
import numpy as np
8+
import covidcast
89
from .errors import ValidationFailure
910
from .datafetcher import get_geo_signal_combos, threaded_api_calls
1011
from .utils import relative_difference_by_min, TimeWindow, lag_converter
@@ -14,12 +15,14 @@ class DynamicValidator:
1415
"""Class for validation of static properties of individual datasets."""
1516

1617
@dataclass
17-
class Parameters:
18+
class Parameters: # pylint: disable=too-many-instance-attributes
1819
"""Configuration parameters."""
1920

2021
# data source name, one of
2122
# https://cmu-delphi.github.io/delphi-epidata/api/covidcast_signals.html
2223
data_source: str
24+
# COVIDcast API key
25+
api_key: str
2326
# span of time over which to perform checks
2427
time_window: TimeWindow
2528
# date that this df_to_test was generated; typically 1 day after the last date in df_to_test
@@ -48,6 +51,7 @@ def __init__(self, params):
4851

4952
self.params = self.Parameters(
5053
data_source=common_params["data_source"],
54+
api_key = common_params["api_credentials"],
5155
time_window=TimeWindow.from_params(common_params["end_date"],
5256
common_params["span_length"]),
5357
generation_date=date.today(),
@@ -74,8 +78,12 @@ def validate(self, all_frames, report):
7478
# Get 14 days prior to the earliest list date
7579
outlier_lookbehind = timedelta(days=14)
7680

81+
# Authenticate API
82+
covidcast.use_api_key(self.params.api_key)
83+
7784
# Get all expected combinations of geo_type and signal.
78-
geo_signal_combos = get_geo_signal_combos(self.params.data_source)
85+
geo_signal_combos = get_geo_signal_combos(self.params.data_source,
86+
api_key = self.params.api_key)
7987

8088
all_api_df = threaded_api_calls(self.params.data_source,
8189
self.params.time_window.start_date - outlier_lookbehind,

_delphi_utils_python/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
setup(
2929
name="delphi_utils",
30-
version="0.3.18",
30+
version="0.3.19",
3131
description="Shared Utility Functions for Indicators",
3232
long_description=long_description,
3333
long_description_content_type="text/markdown",

_delphi_utils_python/tests/validator/test_datafetcher.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def raise_for_status(self):
5454
def test_bad_api_key(self, **kwargs):
5555
kwargs["mock_requests"].get("https://api.covidcast.cmu.edu/epidata/covidcast/meta", status_code=429)
5656
with pytest.raises(HTTPError):
57-
get_geo_signal_combos("chng")
57+
get_geo_signal_combos("chng", api_key="")
5858

5959
@mock.patch('requests.get', side_effect=mocked_requests_get)
6060
@mock.patch("covidcast.metadata")
@@ -78,11 +78,11 @@ def test_get_geo_signal_combos(self, mock_metadata, mock_get):
7878
"hrr", "msa", "msa",
7979
"state"]
8080
})
81-
assert set(get_geo_signal_combos("chng")) == set(
81+
assert set(get_geo_signal_combos("chng", api_key="")) == set(
8282
[("state", "smoothed_outpatient_cli"),
8383
("state", "smoothed_outpatient_covid"),
8484
("county", "smoothed_outpatient_covid")])
85-
assert set(get_geo_signal_combos("covid-act-now")) == set(
85+
assert set(get_geo_signal_combos("covid-act-now", api_key="")) == set(
8686
[("hrr", "pcr_specimen_positivity_rate"),
8787
("msa", "pcr_specimen_positivity_rate"),
8888
("msa", "pcr_specimen_total_tests")])
@@ -138,7 +138,8 @@ def mock_signal_return_fn(unused_data_source, signal_type, unused_start_date,
138138
("state", "b"): ValidationFailure("api_data_fetch_error",
139139
geo_type="state",
140140
signal="b",
141-
message="Error fetching data from 2020-03-10 "
141+
message="Error: no API data was returned when "
142+
"fetching reference data from 2020-03-10 "
142143
"to 2020-06-10 for data source: "
143144
"source, signal type: b, geo type: state")
144145
}

0 commit comments

Comments
 (0)