26
26
# saveRDS(scorecards, "exploration-scorecards-2023-10-04.RDS")
27
27
28
28
print(" Reading environment variables (TAR_PROJECT, EXTERNAL_SCORES_PATH, DEBUG_MODE, USE_SHINY)..." )
29
- tar_project <- Sys.getenv(" TAR_PROJECT" , " " )
29
+ tar_project <- Sys.getenv(" TAR_PROJECT" , " covid_hosp_explore " )
30
30
external_scores_path <- Sys.getenv(" EXTERNAL_SCORES_PATH" , " " )
31
- debug_mode <- Sys.getenv(" DEBUG_MODE" , " " )
32
- use_shiny <- Sys.getenv(" USE_SHINY" , " " )
31
+ debug_mode <- as.logical( Sys.getenv(" DEBUG_MODE" , TRUE ) )
32
+ use_shiny <- as.logical( Sys.getenv(" USE_SHINY" , FALSE ) )
33
33
34
- readline_wrapper <- function (msg ) {
35
- if (interactive()) {
36
- txt <- readline(msg )
37
- } else {
38
- cat(msg )
39
- txt <- readLines(" stdin" , n = 1 )
40
- }
41
- return (txt )
42
- }
43
- if (tar_project == " " ) {
44
- project_selection <- readline_wrapper(" Which project would you like to run?
45
- 1: covid_hosp_explore
46
- 2: flu_hosp_explore
47
- 3: covid_hosp_prod
48
- 4: flu_hosp_prod
49
- Input: " )
50
- tar_project <- switch (as.character(project_selection ),
51
- " 1" = " covid_hosp_explore" ,
52
- " 2" = " flu_hosp_explore" ,
53
- " 3" = " covid_hosp_prod" ,
54
- " 4" = " flu_hosp_prod" ,
55
- # else
56
- stop(" selection `" , project_selection , " ` is invalid" )
57
- )
58
- } else {
59
- cat(" Using project: " , tar_project , " \n " )
60
- }
61
- Sys.setenv(TAR_PROJECT = tar_project )
62
-
63
-
64
- if (external_scores_path == " " ) {
65
- external_scores_path <- readline_wrapper(" Path to RDS file containing external forecast scores, if desired:" )
66
- } else {
67
- cat(" Using external scores from " , external_scores_path , " \n " )
68
- }
69
- Sys.setenv(EXTERNAL_SCORES_PATH = external_scores_path )
70
-
71
- if (debug_mode == " " ) {
72
- debug_mode <- readline_wrapper(" Would you like to run debug mode? (y/[N]): " )
73
- } else {
74
- cat(" Debug mode: " , debug_mode , " \n " )
75
- if (as.logical(debug_mode )) {
76
- debug_mode <- " y"
77
- }
78
- }
79
-
80
- if (use_shiny == " " ) {
81
- use_shiny <- readline_wrapper(" Would you like to run the shiny app? (y/[N]): " )
82
- } else {
83
- cat(" Use shiny: " , use_shiny , " \n " )
84
- if (as.logical(use_shiny )) {
85
- use_shiny <- " y"
86
- }
87
- }
34
+ cat(" Using project: " , tar_project , " \n " )
35
+ if (external_scores_path != " " ) cat(" Using external scores from " , external_scores_path , " \n " )
36
+ if (debug_mode ) cat(" Debug mode is on." )
37
+ if (use_shiny ) cat(" Running shiny server after results." )
88
38
89
39
90
40
suppressPackageStartupMessages({
@@ -97,15 +47,15 @@ store_dir <- tar_path_store()
97
47
if (! dir.exists(store_dir )) dir.create(store_dir )
98
48
99
49
tar_manifest()
100
- if (debug_mode == " y " ) {
50
+ if (debug_mode ) {
101
51
tar_make(callr_function = NULL )
102
52
} else {
103
53
tar_make()
104
54
}
105
55
# tar_make_clustermq(workers = 2) # nolint
106
56
# tar_make_future(workers = 2) # nolint
107
57
108
- if (use_shiny == " y " ) {
58
+ if (use_shiny ) {
109
59
# Prevent functions defined in /R dir from being loaded unnecessarily
110
60
options(shiny.autoload.r = FALSE )
111
61
0 commit comments