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

Issue 216: end-to-end CI #247

Merged
merged 33 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
bfe480b
add simple model for generating count data
SamuelBrand1 Dec 16, 2024
4a56fca
Merge branch 'main' into 149-generate-test-data-programmatically
SamuelBrand1 Dec 16, 2024
c84d4d4
pre-commit
SamuelBrand1 Dec 16, 2024
f5975eb
Create generate_test_data.R
SamuelBrand1 Dec 17, 2024
abfe8d3
state-level data
SamuelBrand1 Dec 17, 2024
3b07b51
Update generate_test_data.R
SamuelBrand1 Dec 17, 2024
b63013c
styler
SamuelBrand1 Dec 17, 2024
ba801d6
fake parameter data generation
SamuelBrand1 Dec 17, 2024
68562d1
populate test_output with priors
SamuelBrand1 Dec 17, 2024
6829591
Create test_forecast_state.sh
SamuelBrand1 Dec 17, 2024
a9a1c0e
Update generate_test_data.R
SamuelBrand1 Dec 17, 2024
6406e8c
catch different naming of disease
SamuelBrand1 Dec 17, 2024
22b6b46
catch script error
SamuelBrand1 Dec 17, 2024
b2cc518
generate latest comprehensive fake state data
SamuelBrand1 Dec 17, 2024
6657925
Update test_forecast_state.sh
SamuelBrand1 Dec 17, 2024
04f72f7
Merge branch 'main' into 149-generate-test-data-programmatically
SamuelBrand1 Dec 17, 2024
9fae922
reduce generated facs
SamuelBrand1 Dec 17, 2024
d0eaff0
reduce number of samples
SamuelBrand1 Dec 17, 2024
fcb6443
ignore test pipe output
SamuelBrand1 Dec 17, 2024
a07e87d
Update .gitignore
SamuelBrand1 Dec 17, 2024
fdc7ddb
modify to generate out-of-sample data
SamuelBrand1 Dec 17, 2024
10a092b
Merge branch 'main' into 149-generate-test-data-programmatically
SamuelBrand1 Dec 17, 2024
a2bea54
add explicit fails to pipeline run
SamuelBrand1 Dec 17, 2024
f62dd1d
style
SamuelBrand1 Dec 17, 2024
3f6ef3d
Add CI to run pipeline test mode
SamuelBrand1 Dec 17, 2024
6f98155
add install hewr step
SamuelBrand1 Dec 17, 2024
6a280fe
catch bad var
SamuelBrand1 Dec 17, 2024
db5abc4
catch no interactive
SamuelBrand1 Dec 17, 2024
e27308e
add epipredict and epiprocess
SamuelBrand1 Dec 17, 2024
63d061f
install quarto
damonbayer Dec 17, 2024
6abf678
Merge branch 'main' into 149-generate-test-data-programmatically
SamuelBrand1 Dec 17, 2024
b2810da
cleanup generate_test_data
damonbayer Dec 17, 2024
8314ba1
pre-commit
damonbayer Dec 17, 2024
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
39 changes: 39 additions & 0 deletions .github/workflows/pipeline-run-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Pipeline Run Check

on:
pull_request:
push:
branches: [main]

jobs:
run-pipeline:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: "Set up R"
uses: r-lib/actions/setup-r@v2
with:
r-version: "release"
use-public-rspm: true
- name: "Install poetry"
run: pip install poetry
- name: "Install pyrenew-hew"
run: poetry install
- name: "Set up Quarto"
uses: quarto-dev/quarto-actions/setup@v2
- name: "Set up dependencies for hewr"
uses: r-lib/actions/setup-r-dependencies@v2
with:
working-directory: hewr
- name: "Install extra pkgs"
run: |
pak::local_install("hewr", ask = FALSE)
pak::pkg_install("cmu-delphi/epipredict@main", ask = FALSE)
pak::pkg_install("cmu-delphi/epiprocess@main", ask = FALSE)
shell: Rscript {0}
- name: "Run pipeline"
run: poetry run bash pipelines/tests/test_forecast_state.sh pipelines/tests
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -403,3 +403,6 @@ private_data/*
# Test data exceptions to the general data exclusion
!pipelines/tests/covid-19_r_2024-01-29_f_2023-11-01_t_2024-01-29/model_runs/TD/data/data.tsv
!pipelines/tests/covid-19_r_2024-01-29_f_2023-11-01_t_2024-01-29/model_runs/TD/data/eval_data.tsv

# Ignore test pipe output
pipelines/tests/private_data/*
1 change: 1 addition & 0 deletions hewr/NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(combine_training_and_eval_data)
export(generate_exp_growth_pois)
export(get_all_model_batch_dirs)
export(make_forecast_figure)
export(parse_model_batch_dir_path)
Expand Down
26 changes: 26 additions & 0 deletions hewr/R/generate_exp_growth_process.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#' Generate Exponential Growth Process with Poisson Noise
#'
#' This function generates a sequence of samples from an exponential growth
#' process through Poisson sampling:
#' ```math
#' \begin{aligned}
#' \( \lambda_t &= I_0 \exp(\sum_{t=1}^{t} r_t) \) \\
#' I_t &\sim \text{Poisson}(\lambda_t).
#' ```
#' @param rt A numeric vector of exponential growth rates.
#' @param initial A numeric value representing the initial value of the process.
#'
#' @return An integer vector of Poisson samples generated from the exponential
#' growth process.
#'
#' @examples
#' rt <- c(0.1, 0.2, 0.15)
#' initial <- 10
#' generate_exp_growth_pois(rt, initial)
#'
#' @export
generate_exp_growth_pois <- function(rt, initial) {
means <- initial * exp(cumsum(rt))
samples <- stats::rpois(length(means), lambda = means)
return(samples)
}
32 changes: 32 additions & 0 deletions hewr/man/generate_exp_growth_pois.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions hewr/tests/testthat/test_generate_exp_growth_process.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
test_that("generate_exp_growth_pois generates correct number of samples", {
rt <- c(0.1, 0.2, 0.15)
initial <- 10
samples <- generate_exp_growth_pois(rt, initial)
expect_length(samples, length(rt))
})

test_that("generate_exp_growth_pois returns a vector of integers", {
rt <- c(0.1, 0.2, 0.15)
initial <- 10
samples <- generate_exp_growth_pois(rt, initial)
expect_type(samples, "integer")
})

test_that("generate_exp_growth_pois does not return implausible values", {
rt <- c(0.1, 0.2, 0.15)
initial <- 10
analytic_av <- initial * exp(cumsum(rt))
analytic_std <- sqrt(analytic_av)
samples <- generate_exp_growth_pois(rt, initial)
expect_true(all(samples <= initial + 10 * analytic_std))
expect_true(all(samples >= initial - 10 * analytic_std))
})

test_that("generate_exp_growth_pois handles empty growth rates", {
rt <- numeric(0)
initial <- 10
samples <- generate_exp_growth_pois(rt, initial)
expect_equal(samples, numeric(0))
})
Loading
Loading