`future` unable to export libraries of list encapsulated functions

未关闭
#741 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
r

调研方向

使用 plan(multisession, workers = 2) 运行提供的 R 重现代码,重点关注 future::future(wrapper(1)) 和列表中持有的函数。跟踪 future 如何为此嵌套调用检测 globals 和包;当示例能够解析 lubridate's days() 且不再出现缺少函数的错误时,即完成。

由索引模型根据 Issue 内容生成。

描述

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)
主要语言
R
星标
1k
派生
93
平均合并
2 天 4 小时
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

futureverse/future 的其他 Issue

查看 futureverse/future 的全部 Issue

相似的 Issue

更多 R Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。