Skip to content

Commit

Permalink
explicitly export to global
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Feb 6, 2025
1 parent 5190306 commit 93630b0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion R/SimSolve.R
Original file line number Diff line number Diff line change
Expand Up @@ -605,14 +605,15 @@ SimSolve <- function(design, interval, b, generate, analyse, summarise,
on.exit(parallel::stopCluster(cl), add = TRUE)
}
}
browser()
export_funs <- parent_env_fun(control$global_fun_level)
if(parallel){
if(!useFuture && is.null(cl)){
cl <- parallel::makeCluster(ncores, type=type)
on.exit(parallel::stopCluster(cl), add = TRUE)
}
if(!useFuture){
parallel::clusterExport(cl=cl, export_funs, envir = parent.frame(1L))
parallel::clusterExport(cl=cl, export_funs)
parallel::clusterExport(cl=cl, "ANALYSE_FUNCTIONS", envir = environment())
if(verbose > 0 && verbose < 2)
message(sprintf("\nNumber of parallel clusters in use: %i", length(cl)))
Expand Down
4 changes: 2 additions & 2 deletions R/runSimulation.R
Original file line number Diff line number Diff line change
Expand Up @@ -1295,10 +1295,10 @@ runSimulation <- function(design, replications, generate, analyse, summarise,
on.exit(parallel::stopCluster(cl), add = TRUE)
}
if(!useFuture){
parallel::clusterExport(cl=cl, export_funs, envir = parent.frame(1L))
parallel::clusterExport(cl=cl, export_funs)
parallel::clusterExport(cl=cl, "ANALYSE_FUNCTIONS", envir = environment())
parallel::clusterExport(cl=cl, "TRY_ALL_ANALYSE", envir = environment())
if(verbose)
if(verbose > 0 && verbose < 2)
message(sprintf("\nNumber of parallel clusters in use: %i", length(cl)))
}
}
Expand Down

0 comments on commit 93630b0

Please sign in to comment.