Skip to content

Commit

Permalink
Merge pull request #15 from addelany/main
Browse files Browse the repository at this point in the history
update keywords and model asset items
  • Loading branch information
addelany authored Nov 7, 2023
2 parents 773dd18 + a96ff03 commit d0a87f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
8 changes: 5 additions & 3 deletions R/build_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ build_model <- function(model_id,
collection_name,
thumbnail_image_name,
table_schema,
table_description) {
table_description,
full_var_df) {


preset_keywords <- list("Forecasting", config$project_id)
variables_reformat <- paste(var_values, collapse = ", ")
#variables_reformat <- paste(var_values, collapse = ", ")
variables_reformat <- as.list(var_values)
site_reformat <- paste(site_values, collapse = ", ")

aws_asset_link <- paste0("s3://anonymous@",
Expand Down Expand Up @@ -116,7 +118,7 @@ build_model <- function(model_id,
"type"= "application/json",
"title"= "Model Forecast"
)),
"assets"= stac4cast::generate_model_assets(var_values, duration_names, aws_download_path)#,
"assets"= stac4cast::generate_model_assets(full_var_df, aws_download_path)#,
#pull_images(theme_id,model_id,thumbnail_image_name)
)

Expand Down
13 changes: 6 additions & 7 deletions R/generate_model_assets.R
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#' Build the Assets objects for model JSONS
#'
#' @param m_vars list of unique model variables
#' @param m_duration list of unique model duration periods
#' @param full_var_df dataframe that contains variable column information (name, full name, duration, duration name)
#' @param aws_path s3 path for accessing model data
#' @export
#'
#'
generate_model_assets <- function(m_vars, m_duration, aws_path){
generate_model_assets <- function(full_var_df, aws_path){

metadata_json_asset <- list(
"1"= list(
Expand All @@ -18,20 +17,20 @@ generate_model_assets <- function(m_vars, m_duration, aws_path){
)
)

iterator_list <- 1:length(m_vars)
iterator_list <- 1:nrow(full_var_df)

model_data_assets <- purrr::map(iterator_list, function(i)
list(
'type'= 'application/x-parquet',
'title' = paste0('Database Access for',' ',m_vars[i]),
'title' = paste0('Database Access for',' ', full_var_df$var_duration_name[i]),
'href' = paste0("s3://anonymous@",
aws_path,
"/parquet/duration=P1D/variable=", m_vars[i],
"/parquet/duration=", full_var_df$duration[i],"/variable=", full_var_df$variable[i],
"/model_id=", m,
"?endpoint_override=",config$endpoint),
'description' = paste0("Use `arrow` for remote access to the database. This R code will return results for this variable and model combination.\n\n### R\n\n```{r}\n# Use code below\n\nall_results <- arrow::open_dataset(",paste0("s3://anonymous@",
aws_path,
"/parquet/duration=P1D/variable=", m_vars[i],
"/parquet/duration=", full_var_df$duration[i],"/variable=", full_var_df$variable[i],
"/model_id=", m,
"?endpoint_override=",config$endpoint),")\ndf <- all_results |> dplyr::collect()\n\n```
\n\nYou can use dplyr operations before calling `dplyr::collect()` to `summarise`, `select` columns, and/or `filter` rows prior to pulling the data into a local `data.frame`. Reducing the data that is pulled locally will speed up the data download speed and reduce your memory usage.\n\n\n")
Expand Down

0 comments on commit d0a87f2

Please sign in to comment.