-
Notifications
You must be signed in to change notification settings - Fork 16
2129 fix hrr for nssp #2131
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
2129 fix hrr for nssp #2131
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c1e9d56
first implimentation
aysim319 4ac06a0
tests and clean up
aysim319 dfe0a6a
fixing copy pasta
aysim319 a4da3fe
name change for host
aysim319 6b95121
adding test data
aysim319 59dd036
suggested commits
aysim319 ffb42ab
re adding content
aysim319 8254aa5
moving to proper place
aysim319 7ae7bcd
lint
aysim319 a4d7b9e
fixed test
aysim319 19358d4
fix import error
aysim319 4607a69
adding fixture for hrr run
aysim319 c853c99
comment on test for hrr
aysim319 77f337b
Apply suggestions from code review
aysim319 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
"""Registry for variations.""" | ||
|
||
DATASET_ID = "rdmq-nq56" | ||
|
||
GEOS = [ | ||
"hrr", | ||
"msa", | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import copy | ||
import json | ||
import time | ||
from unittest.mock import patch, MagicMock | ||
|
||
import pytest | ||
from pathlib import Path | ||
|
||
from delphi_nssp.run import run_module | ||
from delphi_nssp.constants import DATASET_ID | ||
|
||
TEST_DIR = Path(__file__).parent | ||
|
||
# test data generated with following url with socrata: | ||
# https://data.cdc.gov/resource/rdmq-nq56.json?$where=week_end >= '2022-10-01T00:00:00.000' AND week_end <= '2022-10-20T00:00:00.000' | ||
|
||
with open(f"{TEST_DIR}/test_data/page.json", "r") as f: | ||
TEST_DATA = json.load(f) | ||
|
||
with open(f"{TEST_DIR}/test_data/page_100_hrr.json", "r") as f: | ||
HRR_TEST_DATA = json.load(f) | ||
|
||
@pytest.fixture(scope="session") | ||
def params(): | ||
params = { | ||
"common": { | ||
"export_dir": f"{TEST_DIR}/receiving", | ||
"log_filename": f"{TEST_DIR}/test.log", | ||
"backup_dir": f"{TEST_DIR}/test_raw_data_backups", | ||
"custom_run": False | ||
}, | ||
"indicator": { | ||
"wip_signal": True, | ||
"export_start_date": "2020-08-01", | ||
"static_file_dir": "./static", | ||
"socrata_token": "test_token" | ||
}, | ||
"validation": { | ||
"common": { | ||
"span_length": 14, | ||
"min_expected_lag": {"all": "3"}, | ||
"max_expected_lag": {"all": "4"}, | ||
} | ||
} | ||
} | ||
return copy.deepcopy(params) | ||
|
||
@pytest.fixture | ||
def params_w_patch(params): | ||
params_copy = copy.deepcopy(params) | ||
params_copy["common"]["custom_run"] = True | ||
params_copy["patch"] = { | ||
"patch_dir": f"{TEST_DIR}/patch_dir", | ||
"source_dir": "test_source_dir", | ||
"source_host": "host", | ||
"user": "test_user", | ||
"start_issue": "2023-01-01", | ||
"end_issue": "2023-01-03", | ||
} | ||
|
||
return params_copy | ||
|
||
@pytest.fixture(scope="function") | ||
def run_as_module(params): | ||
""" | ||
Fixture to use TEST_DATA when testing run_module. | ||
|
||
This fixture patches Socrara to return the predefined test data | ||
""" | ||
|
||
with patch('sodapy.Socrata.get') as mock_get: | ||
def side_effect(*args, **kwargs): | ||
if kwargs['offset'] == 0: | ||
if DATASET_ID in args[0]: | ||
return TEST_DATA | ||
else: | ||
return [] | ||
mock_get.side_effect = side_effect | ||
run_module(params) | ||
|
||
|
||
|
||
@pytest.fixture(scope="function") | ||
def run_as_module_hrr(params): | ||
aysim319 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
""" | ||
Fixture to use HRR_TEST_DATA when testing run_module. | ||
|
||
This fixture patches socrara to return the predefined test data for HRR region. | ||
""" | ||
|
||
with patch('sodapy.Socrata.get') as mock_get, \ | ||
patch('delphi_nssp.run.GEOS', ["hrr"]): | ||
def side_effect(*args, **kwargs): | ||
if kwargs['offset'] == 0: | ||
if DATASET_ID in args[0]: | ||
return HRR_TEST_DATA | ||
else: | ||
return [] | ||
mock_get.side_effect = side_effect | ||
run_module(params) | ||
|
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
[ | ||
{ | ||
"week_end": "2022-10-01T00:00:00.000", | ||
"geography": "United States", | ||
"county": "All", | ||
"percent_visits_combined": "2.84", | ||
"percent_visits_covid": "1.84", | ||
"percent_visits_influenza": "0.48", | ||
"percent_visits_rsv": "0.55", | ||
"percent_visits_smoothed": "2.83", | ||
"percent_visits_smoothed_covid": "2.07", | ||
"percent_visits_smoothed_1": "0.34", | ||
"percent_visits_smoothed_rsv": "0.44", | ||
"ed_trends_covid": "Decreasing", | ||
"ed_trends_influenza": "Increasing", | ||
"ed_trends_rsv": "Increasing", | ||
"hsa": "All", | ||
"hsa_counties": "All", | ||
"hsa_nci_id": "All", | ||
"fips": "0", | ||
"trend_source": "United States", | ||
"buildnumber": "2025-02-28" | ||
}, | ||
{ | ||
"week_end": "2022-10-01T00:00:00.000", | ||
"geography": "Colorado", | ||
"county": "All", | ||
"percent_visits_combined": "1.86", | ||
"percent_visits_covid": "1.61", | ||
"percent_visits_influenza": "0.1", | ||
"percent_visits_rsv": "0.16", | ||
"percent_visits_smoothed": "1.83", | ||
"percent_visits_smoothed_covid": "1.61", | ||
"percent_visits_smoothed_1": "0.1", | ||
"percent_visits_smoothed_rsv": "0.12", | ||
"ed_trends_covid": "Decreasing", | ||
"ed_trends_influenza": "Increasing", | ||
"ed_trends_rsv": "Increasing", | ||
"hsa": "All", | ||
"hsa_counties": "All", | ||
"hsa_nci_id": "All", | ||
"fips": "8000", | ||
"trend_source": "State", | ||
"buildnumber": "2025-02-28" | ||
}, | ||
{ | ||
"week_end": "2022-10-01T00:00:00.000", | ||
"geography": "Colorado", | ||
"county": "Broomfield", | ||
"percent_visits_combined": "2.29", | ||
"percent_visits_covid": "1.78", | ||
"percent_visits_influenza": "0.11", | ||
"percent_visits_rsv": "0.4", | ||
"percent_visits_smoothed": "2.06", | ||
"percent_visits_smoothed_covid": "1.7", | ||
"percent_visits_smoothed_1": "0.07", | ||
"percent_visits_smoothed_rsv": "0.32", | ||
"ed_trends_covid": "No Change", | ||
"ed_trends_influenza": "Increasing", | ||
"ed_trends_rsv": "Increasing", | ||
"hsa": "Boulder, CO - Broomfield, CO", | ||
"hsa_counties": "Boulder, Broomfield", | ||
"hsa_nci_id": "795", | ||
"fips": "8014", | ||
"trend_source": "HSA", | ||
"buildnumber": "2025-02-28" | ||
}, | ||
{ | ||
"week_end": "2022-10-08T00:00:00.000", | ||
"geography": "United States", | ||
"county": "All", | ||
"percent_visits_combined": "2.93", | ||
"percent_visits_covid": "1.68", | ||
"percent_visits_influenza": "0.68", | ||
"percent_visits_rsv": "0.6", | ||
"percent_visits_smoothed": "2.85", | ||
"percent_visits_smoothed_covid": "1.85", | ||
"percent_visits_smoothed_1": "0.49", | ||
"percent_visits_smoothed_rsv": "0.53", | ||
"ed_trends_covid": "Decreasing", | ||
"ed_trends_influenza": "Increasing", | ||
"ed_trends_rsv": "Increasing", | ||
"hsa": "All", | ||
"hsa_counties": "All", | ||
"hsa_nci_id": "All", | ||
"fips": "0", | ||
"trend_source": "United States", | ||
"buildnumber": "2025-02-28" | ||
}, | ||
{ | ||
"week_end": "2022-10-08T00:00:00.000", | ||
"geography": "Colorado", | ||
"county": "All", | ||
"percent_visits_combined": "1.82", | ||
"percent_visits_covid": "1.54", | ||
"percent_visits_influenza": "0.09", | ||
"percent_visits_rsv": "0.2", | ||
"percent_visits_smoothed": "1.83", | ||
"percent_visits_smoothed_covid": "1.58", | ||
"percent_visits_smoothed_1": "0.1", | ||
"percent_visits_smoothed_rsv": "0.16", | ||
"ed_trends_covid": "Decreasing", | ||
"ed_trends_influenza": "No Change", | ||
"ed_trends_rsv": "Increasing", | ||
"hsa": "All", | ||
"hsa_counties": "All", | ||
"hsa_nci_id": "All", | ||
"fips": "8000", | ||
"trend_source": "State", | ||
"buildnumber": "2025-02-28" | ||
}, | ||
{ | ||
"week_end": "2022-10-08T00:00:00.000", | ||
"geography": "Colorado", | ||
"county": "Arapahoe", | ||
"percent_visits_combined": "1.78", | ||
"percent_visits_covid": "1.43", | ||
"percent_visits_influenza": "0.12", | ||
"percent_visits_rsv": "0.23", | ||
"percent_visits_smoothed": "1.74", | ||
"percent_visits_smoothed_covid": "1.4", | ||
"percent_visits_smoothed_1": "0.12", | ||
"percent_visits_smoothed_rsv": "0.25", | ||
"ed_trends_covid": "Increasing", | ||
"ed_trends_influenza": "Increasing", | ||
"ed_trends_rsv": "Increasing", | ||
"hsa": "Denver (Denver), CO - Jefferson, CO", | ||
"hsa_counties": "Adams, Arapahoe, Clear Creek, Denver, Douglas, Elbert, Gilpin, Grand, Jefferson, Park, Summit", | ||
"hsa_nci_id": "688", | ||
"fips": "8005", | ||
"trend_source": "HSA", | ||
"buildnumber": "2025-02-28" | ||
}, | ||
{ | ||
"week_end": "2022-10-15T00:00:00.000", | ||
"geography": "United States", | ||
"county": "All", | ||
"percent_visits_combined": "3.25", | ||
"percent_visits_covid": "1.64", | ||
"percent_visits_influenza": "0.9", | ||
"percent_visits_rsv": "0.74", | ||
"percent_visits_smoothed": "3.01", | ||
"percent_visits_smoothed_covid": "1.72", | ||
"percent_visits_smoothed_1": "0.69", | ||
"percent_visits_smoothed_rsv": "0.63", | ||
"ed_trends_covid": "Decreasing", | ||
"ed_trends_influenza": "Increasing", | ||
"ed_trends_rsv": "Increasing", | ||
"hsa": "All", | ||
"hsa_counties": "All", | ||
"hsa_nci_id": "All", | ||
"fips": "0", | ||
"trend_source": "United States", | ||
"buildnumber": "2025-02-28" | ||
}, | ||
{ | ||
"week_end": "2022-10-15T00:00:00.000", | ||
"geography": "Colorado", | ||
"county": "All", | ||
"percent_visits_combined": "2.22", | ||
"percent_visits_covid": "1.7", | ||
"percent_visits_influenza": "0.14", | ||
"percent_visits_rsv": "0.39", | ||
"percent_visits_smoothed": "1.97", | ||
"percent_visits_smoothed_covid": "1.62", | ||
"percent_visits_smoothed_1": "0.11", | ||
"percent_visits_smoothed_rsv": "0.25", | ||
"ed_trends_covid": "No Change", | ||
"ed_trends_influenza": "No Change", | ||
"ed_trends_rsv": "Increasing", | ||
"hsa": "All", | ||
"hsa_counties": "All", | ||
"hsa_nci_id": "All", | ||
"fips": "8000", | ||
"trend_source": "State", | ||
"buildnumber": "2025-02-28" | ||
}, | ||
{ | ||
"week_end": "2022-10-15T00:00:00.000", | ||
"geography": "Colorado", | ||
"county": "Pueblo", | ||
"percent_visits_combined": "3.24", | ||
"percent_visits_covid": "2.97", | ||
"percent_visits_influenza": "0.14", | ||
"percent_visits_rsv": "0.14", | ||
"percent_visits_smoothed": "2.99", | ||
"percent_visits_smoothed_covid": "2.82", | ||
"percent_visits_smoothed_1": "0.07", | ||
"percent_visits_smoothed_rsv": "0.1", | ||
"ed_trends_covid": "Increasing", | ||
"ed_trends_influenza": "Increasing", | ||
"ed_trends_rsv": "Increasing", | ||
"hsa": "Pueblo (Pueblo), CO - Las Animas, CO", | ||
"hsa_counties": "Huerfano, Las Animas, Pueblo", | ||
"hsa_nci_id": "704", | ||
"fips": "8101", | ||
"trend_source": "HSA", | ||
"buildnumber": "2025-02-28" | ||
} | ||
] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.