R/run_create_process_i.R

Defines functions run_create_process_i

Documented in run_create_process_i

#' run_create_process_i
#'
#' @param i TODO
#' @param args TODO
#' @param parent_dir TODO
#' @param seed TODO
#' @param output_full_run_env TODO
#'
#' @return List
#' @export
run_create_process_i <- function(i, args,  parent_dir,  seed, output_full_run_env){

  child_name <- paste0("child_",i)
  child_path <- file.path(parent_dir,child_name)
  if(dir.exists(child_path)==F){
    dir.create(child_path, recursive=T)
  }



  process_path  <- file.path(child_path,"process.R")
  args_path     <- file.path(child_path,"args.rds")
  output_path     <- file.path(child_path,"output.rds")
  saveRDS(args, file=args_path )

  cat(sprintf("
set.seed(%d)
parent_dir       <- \"%s\";
code_path        <- file.path(parent_dir,\"code.R\");
args_path        <- file.path(parent_dir, \"%s\",\"args.rds\");
parent_env_path  <- file.path(parent_dir,\"run_env.rds\");
save_path        <- file.path(parent_dir, \"%s\",\"output.rds\");
output_full_run_env   <- %s
jobsR::run_worker(code_path=code_path, args_path, parent_env_path, save_path, output_full_run_env);" ,
              seed,parent_dir, child_name,child_name, as.character(output_full_run_env)), file = process_path)

  return(list(process_path=process_path,output_path=output_path))

}
trevorlolsen/jobsR documentation built on Dec. 23, 2021, 12:56 p.m.