forked from eco4cast/neon4cast-ci
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from eco4cast/targets-to-bucket
Pushing targets to s3
- Loading branch information
Showing
3 changed files
with
51 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
#' helper function for pushing file to s3 | ||
#' | ||
#' @param config configuration file of the challenge | ||
#' @param local_file_name targets file name | ||
#' @param s3_file_name file to write to s3 #' | ||
push_to_s3 <- function( | ||
config, | ||
local_file_name, | ||
s3_file_name | ||
){ | ||
|
||
targets <- read_csv(local_file_name) | ||
# duration hard coded for now | ||
bucket_path <- glue::glue("{config$targets_bucket}/project_id={config$project_id}/duration=P1D") | ||
|
||
s3 <- arrow::s3_bucket(bucket_path, | ||
endpoint_override = config$endpoint, | ||
access_key = Sys.getenv("OSN_KEY"), | ||
secret_key = Sys.getenv("OSN_SECRET")) | ||
|
||
sink <- s3$path(s3_file_name) | ||
|
||
# write to s3 | ||
arrow::write_csv_arrow(x = targets, | ||
sink = sink) | ||
|
||
return(sink) | ||
} | ||
|