Skip to content

Commit 1a7747e

Browse files
committed
fix: tar_options needs to be in targets, not run.R
1 parent 173f1cc commit 1a7747e

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

extras/targets-common.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,23 @@ tar_option_set(
5050
)
5151
)
5252

53+
use_aws_s3 <- as.logical(Sys.getenv("USE_AWS_S3", FALSE))
54+
tar_project <- Sys.getenv("TAR_PROJECT", "covid_hosp_explore")
55+
aws_s3_prefix <- Sys.getenv("AWS_S3_PREFIX", "exploration")
56+
aws_s3_prefix <- paste0(aws_s3_prefix, "/", tar_project)
57+
if (use_aws_s3) {
58+
tar_option_set(
59+
repository = "aws",
60+
resources = tar_resources(
61+
aws = tar_resources_aws(
62+
bucket = "forecasting-team-data",
63+
prefix = aws_s3_prefix,
64+
region = "us-east-1"
65+
)
66+
)
67+
)
68+
}
69+
5370
linreg <- parsnip::linear_reg()
5471
quantreg <- epipredict::quantile_reg()
5572
ONE_AHEAD_FORECAST_NAME <- "forecast_by_ahead"

run.R

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ debug_mode <- as.logical(Sys.getenv("DEBUG_MODE", TRUE))
3232
use_shiny <- as.logical(Sys.getenv("USE_SHINY", FALSE))
3333
use_aws_s3 <- as.logical(Sys.getenv("USE_AWS_S3", FALSE))
3434
aws_s3_prefix <- Sys.getenv("AWS_S3_PREFIX", "exploration")
35+
aws_s3_prefix <- paste0(aws_s3_prefix, "/", tar_project)
3536
cli::cli_inform(
3637
c(
3738
"i" = "Reading environment variables...",
@@ -53,18 +54,6 @@ suppressPackageStartupMessages({
5354
store_dir <- tar_path_store()
5455
if (!dir.exists(store_dir)) dir.create(store_dir)
5556

56-
if (use_aws_s3) {
57-
tar_option_set(
58-
repository = "aws",
59-
resources = tar_resources(
60-
aws = tar_resources_aws(
61-
bucket = "forecasting-team-data",
62-
prefix = aws_s3_prefix,
63-
region = "us-east-1"
64-
)
65-
)
66-
)
67-
}
6857

6958
tar_manifest()
7059
if (debug_mode) {

0 commit comments

Comments
 (0)