[Feature request] function that tells what is the current strategy
@HenrikBengtsson 已经在做这个了。
开始于 2022年6月1日。
评估
这个 Issue 还没有评估数据。
描述
Let define a simplified function in a package that looks like that:
pkg_fun <- function(fun, x) {
f <- vector("list", length(x))
for (i in seq_along(x)) {
f[[i]] <- future::future({ fun(x) })
}
# some code to handle resolution and get values of futures...
}
Users can use it like that
library(pkg)
library(future)
plan(multisession)
pkg_fun(myfunction, mydata)
There is no way for the developer to know what is the plan used by the user. It is sequential? multicore on a single machine? multiple remote machine? I do agree that most of the time the developer do no need to know. But I'm personally facing multiple cases were I need to know to handle stuff internally or to throw informative warning or error. For examples:
myfunctionmay already be parallelized in C++ with OpenMP. Testing the strategy allows to enable or disable OpenMP and avoid nested parallelismmydatacan contain non serializable objects and the code subsequently fails with no informative error for parallel strategies (but works withplan(sequential)). Being able to catch those cases early would allow to handle them nicely.myfunctioncan return non serializable objects. Same issue than 2.
So far I'm using a custom parser than analyses the ouptut of future::plan() but I think it would be a useful addition to add easy to parse functions for developpers in future. Something like that maybe
future::is_parallel_strategy()
future::get_strategy_workers()
future::is_remote_stragety()
future::is_nested_strategy()
# ...
Thanks
- 主要语言
- R
- 星标
- 1k
- 派生
- 93
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 1
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
futureverse/future 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
futureverse/future#852 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 35/100
futureverse/future#849 ·
-
bug
难度 4/5 3-5 天 新手友好度 48/100
futureverse/future#833 ·
-
feature/resources RNG
难度 5/5 一周以上 新手友好度 35/100
futureverse/future#832 ·
-
RNG
难度 5/5 一周以上 新手友好度 38/100
futureverse/future#831 · 1 条评论 ·
查看 futureverse/future 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 88/100
nf-core/provenancereport#75 ·
-
难度 1/5 1 小时以内 新手友好度 95/100
-
难度 1/5 1 小时以内 新手友好度 72/100
garner-code/PsyR#80 ·