`future` unable to export libraries of list encapsulated functions

Aperta
#741 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
r

Direzione di ricerca

Esegui il riproduttore R fornito con plan(multisession, workers = 2), concentrandoti su future::future(wrapper(1)) e sulla funzione contenuta nella lista. Traccia il modo in cui future rileva i globals e i pacchetti per questa chiamata annidata; il lavoro è completato quando l'esempio risolve lubridate's days() senza l'errore di funzione mancante.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug

Describe the bug

If a function is wrapped in a list then future seems to be unable to detect the libraries used by that function:

library(lubridate)
library(future)
my_a_fun <- function(x) {
    zz <- days(3)
    x
}
callme <- function(fun) {
    obj <- list(funny = fun)
    wrapper <- function(x) {
        obj$funny(x)
    }
    future::future(wrapper(1))
}

plan(multisession, workers = 2)
value(callme(my_a_fun))

Error in days(3) : could not find function "days"

Expected behavior

That it would be able to recognise that the lubridate library is required

Session information

Please share your session information after the error has occurred so that we also see which packages and versions are involved;

> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: x86_64-apple-darwin23.4.0
Running under: macOS Sonoma 14.6.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /usr/local/Cellar/r/4.4.1/lib/R/lib/libRlapack.dylib;  LAPACK version 3.12.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: Europe/London
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] lubridate_1.9.3 future_1.34.0  

loaded via a namespace (and not attached):
 [1] compiler_4.4.1    parallelly_1.38.0 generics_0.1.3    parallel_4.4.1    tools_4.4.1       rstudioapi_0.16.0 listenv_0.9.1     codetools_0.2-20 
 [9] digest_0.6.37     globals_0.16.3    timechange_0.3.0



> future::futureSessionInfo()
*** Package versions
future 1.34.0, parallelly 1.38.0, parallel 4.4.1, globals 0.16.3, listenv 0.9.1

*** Allocations
availableCores():
system 
    12 
availableWorkers():
$system
 [1] "localhost" "localhost" "localhost" "localhost" "localhost" "localhost" "localhost" "localhost" "localhost" "localhost" "localhost" "localhost"


*** Settings
- future.plan=<not set>
- future.fork.multithreading.enable=<not set>
- future.globals.maxSize=<not set>
- future.globals.onReference=<not set>
- future.resolve.recursive=<not set>
- future.rng.onMisuse=<not set>
- future.wait.timeout=<not set>
- future.wait.interval=<not set>
- future.wait.alpha=<not set>
- future.startup.script=<not set>

*** Backends
Number of workers: 2
List of future strategies:
1. multisession:
   - args: function (..., workers = 2, envir = parent.frame())
   - tweaked: TRUE
   - call: plan(multisession, workers = 2)

*** Basic tests
Main R session details:
    pid     r sysname release                                                                                           version nodename machine
1 65511 4.4.1  Darwin  23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64  host001  x86_64
    login    user effective_user
1 user001 user001        user001
Worker R session details:
  worker   pid     r sysname release                                                                                           version nodename
1      1 65631 4.4.1  Darwin  23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64  host001
2      2 65632 4.4.1  Darwin  23.6.0 Darwin Kernel Version 23.6.0: Mon Jul 29 21:13:00 PDT 2024; root:xnu-10063.141.2~1/RELEASE_X86_64  host001
  machine   login    user effective_user
1  x86_64 user001 user001        user001
2  x86_64 user001 user001        user001
Number of unique worker PIDs: 2 (as expected)
Lingua principale
R
Stelle
1k
Fork
93
Merge medio
2g 4h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di futureverse/future

Tutte le issue di futureverse/future

Issue simili

Altre issue su R

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.