Skip to content

Make data.cdc.gov data pull helpers more generic and use httr2.#155

Merged
dylanhmorris merged 11 commits into
mainfrom
dhm-pull-nssp
Jun 10, 2025
Merged

Make data.cdc.gov data pull helpers more generic and use httr2.#155
dylanhmorris merged 11 commits into
mainfrom
dhm-pull-nssp

Conversation

@dylanhmorris

@dylanhmorris dylanhmorris commented Jun 9, 2025

Copy link
Copy Markdown
Collaborator

Closes #156

Prerequisite for #148 ; decided to separate this off for ease of review.

  • Replaces httr with httr2 and httptest with httptest2
  • Makes pull_nhsn() into a light wrapper of more generic functions for API calls in general and interactions with data.cdc.gov in particular

@dylanhmorris dylanhmorris linked an issue Jun 9, 2025 that may be closed by this pull request
@dylanhmorris dylanhmorris changed the title Dhm pull nssp Make data.cdc.gov data pull helpers more generic, add pull_nssp helper. Jun 9, 2025
@codecov

codecov Bot commented Jun 9, 2025

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 90.74074% with 5 lines in your changes missing coverage. Please review.

Project coverage is 64.29%. Comparing base (d7105bb) to head (a2920ef).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
R/pull_data_cdc_gov.R 90.74% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #155      +/-   ##
==========================================
+ Coverage   63.76%   64.29%   +0.52%     
==========================================
  Files          28       28              
  Lines        1551     1574      +23     
==========================================
+ Hits          989     1012      +23     
  Misses        562      562              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dylanhmorris dylanhmorris changed the title Make data.cdc.gov data pull helpers more generic, add pull_nssp helper. Make data.cdc.gov data pull helpers more generic and use httr2. Jun 9, 2025
@dylanhmorris
dylanhmorris requested a review from sbidari June 9, 2025 21:04
@dylanhmorris
dylanhmorris marked this pull request as ready for review June 9, 2025 21:24
@dylanhmorris
dylanhmorris requested a review from damonbayer as a code owner June 9, 2025 21:24
@dylanhmorris
dylanhmorris requested a review from Copilot June 9, 2025 21:24

This comment was marked as outdated.

@dylanhmorris
dylanhmorris requested a review from Copilot June 10, 2025 19:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the data pull helpers for data.cdc.gov to be more generic, replacing the previous httr-based implementation with a new httr2‐based workflow. In addition, it updates the documentation, tests, and API endpoint configuration to support the new design.

  • Updated vignette chunks to use httptest2 and removed obsolete httr calls.
  • Introduced functions for constructing data.cdc.gov endpoints and managing API credentials.
  • Revised tests and data mocks to align with the new API request implementations.

Reviewed Changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
vignettes/pull-nhsn.Rmd Updated chunk labels and switched to httptest2; duplicate ENV assignment noted.
tests/testthat/* Added tests for warning behavior and replaced httptest with httptest2.
R/pull_data_cdc_gov.R Migrated API requests from httr to httr2 and improved error-handling logic.
man/*.Rd & R/constants.R Updated documentation to reference new functions and dataset IDs.
NAMESPACE & DESCRIPTION Updated exports and dependencies to reflect changes with httr2 and httptest2.
Comments suppressed due to low confidence (1)

R/pull_data_cdc_gov.R:193

  • Ensure that checking nrow(df) >= limit correctly captures the case where the query result is exactly at the limit, which could indicate truncated data. Verify that this behavior is intended or consider providing additional guidance in the documentation.
if (error_on_limit && nrow(df) >= limit) {

Comment thread vignettes/pull-nhsn.Rmd Outdated

@sbidari sbidari left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM! Thanks @dylanhmorris

@dylanhmorris
dylanhmorris enabled auto-merge (squash) June 10, 2025 22:47
@dylanhmorris
dylanhmorris merged commit 6a19d93 into main Jun 10, 2025
12 checks passed
@dylanhmorris
dylanhmorris deleted the dhm-pull-nssp branch June 10, 2025 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Depend on httr2 instead of httr

3 participants