Skip to content

Commit 3c989f6

Browse files
committed
some re-organizing of code for readability
1 parent 51dd3d8 commit 3c989f6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

_delphi_utils_python/delphi_utils/validator/datafetcher.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
FILENAME_REGEX = re.compile(
1717
r'^(?P<date>\d{8})_(?P<geo_type>\w+?)_(?P<signal>\w+)\.csv$')
1818

19-
params = read_params()
20-
assert "validation" in params
21-
API_KEY = ("epidata", params["validation"]["common"]["api_credentials"])
22-
2319
def make_date_filter(start_date, end_date):
2420
"""
2521
Create a function to filter dates in the specified date range (inclusive).
@@ -113,9 +109,14 @@ def get_geo_signal_combos(data_source):
113109
114110
Cross references based on combinations reported available by COVIDcast metadata.
115111
"""
112+
113+
params = read_params()
114+
assert "validation" in params
115+
api_key = ("epidata", params["validation"]["common"]["api_credentials"])
116+
116117
# Maps data_source name with what's in the API, lists used in case of multiple names
117118
meta_response = requests.get("https://api.covidcast.cmu.edu/epidata/covidcast/meta",
118-
auth=API_KEY)
119+
auth=api_key)
119120
meta_response.raise_for_status()
120121
source_signal_mappings = {i['source']:i['db_source'] for i in
121122
meta_response.json()}
@@ -143,7 +144,7 @@ def get_geo_signal_combos(data_source):
143144
elif geo_status == "unknown":
144145
epidata_signal = requests.get(
145146
"https://api.covidcast.cmu.edu/epidata/covidcast/meta",
146-
params={'signal': f"{src}:{sig}"}, auth=API_KEY)
147+
params={'signal': f"{src}:{sig}"}, auth=api_key)
147148
epidata_signal.raise_for_status()
148149
# Not an active signal
149150
active_status = [val['active'] for i in epidata_signal.json()

0 commit comments

Comments
 (0)