Skip to content
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

2085 add proportions nhsn #2111

Merged
merged 25 commits into from
Feb 11, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
adding checking updates in progress
aysim319 committed Jan 23, 2025
commit f4b3c404294c73f23f6073baf50337fbab40615b
13 changes: 5 additions & 8 deletions nhsn/delphi_nhsn/pull.py
Original file line number Diff line number Diff line change
@@ -11,13 +11,11 @@

from .constants import MAIN_DATASET_ID, PRELIM_DATASET_ID, PRELIM_SIGNALS_MAP, PRELIM_TYPE_DICT, SIGNALS_MAP, TYPE_DICT

def check_update(socrata_token: str, dataset_id: str):
client = Socrata("data.cdc.gov", socrata_token)
def updated_today(client, dataset_id):
response = client.get_metadata(dataset_id)
updated_timestamp = datetime.utcfromtimestamp(int(response["rowsUpdatedAt"]))
print("bob")


now = datetime.utcnow()
return True if now - updated_timestamp < datetime.timedelta(days=1) else False

def pull_data(socrata_token: str, dataset_id: str):
"""Pull data from Socrata API."""
@@ -96,10 +94,10 @@ def pull_nhsn_data(
Dataframe as described above.
"""
# Pull data from Socrata API
check_update(socrata_token, "ua7e-t2fy")
updated_today(socrata_token, "ua7e-t2fy")
df = (
pull_data(socrata_token, dataset_id=MAIN_DATASET_ID)
if not custom_run
if not custom_run and updated_today
else pull_data_from_file(backup_dir, issue_date, logger, prelim_flag=False)
)

@@ -154,7 +152,6 @@ def pull_preliminary_nhsn_data(
Dataframe as described above.
"""
# Pull data from Socrata API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: pull_preliminary_nhsn_data and pull_nhsn_data are really similar. I think it will become a maintenance issue to keep both. We should probably keep these two functions as wrappers of a shared fn that takes a is_prelim flag (or similar).

Diff of the two fns:

Screen Shot 2025-02-11 at 15 20 55

Copy link
Contributor Author

@aysim319 aysim319 Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know they're similar, i thought about it and went back and forth about it but I was in the thought of maybe in the future there would be something different going on so kept it seperate. I'm not too concerned about this, since we'll be slowly deprecating this codebase;

check_update(socrata_token, "mpgq-jmmr")
df = (
pull_data(socrata_token, dataset_id=PRELIM_DATASET_ID)
if not custom_run