Skip to content

Commit 150d876

Browse files
authored
Merge pull request #112 from cmu-delphi/ds/epiprocess
testing: ab testing branch for epiprocess r6 refactor
2 parents 14d99f1 + 7f59e94 commit 150d876

File tree

6 files changed

+88
-32
lines changed

6 files changed

+88
-32
lines changed

R/looping.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ slide_forecaster <- function(data,
108108
names(res) <- sub("^slide_value_", "", names(res))
109109

110110
# append the truth data
111-
true_value <- archive$as_of(archive$versions_end) %>%
111+
true_value <- archive %>%
112+
epiprocess::epix_as_of(archive$versions_end) %>%
112113
select(geo_value, time_value, !!outcome) %>%
113114
rename(true_value = !!outcome)
114115
res %<>%

R/manage_S3.R

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ manage_S3_forecast_cache <- function(rel_cache_dir = NULL,
2828

2929
project_prefix <- paste0(prefix, "/", tar_project, "/")
3030
s3b <- get_bucket(bucket_name, prefix = project_prefix)
31-
print(paste0(direction, "ing:"))
32-
print(paste("local:", cache_path))
33-
print(paste("remote:", prefix))
31+
cli::cli_inform(c(
32+
"{direction}ing cache to S3 bucket '{bucket_name}'",
33+
"i" = "Local cache path: {cache_path}",
34+
"i" = "AWS prefix: {prefix}"
35+
))
3436
if (direction == "sync") {
3537
if (verbose) {
3638
s3sync(cache_path, s3b, prefix = project_prefix)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ make push
5252

5353
### Directory Layout
5454

55-
- `Makefile`: the main entrypoint for all pipelines
55+
- `run.R` and `Makefile`: the main entrypoint for all pipelines
5656
- `R/`: R package code to be reused
5757
- `scripts/`: plotting, code, and misc.
5858
- `tests/`: package tests

renv.lock

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -812,14 +812,15 @@
812812
},
813813
"epidatr": {
814814
"Package": "epidatr",
815-
"Version": "1.1.4",
815+
"Version": "1.1.5",
816816
"Source": "GitHub",
817817
"RemoteType": "github",
818818
"RemoteHost": "api.github.com",
819-
"RemoteUsername": "cmu-delphi",
820819
"RemoteRepo": "epidatr",
821-
"RemoteRef": "dev",
822-
"RemoteSha": "a53ad5671cc072518feaed605637d0bf27fde3e6",
820+
"RemoteUsername": "cmu-delphi",
821+
"RemotePkgRef": "cmu-delphi/epidatr",
822+
"RemoteRef": "HEAD",
823+
"RemoteSha": "626c30bc07f4aae3c3e6a6c6b825a6cd5eee1ce7",
823824
"Requirements": [
824825
"MMWRweek",
825826
"R",
@@ -838,33 +839,32 @@
838839
"usethis",
839840
"xml2"
840841
],
841-
"Hash": "c495a916c7f3aba065e09fcaceca4b01"
842+
"Hash": "5c76408a283a0b20c6fd455fcd1c44b6"
842843
},
843844
"epipredict": {
844845
"Package": "epipredict",
845-
"Version": "0.0.10",
846+
"Version": "0.0.13",
846847
"Source": "GitHub",
848+
"Remotes": "cmu-delphi/epidatr, cmu-delphi/epiprocess, dajmcdon/smoothqr",
847849
"RemoteType": "github",
848-
"RemoteUsername": "cmu-delphi",
850+
"RemoteHost": "api.github.com",
849851
"RemoteRepo": "epipredict",
852+
"RemoteUsername": "cmu-delphi",
853+
"RemotePkgRef": "cmu-delphi/epipredict",
850854
"RemoteRef": "HEAD",
851-
"RemoteSha": "7a4ea55437f6415e86b34d0fb7079ba7e8d5e286",
852-
"RemoteHost": "api.github.com",
853-
"Remotes": "cmu-delphi/epidatr, cmu-delphi/epiprocess, dajmcdon/smoothqr",
855+
"RemoteSha": "8a516e96bbd0d647291700c32da9d4c5182e9f13",
854856
"Requirements": [
855857
"R",
856858
"checkmate",
857859
"cli",
858860
"distributional",
859861
"dplyr",
860862
"epiprocess",
861-
"fs",
862863
"generics",
864+
"ggplot2",
863865
"glue",
864866
"hardhat",
865-
"lifecycle",
866867
"magrittr",
867-
"methods",
868868
"parsnip",
869869
"quantreg",
870870
"recipes",
@@ -874,26 +874,25 @@
874874
"tibble",
875875
"tidyr",
876876
"tidyselect",
877-
"usethis",
877+
"tsibble",
878878
"vctrs",
879879
"workflows"
880880
],
881-
"Hash": "d59cd87c1aef1bfb1afce0bbf9b7c9c5"
881+
"Hash": "c8f4f260388bc61e562f599c00c73fa6"
882882
},
883883
"epiprocess": {
884884
"Package": "epiprocess",
885-
"Version": "0.7.5",
885+
"Version": "0.7.7",
886886
"Source": "GitHub",
887887
"RemoteType": "github",
888+
"RemoteHost": "api.github.com",
888889
"RemoteUsername": "cmu-delphi",
889890
"RemoteRepo": "epiprocess",
890-
"RemoteRef": "HEAD",
891-
"RemoteSha": "f29654512c4784c5a622b76b0ad13c0b43004d48",
892-
"RemoteHost": "api.github.com",
891+
"RemoteRef": "ds/r6-clean",
892+
"RemoteSha": "d5c89b7e6bcf27d76aeb58c13c1bf9a528f92a3b",
893893
"Remotes": "cmu-delphi/epidatr, reconverse/outbreaks, glmgen/genlasso",
894894
"Requirements": [
895895
"R",
896-
"R6",
897896
"checkmate",
898897
"cli",
899898
"data.table",
@@ -916,7 +915,7 @@
916915
"utils",
917916
"vctrs"
918917
],
919-
"Hash": "d408b669e3b55d445b76272049fdb07e"
918+
"Hash": "a6d480168d4ada8865470ca9912187a5"
920919
},
921920
"evaluate": {
922921
"Package": "evaluate",
@@ -1154,7 +1153,7 @@
11541153
},
11551154
"ggplot2": {
11561155
"Package": "ggplot2",
1157-
"Version": "3.5.0",
1156+
"Version": "3.5.1",
11581157
"Source": "Repository",
11591158
"Repository": "RSPM",
11601159
"Requirements": [
@@ -1175,7 +1174,7 @@
11751174
"vctrs",
11761175
"withr"
11771176
],
1178-
"Hash": "52ef83f93f74833007f193b2d4c159a2"
1177+
"Hash": "44c6a2f8202d5b7e878ea274b1092426"
11791178
},
11801179
"gh": {
11811180
"Package": "gh",

scripts/one_offs/r6_refactor.R

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# R6 refactor comparison script.
2+
#
3+
# This script is used to compare the old and new R6 refactor objects to ensure
4+
# that the refactor did not change the forecast output. This script assumes that
5+
# you:
6+
#
7+
# 1. Ran the covid_hosp_explore pipeline (or downloaded the objects using `make
8+
# download`)
9+
# 2. Copied the cache objects to a new directory (e.g. `covid_hosp_explore
10+
# copy`)
11+
# 3. Installed the new epiprocess branch
12+
# `renv::install("cmu-delphi/epiprocess@ds/r6-clean")`
13+
# 4. Ran the covid_hosp_explore pipeline again (should take about 3.5 hours)
14+
#
15+
# Once that is done, you should be able to run the script below and find no
16+
# differences in the forecasts.
17+
18+
library(dplyr)
19+
library(magrittr)
20+
library(purrr)
21+
library(qs)
22+
23+
df <- targets::tar_manifest()
24+
25+
# Both have already been produced, so we can just read them in. Let's do a loop to compare them.
26+
old_forecasts <- list.files("covid_hosp_explore copy/objects", full.names = TRUE) %>%
27+
keep(~ basename(.) %in% df$name) %>%
28+
sort()
29+
new_forecasts <- list.files("covid_hosp_explore/objects", full.names = TRUE) %>%
30+
keep(~ basename(.) %in% df$name) %>%
31+
sort()
32+
33+
# Make sure the lists are the same length and the basenames match
34+
assertthat::assert_that(
35+
c(
36+
length(old_forecasts) == length(new_forecasts),
37+
basename(old_forecasts) == basename(new_forecasts)
38+
) %>% all()
39+
)
40+
41+
tib <- tibble::tibble(
42+
old_forecasts = old_forecasts,
43+
new_forecasts = new_forecasts,
44+
compare = purrr::map2_chr(old_forecasts, new_forecasts, function(x, y) {
45+
# If objects are not the same, `all.equal` returns a character vector that
46+
# can have `length` > 1. In that case, we need to collapse the output
47+
# into a length-1 string so that `purrr::map2_chr` accepts it.
48+
all.equal(qs::qread(x), qs::qread(y)) %>% as.character() %>% paste(collapse = "; ")
49+
})
50+
)
51+
tib %>%
52+
filter(compare != "TRUE") %>%
53+
slice(1:5) %>%
54+
c()
55+
56+
x <- qread("covid_hosp_explore copy/objects/joined_archive_data_2022")
57+
y <- qread("covid_hosp_explore/objects/joined_archive_data_2022")

scripts/run.R

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
# # Save to disk
2727
# saveRDS(scorecards, "exploration-scorecards-2023-10-04.RDS")
2828

29-
30-
31-
3229
tar_project <- Sys.getenv("TAR_PROJECT", "covid_hosp_explore")
3330
external_scores_path <- Sys.getenv("EXTERNAL_SCORES_PATH", "")
3431
debug_mode <- as.logical(Sys.getenv("DEBUG_MODE", TRUE))
@@ -64,7 +61,7 @@ tar_manifest()
6461
if (debug_mode) {
6562
tar_make(callr_function = NULL, use_crew = FALSE)
6663
} else {
67-
tar_make(use_crew = TRUE)
64+
tar_make()
6865
}
6966

7067
if (use_shiny) {

0 commit comments

Comments
 (0)