Skip to content

Commit 1f9bf19

Browse files
authored
Merge pull request #1295 from cmu-delphi/revert_deprecate_async_epidata
revert and deprecate async_epidata (+ Remove usage of PHP alias in the Python client)
2 parents 5f0b521 + 65d1587 commit 1f9bf19

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

integrations/client/test_delphi_epidata.py

+11-8
Original file line numberDiff line numberDiff line change
@@ -335,25 +335,28 @@ def test_async_epidata(self):
335335
]
336336
self._insert_rows(rows)
337337

338-
test_output = Epidata.async_epidata('covidcast', [
339-
self.params_from_row(rows[0]),
340-
self.params_from_row(rows[1])
338+
test_output = Epidata.async_epidata([
339+
self.params_from_row(rows[0], source='covidcast'),
340+
self.params_from_row(rows[1], source='covidcast')
341341
]*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
342+
responses = [i[0]["epidata"] for i in test_output]
343+
# check response is same as standard covidcast call (minus fields omitted by the api.php endpoint),
344+
# using 24 calls to test batch sizing
345+
ignore_fields = CovidcastTestRow._api_row_compatibility_ignore_fields
344346
self.assertEqual(
345347
responses,
346348
[
347-
Epidata.covidcast(**self.params_from_row(rows[0])),
348-
Epidata.covidcast(**self.params_from_row(rows[1])),
349+
[{k: row[k] for k in row.keys() - ignore_fields} for row in Epidata.covidcast(**self.params_from_row(rows[0]))["epidata"]],
350+
[{k: row[k] for k in row.keys() - ignore_fields} for row in Epidata.covidcast(**self.params_from_row(rows[1]))["epidata"]],
349351
]*12
350352
)
351353

352354
@fake_epidata_endpoint
353355
def test_async_epidata_fail(self):
354356
with pytest.raises(ClientResponseError, match="404, message='NOT FOUND'"):
355-
Epidata.async_epidata('covidcast', [
357+
Epidata.async_epidata([
356358
{
359+
'source': 'covidcast',
357360
'data_source': 'src',
358361
'signals': 'sig',
359362
'time_type': 'day',

src/client/delphi_epidata.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,17 @@ def covidcast_nowcast(
691691
return Epidata._request("covidcast_nowcast", params)
692692

693693
@staticmethod
694-
def async_epidata(endpoint, param_list, batch_size=50):
695-
"""Make asynchronous Epidata calls for a list of parameters."""
694+
def async_epidata(param_list, batch_size=50):
695+
"""[DEPRECATED] Make asynchronous Epidata calls for a list of parameters."""
696696

697-
request_url = f"{Epidata.BASE_URL}/{endpoint}"
697+
import warnings
698+
warnings.filterwarnings("once", category=DeprecationWarning, module="delphi_epidata")
699+
warnings.warn("Method `Epidata.async_epidata()` is deprecated and will be removed in a future version.",
700+
category=DeprecationWarning)
698701

699702
async def async_get(params, session):
700703
"""Helper function to make Epidata GET requests."""
701-
async with session.get(request_url, params=params) as response:
704+
async with session.get(f"{Epidata.BASE_URL}/api.php", params=params) as response:
702705
response.raise_for_status()
703706
return await response.json(), params
704707

0 commit comments

Comments
 (0)