lapply, passing through any intermediate remotes
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- r
- Ambito
- distributed-systems
Direzione di ricerca
Iniziate esaminando il future_lapply_backend proposto e il modo in cui delega a future.apply::future_lapply. Chiarite il comportamento desiderato per trasmettere piani remoti arbitrari e concordate un’API e i criteri di completamento prima di modificare il codice; l’issue non indica file del progetto né test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A common setup is to initiate a process on one server, pass it to the head node of a cluster, then parallelize on the cluster from the head node. future is a good tool for this scenario, but the code for this is a bit ... idiomatic:
plan(list(<some sort of remote setup>,<futurebatchtools>))
future_lapply(X=1L,function(x){
future_lapply(X=1L:10L, function(z){
#actually do the thing you want parallelized
}
})
The problem with the above setup is that if you start writing your code for a local multiprocess, then decide to switch to a cluster backend specified in the above plan (ie passing through a remote head), you need to go and wrap every call to future_lapply() with another future_lappy() call.
I've written some script which passes objects through an arbitrary number of remotes, if they exist, before actually doing a specified lapply.
this should (in theory) be a drop-in replacement for future_lapply:
future_lapply_backend <- function(X, FUN, ..., future.stdout = TRUE,
future.conditions = NULL, future.globals = FALSE,
future.packages = NULL, future.lazy = FALSE, future.seed = FALSE,
future.scheduling = 1.0, future.chunk.size = NULL,
future.label = "future_lapply-%d") {
current_plan <- setdiff(class(future::plan()), c("FutureStrategy", "tweaked",
"function"))[1]
call <- match.call()
arg_list <- as.list(call)[-1] #the first element is the function symbol
##we're just using match.call here to find the arguments which were actually specified.
#but we want to actually evaluate them rather than passing then unevaluated:
##evaulate all specified arguments
for(i in 1:length(arg_list)){
arg_list[[names(arg_list)[i] ]] <- get(names(arg_list)[[i]])
}
#"mypackage" contains future_lapply_backend, thus ensuring that it gets passed allowing recursion
if(!"mypackage" %in% arg_list[["future.packages"]]){
arg_list[["future.packages"]] <- c("mypackage",arg_list[["future.packages"]])
}
if(current_plan=="remote"){
#create a copy of the arglist. everything stays the same *except* X and FUN
#X becomes 1L just to signify that this only needs to be run once
#(as this level of the plan, being remote, is only pasing though)
#and FUN is just a recursive call to start over again
arg_list_pass <- arg_list
arg_list_pass[["X"]] <- 1L
arg_list_pass[["FUN"]] <- function(x) do.call(future_lapply_backend, args=arg_list)
out <- do.call(future.apply::future_lapply, args=arg_list_pass)
#return out[[1]] to drop the top-level of the list created by the future_lapply used to pass through remote
return(out[[1]])
}else{
out <- do.call(future.apply::future_lapply, args=arg_list)
return(out)
}
}
I've worked out most of the kinks but I wonder if there's a better approach to dealing with this?
- Lingua principale
- R
- Stelle
- 218
- Fork
- 20
- Merge medio
- 2g 9h
- PR unite (30g)
- 1
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di futureverse/future.apply
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
futureverse/future.apply#130 · 1 commento · 1 reazione ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
futureverse/future.apply#129 · 2 commenti ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 40/100
futureverse/future.apply#128 · 1 commento ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
futureverse/future.apply#112 · 3 commenti ·
-
feature request
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
futureverse/future.apply#111 · 2 commenti ·
Tutte le issue di futureverse/future.apply
Issue simili
-
Affects Web App documentation PRIORITY LOW
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
hubverse-org/hubCI#36 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
OHDSI/CohortSymmetry#351 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100