Skip to content

Release Delphi Epidata 0.4.9 #1122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.8
current_version = 0.4.9
commit = False
tag = False

Expand Down
2 changes: 1 addition & 1 deletion dev/local/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = Delphi Development
version = 0.4.8
version = 0.4.9

[options]
packages =
Expand Down
10 changes: 5 additions & 5 deletions integrations/client/test_delphi_epidata.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_geo_value(self):
# insert placeholder data: three counties, three MSAs
N = 3
rows = [
CovidcastTestRow.make_default_row(geo_type="fips", geo_value=FIPS[i], value=i)
CovidcastTestRow.make_default_row(geo_type="county", geo_value=FIPS[i], value=i)
for i in range(N)
] + [
CovidcastTestRow.make_default_row(geo_type="msa", geo_value=MSA[i], value=i*10)
Expand All @@ -245,7 +245,7 @@ def fetch(geo):
self.assertEqual(request['epidata'], [counties[0]])
# test fetch a specific yet not existing region
request = fetch('55555')
self.assertEqual(request['message'], 'Invalid geo_value(s) 55555 for the requested geo_type fips')
self.assertEqual(request['message'], 'Invalid geo_value(s) 55555 for the requested geo_type county')
# test fetch a multiple regions
request = fetch([FIPS[0], FIPS[1]])
self.assertEqual(request['message'], 'success')
Expand All @@ -256,10 +256,10 @@ def fetch(geo):
self.assertEqual(request['epidata'], [counties[0], counties[2]])
# test fetch a multiple regions but one is not existing
request = fetch([FIPS[0], '55555'])
self.assertEqual(request['message'], 'Invalid geo_value(s) 55555 for the requested geo_type fips')
self.assertEqual(request['message'], 'Invalid geo_value(s) 55555 for the requested geo_type county')
# test fetch a multiple regions but specify no region
request = fetch([])
self.assertEqual(request['message'], 'geo_value is empty for the requested geo_type fips!')
self.assertEqual(request['message'], 'geo_value is empty for the requested geo_type county!')
# test fetch a region with no results
request = fetch([FIPS[3]])
self.assertEqual(request['message'], 'no results')
Expand Down Expand Up @@ -326,7 +326,7 @@ def test_async_epidata(self):
# insert placeholder data: three counties, three MSAs
N = 3
rows = [
CovidcastTestRow.make_default_row(geo_type="fips", geo_value=FIPS[i-1], value=i)
CovidcastTestRow.make_default_row(geo_type="county", geo_value=FIPS[i-1], value=i)
for i in range(N)
] + [
CovidcastTestRow.make_default_row(geo_type="msa", geo_value=MSA[i-1], value=i*10)
Expand Down
2 changes: 1 addition & 1 deletion src/client/delphi_epidata.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Epidata <- (function() {
# API base url
BASE_URL <- 'https://delphi.cmu.edu/epidata/api.php'

client_version <- '0.4.8'
client_version <- '0.4.9'

# Helper function to cast values and/or ranges to strings
.listitem <- function(value) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/delphi_epidata.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
})(this, function (exports, fetchImpl, jQuery) {
const BASE_URL = "https://delphi.cmu.edu/epidata/";
const client_version = "0.4.8";
const client_version = "0.4.9";

// Helper function to cast values and/or ranges to strings
function _listitem(value) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/packaging/npm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "delphi_epidata",
"description": "Delphi Epidata API Client",
"authors": "Delphi Group",
"version": "0.4.8",
"version": "0.4.9",
"license": "MIT",
"homepage": "https://github.com/cmu-delphi/delphi-epidata",
"bugs": {
Expand Down
2 changes: 1 addition & 1 deletion src/client/packaging/pypi/delphi_epidata/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .delphi_epidata import Epidata

name = 'delphi_epidata'
__version__ = '0.4.8'
__version__ = '0.4.9'
2 changes: 1 addition & 1 deletion src/client/packaging/pypi/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="delphi_epidata",
version="0.4.8",
version="0.4.9",
author="David Farrow",
author_email="[email protected]",
description="A programmatic interface to Delphi's Epidata API.",
Expand Down
2 changes: 1 addition & 1 deletion src/server/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

load_dotenv()

VERSION = "0.4.8"
VERSION = "0.4.9"

MAX_RESULTS = int(10e6)
MAX_COMPATIBILITY_RESULTS = int(3650)
Expand Down
19 changes: 15 additions & 4 deletions src/server/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,21 @@ def __init__(self, geo_type: str, geo_values: Union[bool, Sequence[str]]):
if not isinstance(geo_values, bool):
if geo_values == ['']:
raise ValidationFailedException(f"geo_value is empty for the requested geo_type {geo_type}!")
allowed_values = delphi_utils.geomap.GeoMapper().get_geo_values(geo_type)
invalid_values = set(geo_values) - set(allowed_values)
if invalid_values:
raise ValidationFailedException(f"Invalid geo_value(s) {', '.join(invalid_values)} for the requested geo_type {geo_type}")
# TODO: keep this translator in sync with CsvImporter.GEOGRAPHIC_RESOLUTIONS in acquisition/covidcast/ and with GeoMapper
geo_type_translator = {
"county": "fips",
"state": "state_id",
"zip": "zip",
"hrr": "hrr",
"hhs": "hhs",
"msa": "msa",
"nation": "nation"
}
if geo_type in geo_type_translator: # else geo_type is unknown to GeoMapper
allowed_values = delphi_utils.geomap.GeoMapper().get_geo_values(geo_type_translator[geo_type])
invalid_values = set(geo_values) - set(allowed_values)
if invalid_values:
raise ValidationFailedException(f"Invalid geo_value(s) {', '.join(invalid_values)} for the requested geo_type {geo_type}")
self.geo_type = geo_type
self.geo_values = geo_values

Expand Down
4 changes: 4 additions & 0 deletions tests/server/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def test_parse_geo_arg(self):
self.assertEqual(parse_geo_arg(), [GeoSet("fips", True)])
with app.test_request_context(f"/?geo=fips:{FIPS[0]}"):
self.assertEqual(parse_geo_arg(), [GeoSet("fips", [FIPS[0]])])
with self.subTest("covidcast"):
for geo_type in "county dma hhs hrr msa nation state".split():
with app.test_request_context(f"/?geo={geo_type}:*"):
self.assertEqual(parse_geo_arg(), [GeoSet(geo_type, True)])
with self.subTest("single list"):
with app.test_request_context(f"/?geo=fips:{FIPS[0]},{FIPS[1]}"):
self.assertEqual(parse_geo_arg(), [GeoSet("fips", [FIPS[0], FIPS[1]])])
Expand Down