Future for package developers and temporary overriding of plans
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- r
调研方向
首先阅读 ?future::plan() 中的建议,以及 issues #263 和 #274 中的讨论,还有 pull requests #682 和 #617。评估是否需要为临时 future 计划提供标准的环境变量覆盖,然后定义约定,并记录用户和包开发者应有的预期;该 issue 未指出实现文件或测试。
由索引模型根据 Issue 内容生成。
描述
It's an almost 3 year long standing feature request in r-lib/stlyler to offer parallelisation and I have been very conservative on this and rejected implementations in https://github.com/r-lib/styler/pull/682 and https://github.com/r-lib/styler/pull/617, mainly because of your recommendations for package developers in ?future::plan(). I also read up on #263 and #274. I agree that there should be clear rules on how to use future strategies to avoid lack of control of the end user and a 'parallel chaos' with an increasing adoption of the future framework. I think one thing to consider in this discussion is that requirements for different tasks are widely different. A package for processing genomic sequences has a different user base and different scaling requirements than a tool like styler. For styler, 99% just want to have results quicker, they probably don't even know anything about future, remote workers or similar. And they should not have to. So I appreciate your note in ?future::plan():
If you think it is necessary to modify the future strategy within a function, then make sure to undo the changes when exiting the function. This can be done using: [...].
oplan <- plan(new_set_of_strategies)
on.exit(plan(oplan), add = TRUE)
[...]
The problem with this solution is that there is no way for users (package developer or end user) of code that contains the above workaround to override the strategy anymore. Which is exactly what we wanted to prevent in the first place. For this reason, I suggest to extend the recommendation and give the user a way to override this with an env variable. Of course every package developer could think of their own way to override, but wouldn't it be great to have a spec for this? Along these lines:
If you think it is necessary to modify the future strategy within a function, then make sure to undo the changes when exiting the function. In any case, enduser or package developer of your code should be able to override your decision, as they might use your code in ways you could not think of. To allow this, the recommended convention is to use an environment variable
R_FUTURE_OVERRIDE_[pkgname]where[pkgname]should be substituted with the name of your package in which you place this code. If your package is called pkg1:
if (nzchar(Sys.getenv('R_FUTURE_OVERRIDE_pkgname'))) {
oplan <- plan(new_set_of_strategies)
on.exit(plan(oplan), add = TRUE)
[...]
}
Maybe package authors should document also that they are temporarily setting a future plan in ?pkg1::future_strategy or similar. Not sure I have enough context here for naming conventions and similar, but I guess you get the main idea. What do you think?
- 主要语言
- 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 ·