Skip to content

Commit 749cfb0

Browse files
committed
add make dashboard, drop use_aws... envvir
1 parent 6561a91 commit 749cfb0

File tree

5 files changed

+62
-51
lines changed

5 files changed

+62
-51
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ run-nohup:
1010

1111
sync:
1212
Rscript sync.R
13+
14+
dashboard:
15+
Rscript dashboard.R

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ AWS_S3_PREFIX=2023/exploration
2121
# Pull from the bucket
2222
make sync
2323

24+
# Run only the dashboard, to display results run on other machines
25+
make dashboard
26+
2427
# Run the pipeline wrapper run.R.
2528
make run
29+
2630
```
2731

2832
- `EPIDATR_USE_CACHE` controls whether `epidatr` functions use the cache.

dashboard.R

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
tar_project <- Sys.getenv("TAR_PROJECT", "covid_hosp_explore")
2+
external_scores_path <- Sys.getenv("EXTERNAL_SCORES_PATH", "")
3+
debug_mode <- as.logical(Sys.getenv("DEBUG_MODE", TRUE))
4+
use_shiny <- as.logical(Sys.getenv("USE_SHINY", FALSE))
5+
use_aws_s3_only <- as.logical(Sys.getenv("USE_AWS_S3_ONLY", FALSE))
6+
aws_s3_prefix <- Sys.getenv("AWS_S3_PREFIX", "exploration")
7+
aws_s3_prefix <- paste0(aws_s3_prefix, "/", tar_project)
8+
suppressPackageStartupMessages({
9+
library(targets)
10+
library(shiny)
11+
})
12+
# Prevent functions defined in /R dir from being loaded unnecessarily
13+
options(shiny.autoload.r = FALSE)
14+
15+
forecaster_options <- unique(tar_read(forecaster_params_grid)[["parent_id"]])
16+
# Map forecaster names to score files
17+
forecaster_options <- setNames(
18+
# File names
19+
paste0("score_", gsub(" ", ".", forecaster_options)),
20+
# Display names
21+
forecaster_options
22+
)
23+
24+
# Add ensembles
25+
ensemble_options <- unique(tar_read(ensemble_forecasters)[["parent_id"]])
26+
ensemble_options <- setNames(
27+
# File names
28+
paste0("ensemble_score_", ensemble_options),
29+
# Display names
30+
paste0("ensemble.", ensemble_options)
31+
)
32+
33+
external_options <- unique(tar_read(external_names))
34+
EXTERNAL_PREFIX <- "[external] "
35+
if (!is.null(external_options) && length(external_options) > 0) {
36+
external_options <- setNames(
37+
# File names
38+
# Get names of all branches of `external_scores` target by index. The way these
39+
# were specified, `external_names` provides the order of the branches.
40+
tar_branch_names(external_scores, seq_along(external_options)),
41+
# Display names
42+
paste0(
43+
EXTERNAL_PREFIX,
44+
gsub(" forecaster", "", gsub("_", " ", external_options, fixed = TRUE), fixed = TRUE)
45+
)
46+
)
47+
} else {
48+
external_options <- character(0)
49+
}
50+
51+
forecaster_options <- c(ensemble_options, forecaster_options, external_options)
52+
53+
runApp(here::here("app.R"), port = 3838)

run.R

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ tar_project <- Sys.getenv("TAR_PROJECT", "covid_hosp_explore")
3333
external_scores_path <- Sys.getenv("EXTERNAL_SCORES_PATH", "")
3434
debug_mode <- as.logical(Sys.getenv("DEBUG_MODE", TRUE))
3535
use_shiny <- as.logical(Sys.getenv("USE_SHINY", FALSE))
36-
use_aws_s3 <- as.logical(Sys.getenv("USE_AWS_S3", FALSE))
3736
aws_s3_prefix <- Sys.getenv("AWS_S3_PREFIX", "exploration")
3837
aws_s3_prefix <- paste0(aws_s3_prefix, "/", tar_project)
3938
cli::cli_inform(
@@ -65,50 +64,7 @@ if (debug_mode) {
6564
} else {
6665
tar_make()
6766
}
68-
# tar_make_clustermq(workers = 2) # nolint
69-
# tar_make_future(workers = 2) # nolint
7067

7168
if (use_shiny) {
72-
# Prevent functions defined in /R dir from being loaded unnecessarily
73-
options(shiny.autoload.r = FALSE)
74-
75-
forecaster_options <- unique(tar_read(forecaster_params_grid)[["parent_id"]])
76-
# Map forecaster names to score files
77-
forecaster_options <- setNames(
78-
# File names
79-
paste0("score_", gsub(" ", ".", forecaster_options)),
80-
# Display names
81-
forecaster_options
82-
)
83-
84-
# Add ensembles
85-
ensemble_options <- unique(tar_read(ensemble_forecasters)[["parent_id"]])
86-
ensemble_options <- setNames(
87-
# File names
88-
paste0("ensemble_score_", ensemble_options),
89-
# Display names
90-
paste0("ensemble.", ensemble_options)
91-
)
92-
93-
external_options <- unique(tar_read(external_names))
94-
EXTERNAL_PREFIX <- "[external] "
95-
if (!is.null(external_options) && length(external_options) > 0) {
96-
external_options <- setNames(
97-
# File names
98-
# Get names of all branches of `external_scores` target by index. The way these
99-
# were specified, `external_names` provides the order of the branches.
100-
tar_branch_names(external_scores, seq_along(external_options)),
101-
# Display names
102-
paste0(
103-
EXTERNAL_PREFIX,
104-
gsub(" forecaster", "", gsub("_", " ", external_options, fixed = TRUE), fixed = TRUE)
105-
)
106-
)
107-
} else {
108-
external_options <- character(0)
109-
}
110-
111-
forecaster_options <- c(ensemble_options, forecaster_options, external_options)
112-
113-
runApp(here::here("app.R"), port = 3838)
69+
source("dashboard.R")
11470
}

sync.R

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
library(targets)
22
library(shiny)
3-
use_aws_s3 <- as.logical(Sys.getenv("USE_AWS_S3", FALSE))
4-
if (use_aws_s3) {
5-
epieval::manage_S3_forecast_cache()
6-
} else {
7-
cli::cli_inform("Syncing turned off")
8-
}
3+
epieval::manage_S3_forecast_cache()

0 commit comments

Comments
 (0)