Skip to content

Commit dc505f9

Browse files
authored
Merge pull request #1357 from cmu-delphi/release/delphi-epidata-4.1.15
Release Delphi Epidata 4.1.15
2 parents 1488884 + 33b4239 commit dc505f9

File tree

11 files changed

+22
-19
lines changed

11 files changed

+22
-19
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 = 4.1.14
2+
current_version = 4.1.15
33
commit = False
44
tag = False
55

dev/local/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = Delphi Development
3-
version = 4.1.14
3+
version = 4.1.15
44

55
[options]
66
packages =

requirements.dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
aiohttp==3.8.6
1+
aiohttp==3.9.0
22
black>=20.8b1
33
bump2version==1.0.1
44
covidcast==0.1.5

src/acquisition/covid_hosp/common/database.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -184,19 +184,16 @@ def nan_safe_dtype(dtype, value):
184184
for csv_name in self.key_columns:
185185
dataframe.loc[:, csv_name] = dataframe[csv_name].map(self.columns_and_types[csv_name].dtype)
186186

187-
num_columns = 2 + len(dataframe_columns_and_types) + len(self.additional_fields)
188-
value_placeholders = ', '.join(['%s'] * num_columns)
189187
col_names = [f'`{i.sql_name}`' for i in dataframe_columns_and_types + self.additional_fields]
190-
columns = ', '.join(col_names)
191-
updates = ', '.join(f'{c}=new_values.{c}' for c in col_names)
192-
# NOTE: list in `updates` presumes `publication_col_name` is part of the unique key and thus not needed in UPDATE
193-
sql = f'INSERT INTO `{self.table_name}` (`id`, `{self.publication_col_name}`, {columns}) ' \
194-
f'VALUES ({value_placeholders}) AS new_values ' \
195-
f'ON DUPLICATE KEY UPDATE {updates}'
188+
value_placeholders = ', '.join(['%s'] * (2 + len(col_names))) # extra 2 for `id` and `self.publication_col_name` cols
189+
columnstring = ', '.join(col_names)
190+
sql = f'REPLACE INTO `{self.table_name}` (`id`, `{self.publication_col_name}`, {columnstring}) VALUES ({value_placeholders})'
196191
id_and_publication_date = (0, publication_date)
192+
num_values = len(dataframe.index)
197193
if logger:
198-
logger.info('updating values', count=len(dataframe.index))
194+
logger.info('updating values', count=num_values)
199195
n = 0
196+
rows_affected = 0
200197
many_values = []
201198
with self.new_cursor() as cursor:
202199
for index, row in dataframe.iterrows():
@@ -212,6 +209,7 @@ def nan_safe_dtype(dtype, value):
212209
if n % 5_000 == 0:
213210
try:
214211
cursor.executemany(sql, many_values)
212+
rows_affected += cursor.rowcount
215213
many_values = []
216214
except Exception as e:
217215
if logger:
@@ -220,6 +218,11 @@ def nan_safe_dtype(dtype, value):
220218
# insert final batch
221219
if many_values:
222220
cursor.executemany(sql, many_values)
221+
rows_affected += cursor.rowcount
222+
if logger:
223+
# NOTE: REPLACE INTO marks 2 rows affected for a "replace" (one for a delete and one for a re-insert)
224+
# which allows us to count rows which were updated
225+
logger.info('rows affected', total=rows_affected, updated=rows_affected-num_values)
223226

224227
# deal with non/seldomly updated columns used like a fk table (if this database needs it)
225228
if hasattr(self, 'AGGREGATE_KEY_COLS'):

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 <- getOption('epidata.url', default = 'https://api.delphi.cmu.edu/epidata/')
1717

18-
client_version <- '4.1.14'
18+
client_version <- '4.1.15'
1919

2020
auth <- getOption("epidata.auth", default = NA)
2121

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://api.delphi.cmu.edu/epidata/";
25-
const client_version = "4.1.14";
25+
const client_version = "4.1.15";
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": "4.1.14",
5+
"version": "4.1.15",
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__ = "4.1.14"
4+
__version__ = "4.1.15"

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="4.1.14",
8+
version="4.1.15",
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
@@ -7,7 +7,7 @@
77

88
load_dotenv()
99

10-
VERSION = "4.1.14"
10+
VERSION = "4.1.15"
1111

1212
MAX_RESULTS = int(10e6)
1313
MAX_COMPATIBILITY_RESULTS = int(3650)

tests/acquisition/covid_hosp/common/test_database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_insert_dataset(self):
148148

149149
actual_sql = mock_cursor.executemany.call_args[0][0]
150150
self.assertIn(
151-
'INSERT INTO `test_table` (`id`, `publication_date`, `sql_str_col`, `sql_int_col`, `sql_float_col`)',
151+
'REPLACE INTO `test_table` (`id`, `publication_date`, `sql_str_col`, `sql_int_col`, `sql_float_col`)',
152152
actual_sql)
153153

154154
expected_values = [

0 commit comments

Comments
 (0)