Skip to content

Commit

Permalink
upload straight to bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyclements committed Apr 2, 2024
1 parent b02d42f commit f25fb14
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
10 changes: 2 additions & 8 deletions R/export_r_instat_to_bucket.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#' @param year The year data.
#' @param month The month data.
#' @param summaries A character vector specifying the types of summaries to include.
#' @param file_path The path to the directory where the JSON file will be saved locally.
#' @param file_name The name of the JSON file (without the ".json" extension).
#' @param country `character(1)` The country code of the data.
#' @param station_id `character` The id's of the stations to analyze. Either a
#' single value or a vector.
Expand All @@ -38,7 +36,6 @@
export_r_instat_to_bucket <- function(data, data_by_year, data_by_year_month = NULL, crop_data_name = NULL,
rain = NULL, tmin = NULL, tmax = NULL, year = NULL, month = NULL,
summaries = c("annual_rainfall", "annual_temperature", "monthly_temperature", "extremes", "crop_success", "start_season"),
file_path, file_name,
station_id, country,
include_summary_data = FALSE,
annual_rainfall_data = NULL, annual_temperature_data = NULL, monthly_temperature_data = NULL,
Expand All @@ -47,11 +44,8 @@ export_r_instat_to_bucket <- function(data, data_by_year, data_by_year_month = N
timestamp <- format(Sys.time(), format = "%Y%m%d%H%M%S")

definitions_data <- epicsadata::collate_definitions_data(data = data, data_by_year = data_by_year, data_by_year_month = data_by_year_month, crop_data = crop_data, rain = rain, tmin = tmin, tmax = tmax, year = year, month = month, summaries = summaries)
# Save onto computer
jsonlite::write_json(definitions_data, path = paste0(file_path, file_name, ".json"), auto_unbox = TRUE, pretty = TRUE)

# Read from computer to bucket
add_definitions_to_bucket(country = country, station_id = station_id, new_definitions = paste0(file_path, file_name), timestamp = timestamp)
# Save into bucket
add_definitions_to_bucket(country = country, station_id = station_id, new_definitions = definitions_data, timestamp = timestamp)

Check warning on line 48 in R/export_r_instat_to_bucket.R

View check run for this annotation

Codecov / codecov/patch

R/export_r_instat_to_bucket.R#L48

Added line #L48 was not covered by tests

if (include_summary_data){
# function to read summary data from R-Instat into summaries in buckets
Expand Down
6 changes: 0 additions & 6 deletions man/export_r_instat_to_bucket.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f25fb14

Please sign in to comment.