Skip to content

Commit

Permalink
Weekly forecast visualization data (#264)
Browse files Browse the repository at this point in the history
* consolidate weekly visualization data and web text generation

* only include designated models in the webpage

* Update weekly data and web text

---------

Co-authored-by: sbidari <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 10, 2025
1 parent 4a5bdb4 commit 5b33b29
Show file tree
Hide file tree
Showing 6 changed files with 14,116 additions and 76 deletions.
116 changes: 41 additions & 75 deletions .github/workflows/generate-forecast-visualization-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,84 +12,50 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v4
with:
application_id: ${{ vars.GH_APP_ID }}
application_private_key: ${{ secrets.GH_APP_KEY }}

- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
install-r: false
use-public-rspm: true

- name: Install dependencies
run: |
install.packages(c("argparser", "fs", "readr", "dplyr", "remotes", "RcppTOML", "tidyr", "lubridate"))
remotes::install_github('cdcgov/forecasttools')
remotes::install_github("hubverse-org/hubData")
shell: Rscript {0}

- name: generate data files
run: |
REF_DATE=$(Rscript -e "cat(strftime(lubridate::ceiling_date(lubridate::today(), 'week', week_start = 6, change_on_boundary = FALSE)))")
Rscript src/get_covid_hosp_data.R --reference_date "$REF_DATE" --base_hub_path "." --target_data FALSE
Rscript src/get_forecast_data.R --reference_date "$REF_DATE" --base_hub_path "." --horizons_to_include 0 1 2
Rscript src/get_map_data.R --reference_date "$REF_DATE" --base_hub_path "." --horizons_to_include 0 1 2
env:
NHSN_API_KEY_ID: ${{ secrets.NHSN_API_KEY_ID }}
NHSN_API_KEY_SECRET: ${{ secrets.NHSN_API_KEY_SECRET }}
- name: Checkout code
uses: actions/checkout@v4

- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
message: "Update weekly data"
default_author: github_actions
push: true
new_branch: add-viz-data
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
install-r: false
use-public-rspm: true

generate-webtext:
needs: update-visualization-data
if: ${{ github.repository_owner == 'CDCgov' }}
runs-on: ubuntu-22.04
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v4
with:
application_id: ${{ vars.GH_APP_ID }}
application_private_key: ${{ secrets.GH_APP_KEY }}
- name: Install dependencies
run: |
install.packages(c("argparser", "fs", "readr", "dplyr", "remotes", "RcppTOML", "tidyr", "lubridate", "glue"))
remotes::install_github('cdcgov/forecasttools')
remotes::install_github("hubverse-org/hubData")
shell: Rscript {0}

- name: Checkout code
uses: actions/checkout@v4
- name: Generate data files
run: |
REF_DATE=$(Rscript -e "cat(strftime(lubridate::ceiling_date(lubridate::today(), 'week', week_start = 6, change_on_boundary = FALSE)))")
Rscript src/get_covid_hosp_data.R --reference_date "$REF_DATE" --base_hub_path "." --target_data FALSE
Rscript src/get_forecast_data.R --reference_date "$REF_DATE" --base_hub_path "." --horizons_to_include 0 1 2
Rscript src/get_map_data.R --reference_date "$REF_DATE" --base_hub_path "." --horizons_to_include 0 1 2
Rscript src/get_webtext.R --reference_date "$REF_DATE" --base_hub_path "."
env:
NHSN_API_KEY_ID: ${{ secrets.NHSN_API_KEY_ID }}
NHSN_API_KEY_SECRET: ${{ secrets.NHSN_API_KEY_SECRET }}

- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
install-r: false
use-public-rspm: true

- name: Install dependencies
run: |
install.packages(c("argparser", "readr", "dplyr", "remotes", "glue"))
remotes::install_github("hubverse-org/hubData")
shell: Rscript {0}

- name: generate data files
run: |
REF_DATE=$(Rscript -e "cat(strftime(lubridate::ceiling_date(lubridate::today(), 'week', week_start = 6, change_on_boundary = FALSE)))")
Rscript src/get_webtext.R --reference_date "$REF_DATE" --base_hub_path "."
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
message: "Update weekly data and web text"
default_author: github_actions
push: true
new_branch: add-viz-data

- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
message: "add web text"
default_author: github_actions
push: true

- name: Create pull request
run: |
gh pr create --base main --head add-viz-data --title "Weekly forecast visualization data" --body "This PR adds weekly visualization data files to the repo."
env:
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }}

- name: Create pull request
run: |
gh pr create --base main --head add-viz-data --title "Weekly forecast visualization data" --body "This PR adds weekly visualization data files to the repo."
env:
GH_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
4 changes: 3 additions & 1 deletion src/get_webtext.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ contributing_teams <- readr::read_csv(
reference_date, "-models-submitted-to-hub.csv"
)),
show_col_types = FALSE
)
) |>
dplyr::filter(Designated_Model)

weekly_submissions <- hubData::load_model_metadata(
hub_path,
model_ids = contributing_teams$Model
Expand Down
Loading

0 comments on commit 5b33b29

Please sign in to comment.