Skip to content

Commit 5532aac

Browse files
nmdefriesaysim319
authored andcommitted
move pull date creation into pull_gs_data
1 parent 46b6317 commit 5532aac

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

google_symptoms/delphi_google_symptoms/pull.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from google.oauth2 import service_account
1010

1111
from .constants import COMBINED_METRIC, DC_FIPS, DTYPE_CONVERSIONS, METRICS, SYMPTOM_SETS
12+
from .date_utils import generate_query_dates
1213

1314
# Create map of BigQuery symptom column names to desired column names.
1415
colname_map = {"symptom_" +
@@ -214,7 +215,7 @@ def initialize_credentials(credentials):
214215
pandas_gbq.context.project = credentials.project_id
215216

216217

217-
def pull_gs_data(credentials, export_date_range):
218+
def pull_gs_data(credentials, export_start_date, export_end_date, num_export_days, custom_run_flag):
218219
"""Pull latest dataset for each geo level and combine.
219220
220221
PS: No information for PR
@@ -237,7 +238,7 @@ def pull_gs_data(credentials, export_date_range):
237238
dict: {"county": pd.DataFrame, "state": pd.DataFrame}
238239
"""
239240
# Fetch and format dates we want to attempt to retrieve
240-
241+
export_date_range = generate_query_dates(export_start_date, export_end_date, num_export_days, custom_run_flag)
241242
retrieve_dates = format_dates_for_query(export_date_range)
242243

243244
initialize_credentials(credentials)

google_symptoms/delphi_google_symptoms/run.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from delphi_utils import create_export_csv, get_structured_logger
1313

1414
from .constants import COMBINED_METRIC, GEO_RESOLUTIONS, SMOOTHERS, SMOOTHERS_MAP
15-
from .date_utils import generate_num_export_days, generate_query_dates
15+
from .date_utils import generate_num_export_days
1616
from .geo import geo_map
1717
from .pull import pull_gs_data
1818

@@ -58,10 +58,9 @@ def run_module(params, logger=None):
5858
custom_run_flag = (
5959
False if not params["indicator"].get("custom_run", False) else params["indicator"].get("custom_run", False)
6060
)
61-
export_date_range = generate_query_dates(export_start_date, export_end_date, num_export_days, custom_run_flag)
6261

6362
# Pull GS data
64-
dfs = pull_gs_data(params["indicator"]["bigquery_credentials"], export_date_range)
63+
dfs = pull_gs_data(params["indicator"]["bigquery_credentials"], export_start_date, export_end_date, num_export_days, custom_run_flag)
6564
for geo_res in GEO_RESOLUTIONS:
6665
if geo_res == "state":
6766
df_pull = dfs["state"]

google_symptoms/tests/test_pull.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def test_good_file(self, mock_credentials, mock_read_gbq):
4444
"20201230", "%Y%m%d")
4545
end_date = datetime.combine(date.today(), datetime.min.time())
4646

47-
dfs = pull_gs_data("", [start_date, end_date])
47+
dfs = pull_gs_data("", datetime.strptime(
48+
"20201230", "%Y%m%d"), datetime.combine(date.today(), datetime.min.time()), 0, False)
4849

4950
for level in ["county", "state"]:
5051
df = dfs[level]

0 commit comments

Comments
 (0)