Skip to content

Commit adefef9

Browse files
authored
Merge pull request #1309 from cmu-delphi/release/delphi-epidata-4.1.11
Release Delphi Epidata 4.1.11
2 parents 814cef3 + 46ab6d8 commit adefef9

Some content is hidden

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

42 files changed

+968
-914
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 4.1.10
2+
current_version = 4.1.11
33
commit = False
44
tag = False
55

dev/local/setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = Delphi Development
3-
version = 4.1.10
3+
version = 4.1.11
44

55
[options]
66
packages =

docs/new_endpoint_tutorial.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,9 @@ Here's what we add to each client:
123123
def fluview_meta():
124124
"""Fetch FluView metadata."""
125125
# Set up request
126-
params = {
127-
'endpoint': 'fluview_meta',
128-
}
126+
params = {}
129127
# Make the API call
130-
return Epidata._request(params)
128+
return Epidata._request("fluview_meta", params)
131129
```
132130
133131
- [`delphi_epidata.R`](https://github.com/cmu-delphi/delphi-epidata/blob/dev/src/client/delphi_epidata.R)

docs/symptom-survey/publications.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ Pandemic"](https://www.pnas.org/topic/548) in *PNAS*:
2626

2727
Research publications using the survey data include:
2828

29+
- Ma, M.Z., Chen, S.X. (2023). [Beyond the surface: accounting for confounders
30+
in understanding the link between collectivism and COVID-19 pandemic in the
31+
United States](https://doi.org/10.1186/s12889-023-16384-2). *BMC Public
32+
Health* 23, 1513.
2933
- C.K. Ettman, E. Badillo Goicoechea, and E.A. Stuart (2023). [Evolution of
3034
depression and anxiety over the COVID-19 pandemic and across demographic
3135
groups in a large sample of U.S. adults](https://doi.org/10.1016/j.focus.2023.100140).
@@ -62,7 +66,7 @@ Research publications using the survey data include:
6266
- Rönn MM, Menzies NA, Salomon JA (2023). [Vaccination and voting patterns in
6367
the United States: analysis of COVID-19 and flu surveys from 2010 to
6468
2022](https://doi.org/10.1016/j.amepre.2023.03.001). *American Journal of
65-
Preventive Medicine.*
69+
Preventive Medicine* 65 (3), 458-466.
6670
- Taube JC, Susswein Z, Bansal S (2023). [Spatiotemporal Trends in Self-Reported
6771
Mask-Wearing Behavior in the United States: Analysis of a Large
6872
Cross-sectional Survey](https://doi.org/10.2196/42128). *JMIR Public Health

integrations/acquisition/covid_hosp/facility/test_scenarios.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def setUp(self):
2828
self.test_utils = UnitTestUtils(__file__)
2929

3030
# use the local instance of the Epidata API
31-
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
31+
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata'
3232
Epidata.auth = ('epidata', 'key')
3333

3434
# use the local instance of the epidata database

integrations/acquisition/covid_hosp/state_daily/test_scenarios.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def setUp(self):
3232
self.test_utils = UnitTestUtils(__file__)
3333

3434
# use the local instance of the Epidata API
35-
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
35+
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata'
3636
Epidata.auth = ('epidata', 'key')
3737

3838
# use the local instance of the epidata database

integrations/acquisition/covid_hosp/state_timeseries/test_scenarios.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def setUp(self):
2828
self.test_utils = UnitTestUtils(__file__)
2929

3030
# use the local instance of the Epidata API
31-
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
31+
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata'
3232
Epidata.auth = ('epidata', 'key')
3333

3434
# use the local instance of the epidata database

integrations/acquisition/covidcast/test_covidcast_meta_caching.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
)
2323

2424
# use the local instance of the Epidata API
25-
BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
25+
BASE_URL = 'http://delphi_web_epidata/epidata'
2626

2727

2828
class CovidcastMetaCacheTests(unittest.TestCase):
@@ -82,8 +82,8 @@ def tearDown(self):
8282

8383
@staticmethod
8484
def _make_request():
85-
params = {'endpoint': 'covidcast_meta', 'cached': 'true'}
86-
response = requests.get(Epidata.BASE_URL, params=params, auth=Epidata.auth)
85+
params = {'cached': 'true'}
86+
response = requests.get(f"{Epidata.BASE_URL}/covidcast_meta", params=params, auth=Epidata.auth)
8787
response.raise_for_status()
8888
return response.json()
8989

integrations/acquisition/covidcast/test_csv_uploading.py

+13-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def setUp(self):
6969
epidata_cnx.close()
7070

7171
# use the local instance of the Epidata API
72-
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
72+
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata'
7373
Epidata.auth = ('epidata', 'key')
7474

7575
def tearDown(self):
@@ -132,7 +132,7 @@ def test_uploading(self):
132132
main(args)
133133
response = Epidata.covidcast('src-name', signal_name, 'day', 'state', 20200419, '*')
134134

135-
expected_values = pd.concat([values, pd.DataFrame({ "time_value": [20200419] * 3, "signal": [signal_name] * 3, "direction": [None] * 3})], axis=1).rename(columns=uploader_column_rename).to_dict(orient="records")
135+
expected_values = pd.concat([values, pd.DataFrame({ "geo_type": "state", "source": "src-name", "time_type": "day", "time_value": [20200419] * 3, "signal": [signal_name] * 3, "direction": [None] * 3})], axis=1).rename(columns=uploader_column_rename).to_dict(orient="records")
136136
expected_response = {'result': 1, 'epidata': self.apply_lag(expected_values), 'message': 'success'}
137137

138138
self.assertEqual(response, expected_response)
@@ -161,6 +161,9 @@ def test_uploading(self):
161161
response = Epidata.covidcast('src-name', signal_name, 'day', 'state', 20200419, '*')
162162

163163
expected_values = pd.concat([values, pd.DataFrame({
164+
"geo_type": "state",
165+
"source": "src-name",
166+
"time_type": "day",
164167
"time_value": [20200419] * 3,
165168
"signal": [signal_name] * 3,
166169
"direction": [None] * 3,
@@ -194,7 +197,7 @@ def test_uploading(self):
194197
main(args)
195198
response = Epidata.covidcast('src-name', signal_name, 'day', 'state', 20200419, '*')
196199

197-
expected_response = {'result': -2, 'message': 'no results'}
200+
expected_response = {'epidata': [], 'result': -2, 'message': 'no results'}
198201

199202
self.assertEqual(response, expected_response)
200203
self.verify_timestamps_and_defaults()
@@ -220,6 +223,9 @@ def test_uploading(self):
220223
response = Epidata.covidcast('src-name', signal_name, 'day', 'state', 20200419, '*')
221224

222225
expected_values_df = pd.concat([values, pd.DataFrame({
226+
"geo_type": "state",
227+
"source": "src-name",
228+
"time_type": "day",
223229
"time_value": [20200419],
224230
"signal": [signal_name],
225231
"direction": [None]})], axis=1).rename(columns=uploader_column_rename)
@@ -253,6 +259,9 @@ def test_uploading(self):
253259
response = Epidata.covidcast('src-name', signal_name, 'day', 'state', 20200419, '*')
254260

255261
expected_values = pd.concat([values, pd.DataFrame({
262+
"geo_type": "state",
263+
"source": "src-name",
264+
"time_type": "day",
256265
"time_value": [20200419],
257266
"signal": [signal_name],
258267
"direction": [None]
@@ -283,7 +292,7 @@ def test_uploading(self):
283292
main(args)
284293
response = Epidata.covidcast('src-name', signal_name, 'day', 'state', 20200419, '*')
285294

286-
expected_response = {'result': -2, 'message': 'no results'}
295+
expected_response = {'epidata': [], 'result': -2, 'message': 'no results'}
287296

288297
self.assertEqual(response, expected_response)
289298
self.verify_timestamps_and_defaults()

integrations/acquisition/covidcast_nowcast/test_csv_uploading.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def setUp(self):
5555
secrets.db.epi = ('user', 'pass')
5656

5757
# use the local instance of the Epidata API
58-
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
58+
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata'
5959
Epidata.auth = ('epidata', 'key')
6060

6161
def tearDown(self):

integrations/client/test_delphi_epidata.py

+30-20
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
def fake_epidata_endpoint(func):
2525
"""This can be used as a decorator to enable a bogus Epidata endpoint to return 404 responses."""
2626
def wrapper(*args):
27-
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata/fake_api.php'
27+
Epidata.BASE_URL = 'http://delphi_web_epidata/fake_epidata'
2828
func(*args)
29-
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
29+
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata'
3030
return wrapper
3131

3232
class DelphiEpidataPythonClientTests(CovidcastBase):
@@ -39,7 +39,7 @@ def localSetUp(self):
3939
self._db._cursor.execute('update covidcast_meta_cache set timestamp = 0, epidata = "[]"')
4040

4141
# use the local instance of the Epidata API
42-
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
42+
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata'
4343
Epidata.auth = ('epidata', 'key')
4444

4545
# use the local instance of the epidata database
@@ -65,8 +65,8 @@ def test_covidcast(self):
6565
)
6666

6767
expected = [
68-
row_latest_issue.as_api_compatibility_row_dict(),
69-
rows[-1].as_api_compatibility_row_dict()
68+
row_latest_issue.as_api_row_dict(),
69+
rows[-1].as_api_row_dict()
7070
]
7171

7272
self.assertEqual(response['epidata'], expected)
@@ -85,10 +85,10 @@ def test_covidcast(self):
8585

8686
expected = [{
8787
rows[0].signal: [
88-
row_latest_issue.as_api_compatibility_row_dict(ignore_fields=['signal']),
88+
row_latest_issue.as_api_row_dict(ignore_fields=['signal']),
8989
],
9090
rows[-1].signal: [
91-
rows[-1].as_api_compatibility_row_dict(ignore_fields=['signal']),
91+
rows[-1].as_api_row_dict(ignore_fields=['signal']),
9292
],
9393
}]
9494

@@ -105,7 +105,7 @@ def test_covidcast(self):
105105
**self.params_from_row(rows[0])
106106
)
107107

108-
expected = [row_latest_issue.as_api_compatibility_row_dict()]
108+
expected = [row_latest_issue.as_api_row_dict()]
109109

110110
# check result
111111
self.assertEqual(response_1, {
@@ -120,7 +120,7 @@ def test_covidcast(self):
120120
**self.params_from_row(rows[0], as_of=rows[1].issue)
121121
)
122122

123-
expected = [rows[1].as_api_compatibility_row_dict()]
123+
expected = [rows[1].as_api_row_dict()]
124124

125125
# check result
126126
self.maxDiff=None
@@ -130,15 +130,23 @@ def test_covidcast(self):
130130
'message': 'success',
131131
})
132132

133+
with self.subTest(name='bad as-of date'):
134+
# fetch data, specifying as_of
135+
as_of_response = Epidata.covidcast(
136+
**self.params_from_row(rows[0], as_of="20230101-20230102")
137+
)
138+
self.assertEqual(as_of_response, {"epidata": [], "message": "not a valid date: 20230101-20230102", "result": -1})
139+
140+
133141
with self.subTest(name='request a range of issues'):
134142
# fetch data, specifying issue range, not lag
135143
response_2 = Epidata.covidcast(
136144
**self.params_from_row(rows[0], issues=Epidata.range(rows[0].issue, rows[1].issue))
137145
)
138146

139147
expected = [
140-
rows[0].as_api_compatibility_row_dict(),
141-
rows[1].as_api_compatibility_row_dict()
148+
rows[0].as_api_row_dict(),
149+
rows[1].as_api_row_dict()
142150
]
143151

144152
# check result
@@ -154,7 +162,7 @@ def test_covidcast(self):
154162
**self.params_from_row(rows[0], lag=2)
155163
)
156164

157-
expected = [row_latest_issue.as_api_compatibility_row_dict()]
165+
expected = [row_latest_issue.as_api_row_dict()]
158166

159167
# check result
160168
self.assertDictEqual(response_3, {
@@ -170,7 +178,7 @@ def test_covidcast(self):
170178
)
171179

172180
# check result
173-
self.assertEqual(response_1, {'message': 'no results', 'result': -2})
181+
self.assertEqual(response_1, {'epidata': [], 'message': 'no results', 'result': -2})
174182

175183
@patch('requests.post')
176184
@patch('requests.get')
@@ -196,7 +204,7 @@ def test_retry_request(self, get):
196204
mock_response = MagicMock()
197205
mock_response.status_code = 200
198206
get.side_effect = [JSONDecodeError('Expecting value', "", 0), mock_response]
199-
response = Epidata._request(None)
207+
response = Epidata._request("")
200208
self.assertEqual(get.call_count, 2)
201209
self.assertEqual(response, mock_response.json())
202210

@@ -207,7 +215,7 @@ def test_retry_request(self, get):
207215
get.side_effect = [JSONDecodeError('Expecting value', "", 0),
208216
JSONDecodeError('Expecting value', "", 0),
209217
mock_response]
210-
response = Epidata._request(None)
218+
response = Epidata._request("")
211219
self.assertEqual(get.call_count, 2) # 2 from previous test + 2 from this one
212220
self.assertEqual(response,
213221
{'result': 0, 'message': 'error: Expecting value: line 1 column 1 (char 0)'}
@@ -228,7 +236,7 @@ def test_geo_value(self):
228236
self._insert_rows(rows)
229237

230238
counties = [
231-
rows[i].as_api_compatibility_row_dict() for i in range(N)
239+
rows[i].as_api_row_dict() for i in range(N)
232240
]
233241

234242
def fetch(geo):
@@ -339,13 +347,15 @@ def test_async_epidata(self):
339347
self.params_from_row(rows[0], source='covidcast'),
340348
self.params_from_row(rows[1], source='covidcast')
341349
]*12, batch_size=10)
342-
responses = [i[0] for i in test_output]
343-
# check response is same as standard covidcast call, using 24 calls to test batch sizing
350+
responses = [i[0]["epidata"] for i in test_output]
351+
# check response is same as standard covidcast call (minus fields omitted by the api.php endpoint),
352+
# using 24 calls to test batch sizing
353+
ignore_fields = CovidcastTestRow._api_row_compatibility_ignore_fields
344354
self.assertEqual(
345355
responses,
346356
[
347-
Epidata.covidcast(**self.params_from_row(rows[0])),
348-
Epidata.covidcast(**self.params_from_row(rows[1])),
357+
[{k: row[k] for k in row.keys() - ignore_fields} for row in Epidata.covidcast(**self.params_from_row(rows[0]))["epidata"]],
358+
[{k: row[k] for k in row.keys() - ignore_fields} for row in Epidata.covidcast(**self.params_from_row(rows[1]))["epidata"]],
349359
]*12
350360
)
351361

integrations/client/test_nowcast.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def setUp(self):
3939
self.cur = cnx.cursor()
4040

4141
# use the local instance of the Epidata API
42-
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata/api.php'
42+
Epidata.BASE_URL = 'http://delphi_web_epidata/epidata'
4343
Epidata.auth = ('epidata', 'key')
4444

4545
# use the local instance of the epidata database
@@ -133,4 +133,4 @@ def test_covidcast_nowcast(self):
133133
response = Epidata.covidcast_nowcast(
134134
'src', 'sig1', 'sensor', 'day', 'county', 22222222, '01001')
135135

136-
self.assertEqual(response, {'result': -2, 'message': 'no results'})
136+
self.assertEqual(response, {'epidata': [], 'result': -2, 'message': 'no results'})

0 commit comments

Comments
 (0)