Skip to content

Commit 23135e2

Browse files
authored
Merge pull request #1122 from cmu-delphi/release/delphi-epidata-0.4.9
Release Delphi Epidata 0.4.9
2 parents 5da6d3f + efcf958 commit 23135e2

File tree

11 files changed

+32
-17
lines changed

11 files changed

+32
-17
lines changed

.bumpversion.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.4.8
2+
current_version = 0.4.9
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 = 0.4.8
3+
version = 0.4.9
44

55
[options]
66
packages =

integrations/client/test_delphi_epidata.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def test_geo_value(self):
218218
# insert placeholder data: three counties, three MSAs
219219
N = 3
220220
rows = [
221-
CovidcastTestRow.make_default_row(geo_type="fips", geo_value=FIPS[i], value=i)
221+
CovidcastTestRow.make_default_row(geo_type="county", geo_value=FIPS[i], value=i)
222222
for i in range(N)
223223
] + [
224224
CovidcastTestRow.make_default_row(geo_type="msa", geo_value=MSA[i], value=i*10)
@@ -245,7 +245,7 @@ def fetch(geo):
245245
self.assertEqual(request['epidata'], [counties[0]])
246246
# test fetch a specific yet not existing region
247247
request = fetch('55555')
248-
self.assertEqual(request['message'], 'Invalid geo_value(s) 55555 for the requested geo_type fips')
248+
self.assertEqual(request['message'], 'Invalid geo_value(s) 55555 for the requested geo_type county')
249249
# test fetch a multiple regions
250250
request = fetch([FIPS[0], FIPS[1]])
251251
self.assertEqual(request['message'], 'success')
@@ -256,10 +256,10 @@ def fetch(geo):
256256
self.assertEqual(request['epidata'], [counties[0], counties[2]])
257257
# test fetch a multiple regions but one is not existing
258258
request = fetch([FIPS[0], '55555'])
259-
self.assertEqual(request['message'], 'Invalid geo_value(s) 55555 for the requested geo_type fips')
259+
self.assertEqual(request['message'], 'Invalid geo_value(s) 55555 for the requested geo_type county')
260260
# test fetch a multiple regions but specify no region
261261
request = fetch([])
262-
self.assertEqual(request['message'], 'geo_value is empty for the requested geo_type fips!')
262+
self.assertEqual(request['message'], 'geo_value is empty for the requested geo_type county!')
263263
# test fetch a region with no results
264264
request = fetch([FIPS[3]])
265265
self.assertEqual(request['message'], 'no results')
@@ -326,7 +326,7 @@ def test_async_epidata(self):
326326
# insert placeholder data: three counties, three MSAs
327327
N = 3
328328
rows = [
329-
CovidcastTestRow.make_default_row(geo_type="fips", geo_value=FIPS[i-1], value=i)
329+
CovidcastTestRow.make_default_row(geo_type="county", geo_value=FIPS[i-1], value=i)
330330
for i in range(N)
331331
] + [
332332
CovidcastTestRow.make_default_row(geo_type="msa", geo_value=MSA[i-1], value=i*10)

src/client/delphi_epidata.R

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Epidata <- (function() {
1515
# API base url
1616
BASE_URL <- 'https://delphi.cmu.edu/epidata/api.php'
1717

18-
client_version <- '0.4.8'
18+
client_version <- '0.4.9'
1919

2020
# Helper function to cast values and/or ranges to strings
2121
.listitem <- function(value) {

src/client/delphi_epidata.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
}
2323
})(this, function (exports, fetchImpl, jQuery) {
2424
const BASE_URL = "https://delphi.cmu.edu/epidata/";
25-
const client_version = "0.4.8";
25+
const client_version = "0.4.9";
2626

2727
// Helper function to cast values and/or ranges to strings
2828
function _listitem(value) {

src/client/packaging/npm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "delphi_epidata",
33
"description": "Delphi Epidata API Client",
44
"authors": "Delphi Group",
5-
"version": "0.4.8",
5+
"version": "0.4.9",
66
"license": "MIT",
77
"homepage": "https://github.com/cmu-delphi/delphi-epidata",
88
"bugs": {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .delphi_epidata import Epidata
22

33
name = 'delphi_epidata'
4-
__version__ = '0.4.8'
4+
__version__ = '0.4.9'

src/client/packaging/pypi/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="delphi_epidata",
8-
version="0.4.8",
8+
version="0.4.9",
99
author="David Farrow",
1010
author_email="[email protected]",
1111
description="A programmatic interface to Delphi's Epidata API.",

src/server/_config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
load_dotenv()
66

7-
VERSION = "0.4.8"
7+
VERSION = "0.4.9"
88

99
MAX_RESULTS = int(10e6)
1010
MAX_COMPATIBILITY_RESULTS = int(3650)

src/server/_params.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,21 @@ def __init__(self, geo_type: str, geo_values: Union[bool, Sequence[str]]):
5858
if not isinstance(geo_values, bool):
5959
if geo_values == ['']:
6060
raise ValidationFailedException(f"geo_value is empty for the requested geo_type {geo_type}!")
61-
allowed_values = delphi_utils.geomap.GeoMapper().get_geo_values(geo_type)
62-
invalid_values = set(geo_values) - set(allowed_values)
63-
if invalid_values:
64-
raise ValidationFailedException(f"Invalid geo_value(s) {', '.join(invalid_values)} for the requested geo_type {geo_type}")
61+
# TODO: keep this translator in sync with CsvImporter.GEOGRAPHIC_RESOLUTIONS in acquisition/covidcast/ and with GeoMapper
62+
geo_type_translator = {
63+
"county": "fips",
64+
"state": "state_id",
65+
"zip": "zip",
66+
"hrr": "hrr",
67+
"hhs": "hhs",
68+
"msa": "msa",
69+
"nation": "nation"
70+
}
71+
if geo_type in geo_type_translator: # else geo_type is unknown to GeoMapper
72+
allowed_values = delphi_utils.geomap.GeoMapper().get_geo_values(geo_type_translator[geo_type])
73+
invalid_values = set(geo_values) - set(allowed_values)
74+
if invalid_values:
75+
raise ValidationFailedException(f"Invalid geo_value(s) {', '.join(invalid_values)} for the requested geo_type {geo_type}")
6576
self.geo_type = geo_type
6677
self.geo_values = geo_values
6778

tests/server/test_params.py

+4
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ def test_parse_geo_arg(self):
9494
self.assertEqual(parse_geo_arg(), [GeoSet("fips", True)])
9595
with app.test_request_context(f"/?geo=fips:{FIPS[0]}"):
9696
self.assertEqual(parse_geo_arg(), [GeoSet("fips", [FIPS[0]])])
97+
with self.subTest("covidcast"):
98+
for geo_type in "county dma hhs hrr msa nation state".split():
99+
with app.test_request_context(f"/?geo={geo_type}:*"):
100+
self.assertEqual(parse_geo_arg(), [GeoSet(geo_type, True)])
97101
with self.subTest("single list"):
98102
with app.test_request_context(f"/?geo=fips:{FIPS[0]},{FIPS[1]}"):
99103
self.assertEqual(parse_geo_arg(), [GeoSet("fips", [FIPS[0], FIPS[1]])])

0 commit comments

Comments
 (0)