Skip to content

Commit 7acfec6

Browse files
authored
Merge pull request #870 from cmu-delphi/release/delphi-epidata-0.3.13
Release Delphi Epidata 0.3.13
2 parents 5514286 + cd2f2bc commit 7acfec6

File tree

13 files changed

+46
-24
lines changed

13 files changed

+46
-24
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.3.12
2+
current_version = 0.3.13
33
commit = False
44
tag = False
55

src/acquisition/covidcast/csv_importer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class CsvImporter:
4343
"val": float,
4444
"se": float,
4545
"sample_size": float,
46-
"missing_val": int,
47-
"missing_se": int,
48-
"missing_sample_size": int
46+
"missing_val": "Int64",
47+
"missing_se": "Int64",
48+
"missing_sample_size": "Int64"
4949
}
5050

5151
# NOTE: this should be a Python 3.7+ `dataclass`, but the server is on 3.4

src/acquisition/covidcast/database.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ def delete_batch(self, cc_deletions):
326326
'''
327327

328328
drop_tmp_table_sql = f'DROP TABLE {tmp_table_name}'
329+
total = None
329330
try:
330331
self._cursor.execute(create_tmp_table_sql)
331332
self._cursor.execute(amend_tmp_table_sql)
@@ -337,12 +338,18 @@ def delete_batch(self, cc_deletions):
337338
raise Exception(f"Bad deletions argument: need a filename or a list of tuples; got a {type(cc_deletions)}")
338339
self._cursor.execute(add_id_sql)
339340
self._cursor.execute(delete_sql)
341+
total = self._cursor.rowcount
340342
self._cursor.execute(fix_latest_issue_sql)
341343
self._connection.commit()
344+
345+
if total == -1:
346+
# the SQL connector does not support returning number of rows affected (see PEP 249)
347+
total = None
342348
except Exception as e:
343349
raise e
344350
finally:
345351
self._cursor.execute(drop_tmp_table_sql)
352+
return total
346353

347354
def compute_covidcast_meta(self, table_name='covidcast', use_index=True):
348355
"""Compute and return metadata on all non-WIP COVIDcast signals."""

src/acquisition/covidcast/delete_batch.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# standard library
44
import argparse
5+
import glob
56
import os
67
import time
78

@@ -22,19 +23,21 @@ def get_argument_parser():
2223
help="filename for log output (defaults to stdout)")
2324
return parser
2425

25-
def handle_file(deletion_file, database):
26+
def handle_file(deletion_file, database, logger):
2627
logger.info("Deleting from csv file", filename=deletion_file)
2728
rows = []
2829
with open(deletion_file) as f:
2930
for line in f:
30-
rows.append(line.strip().split(","))
31+
fields = line.strip().split(",")
32+
if len(fields) < 9: continue
33+
rows.append(fields + ["day"])
3134
rows = rows[1:]
3235
try:
3336
n = database.delete_batch(rows)
3437
logger.info("Deleted database rows", row_count=n)
3538
return n
3639
except Exception as e:
37-
logger.exception('Exception while deleting rows:', e)
40+
logger.exception('Exception while deleting rows', exception=e)
3841
database.rollback()
3942
return 0
4043

@@ -49,7 +52,11 @@ def main(args):
4952

5053
try:
5154
for deletion_file in sorted(glob.glob(os.path.join(args.deletion_dir, '*.csv'))):
52-
all_n += handle_file(deletion_file)
55+
n = handle_file(deletion_file, database, logger)
56+
if n is not None:
57+
all_n += n
58+
else:
59+
all_n = "rowcount unsupported"
5360
finally:
5461
database.disconnect(True)
5562

src/client/delphi_epidata.R

Lines changed: 1 addition & 1 deletion
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.3.12'
18+
client_version <- '0.3.13'
1919

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

src/client/delphi_epidata.js

Lines changed: 1 addition & 1 deletion
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.3.12";
25+
const client_version = "0.3.13";
2626

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

src/client/packaging/npm/package.json

Lines changed: 1 addition & 1 deletion
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.3.12",
5+
"version": "0.3.13",
66
"license": "MIT",
77
"homepage": "https://github.com/cmu-delphi/delphi-epidata",
88
"bugs": {
Lines changed: 1 addition & 1 deletion
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.3.12'
4+
__version__ = '0.3.13'

src/client/packaging/pypi/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

src/server/_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
load_dotenv()
77

8-
VERSION = "0.3.12"
8+
VERSION = "0.3.13"
99

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

src/server/endpoints/covidcast_utils/db_signals.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ National provisional death counts is based on death certificate data received an
782782
nchs-mortality,deaths_pneumonia_or_flu_or_covid_incidence_num,TRUE,deaths_pneumonia_or_flu_or_covid_incidence_prop,FALSE,"COVID, Pneumonia or Influenza Deaths (Weekly new, per 100k people)",TRUE,"Number of weekly new deaths involving Pneumonia, Influenza, or COVID-19, per 100k people","{short_description}.
783783

784784
National provisional death counts is based on death certificate data received and coded by the National Center for Health Statistics ([NCHS](https://www.cdc.gov/nchs/nvss/vsrr/COVID19/index.htm))",week,Week,Value,per100k,late,bad,FALSE,FALSE,FALSE,FALSE,FALSE,
785-
quidel-covid-ag,covid_ag_raw_pct_positive,FALSE,covid_ag_raw_pct_positive,FALSE,COVID-19 Antigen Tests: Percent Positive,TRUE,Percentage of antigen tests that were positive for COVID-19,"When a patient (whether at a doctor’s office, clinic, or hospital) has COVID-like symptoms, doctors may order an antigen test. An antigen test can detect parts of the virus that are present during an active infection. This is in contrast with antibody tests, which detect parts of the immune system that react to the virus, but which persist long after the infection has passed. For this signal, we compute the percentage of antigen tests performed that were positive for COVID-19.",day,Date,Percentage,percent,cases_testing,bad,FALSE,FALSE,FALSE,TRUE,TRUE,[Technical description](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/quidel.html#covid-19-tests)
785+
quidel-covid-ag,covid_ag_raw_pct_positive,FALSE,covid_ag_raw_pct_positive,FALSE,COVID-19 Antigen Tests: Percent Positive,TRUE,Percentage of antigen tests that were positive for COVID-19,"When a patient (whether at a doctor's office, clinic, or hospital) has COVID-like symptoms, doctors may order an antigen test. An antigen test can detect parts of the virus that are present during an active infection. This is in contrast with antibody tests, which detect parts of the immune system that react to the virus, but which persist long after the infection has passed. For this signal, we compute the percentage of antigen tests performed that were positive for COVID-19.",day,Date,Percentage,percent,cases_testing,bad,FALSE,FALSE,FALSE,TRUE,TRUE,[Technical description](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/quidel.html#covid-19-tests)
786786
quidel-covid-ag,covid_ag_raw_pct_positive,TRUE,covid_ag_smoothed_pct_positive,FALSE,{base_name} (7-day average),TRUE,,,day,Date,Percentage,percent,cases_testing,bad,TRUE,FALSE,FALSE,TRUE,TRUE,
787787
quidel-covid-ag,covid_ag_raw_pct_positive_age_0_17,FALSE,covid_ag_raw_pct_positive_age_0_17,FALSE,"COVID-19 Antigen Tests: Percent Positive, Ages 0-17",TRUE,Percentage of antigen tests that were positive for COVID-19 among people ages 0-17,"When a patient (whether at a doctor’s office, clinic, or hospital) has COVID-like symptoms, doctors may order an antigen test. An antigen test can detect parts of the virus that are present during an active infection. This is in contrast with antibody tests, which detect parts of the immune system that react to the virus, but which persist long after the infection has passed. For this signal, we compute the percentage of antigen tests performed that were positive for COVID-19 among people ages 0-17",day,Date,Percentage,percent,cases_testing,bad,FALSE,FALSE,FALSE,TRUE,TRUE,[Technical description](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/quidel.html#covid-19-tests)
788788
quidel-covid-ag,covid_ag_raw_pct_positive_age_0_17,TRUE,covid_ag_smoothed_pct_positive_age_0_17,FALSE,{base_name} (Smoothed),TRUE,,"{base_description}, smoothed using a 7-day moving average and geographical pooling",day,Date,Percentage,percent,cases_testing,bad,TRUE,FALSE,FALSE,TRUE,TRUE,

src/server/endpoints/covidcast_utils/db_sources.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fb-survey,fb-survey,Delphi US COVID-19 Trends and Impact Survey,"We conduct the
77
[Question text](https://cmu-delphi.github.io/delphi-epidata/symptom-survey/coding.html)"
88
google-symptoms,google-symptoms,Google Symptoms Search Trends,"Google's [COVID-19 Search Trends symptoms dataset](http://goo.gle/covid19symptomdataset) reflects the relative volume of Google searches for a broad set of symptoms, signs and health conditions. This source includes signals for 7 symptom sets: 6 sets of COVID-related symptoms, and 1 set of control symptoms unrelated to COVID-19.
99

10-
Because of the way this dataset is constructed, values are comparable across signals in the same location, but not across geographic regions, even within the same signal. Use caution in any geographic analyses.",anosmia_smoothed_search,"To download or use the data, you must agree to the Google [Terms of Service](https://policies.google.com/terms)",,[API Documentation](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/google-symptoms.html)
10+
Because of the way this dataset is constructed, values are comparable across signals in the same location, but not across geographic regions, even within the same signal. Use caution in any geographic analyses.",s05_smoothed_search,"To download or use the data, you must agree to the Google [Terms of Service](https://policies.google.com/terms)",,[API Documentation](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/google-symptoms.html)
1111
hhs,hhs,U.S. Department of Health & Human Services,The US Department of Health & Human Services (HHS) publishes several datasets on patient impact and hospital capacity. This source includes only adult and pediatric hospital admissions with confirmed and suspected COVID-19 or confirmed influenza.,confirmed_admissions_1d,[Public Domain US Government](https://www.usa.gov/government-works),,[API Documentation](https://cmu-delphi.github.io/delphi-epidata/api/covidcast-signals/hhs.html)
1212
hospital-admissions,hospital-admissions,Hospital Admissions From Claims,"Information about hospital admissions, provided to us by health system partners. Using inpatient claim counts, we estimate the percentage of new hospital admissions with a COVID-associated diagnosis code in a given location, on a given day.
1313

tests/acquisition/covidcast/test_csv_importer.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -278,13 +278,13 @@ def test_load_csv_with_valid_header(self):
278278

279279
# now with missing values!
280280
data = {
281-
'geo_id': ['ca', 'tx', 'fl', 'ak'],
282-
'val': [np.nan, '1.2', '1.3', '1.4'],
283-
'se': ['2.1', "na", '2.3', '2.4'],
284-
'sample_size': ['301', '302', None, '304'],
285-
'missing_value': [Nans.NOT_APPLICABLE] + [Nans.NOT_MISSING] * 3,
286-
'missing_stderr': [Nans.NOT_MISSING, Nans.REGION_EXCEPTION, Nans.NOT_MISSING, Nans.NOT_MISSING],
287-
'missing_sample_size': [Nans.NOT_MISSING] * 2 + [Nans.REGION_EXCEPTION] * 2
281+
'geo_id': ['ca', 'tx', 'fl', 'ak', 'wa'],
282+
'val': [np.nan, '1.2', '1.3', '1.4', '1.5'],
283+
'se': ['2.1', "na", '2.3', '2.4', '2.5'],
284+
'sample_size': ['301', '302', None, '304', None],
285+
'missing_value': [Nans.NOT_APPLICABLE] + [Nans.NOT_MISSING] * 3 + [None],
286+
'missing_stderr': [Nans.NOT_MISSING, Nans.REGION_EXCEPTION, Nans.NOT_MISSING, Nans.NOT_MISSING] + [None],
287+
'missing_sample_size': [Nans.NOT_MISSING] * 2 + [Nans.REGION_EXCEPTION] * 2 + [None]
288288
}
289289
mock_pandas = MagicMock()
290290
mock_pandas.read_csv.return_value = pandas.DataFrame(data=data)
@@ -295,7 +295,7 @@ def test_load_csv_with_valid_header(self):
295295

296296
self.assertTrue(mock_pandas.read_csv.called)
297297
self.assertTrue(mock_pandas.read_csv.call_args[0][0], filepath)
298-
self.assertEqual(len(rows), 4)
298+
self.assertEqual(len(rows), 5)
299299

300300
self.assertEqual(rows[0].geo_value, 'ca')
301301
self.assertIsNone(rows[0].value)
@@ -328,3 +328,11 @@ def test_load_csv_with_valid_header(self):
328328
self.assertEqual(rows[3].missing_value, Nans.NOT_MISSING)
329329
self.assertEqual(rows[3].missing_stderr, Nans.NOT_MISSING)
330330
self.assertEqual(rows[3].missing_sample_size, Nans.NOT_MISSING)
331+
332+
self.assertEqual(rows[4].geo_value, 'wa')
333+
self.assertEqual(rows[4].value, 1.5)
334+
self.assertEqual(rows[4].stderr, 2.5)
335+
self.assertEqual(rows[4].sample_size, None)
336+
self.assertEqual(rows[4].missing_value, Nans.NOT_MISSING)
337+
self.assertEqual(rows[4].missing_stderr, Nans.NOT_MISSING)
338+
self.assertEqual(rows[4].missing_sample_size, Nans.OTHER)

0 commit comments

Comments
 (0)