diagnose: the error argument is sent as epsilon; the output directory is never removed
还没有人认领这个 Issue。
评估
调研方向
该缺陷位于 cmdstanpy/model.py 中的 CmdStanModel.diagnose:error 分支追加的是 epsilon= 而不是 error=,并且通过 tempfile.mkdtemp 在 _TMPDIR 下创建的输出目录从未被删除。请先阅读 log_prob 的测试,它们检查记录的命令,可作为新测试的范例。完成的标准是:命令中包含 error=,并且在成功和失败两条路径上调用后,_TMPDIR 下的条目数保持不变。请先查看 #869,因为该 issue 称清理方案已在那里达成一致。
由索引模型根据 Issue 内容生成。
描述
Summary
CmdStanModel.diagnose (cmdstanpy develop at the time of writing, also 1.3.0) has two bugs:
- The
errorargument is sent asepsilon. CmdStan never receiveserror=, and when both arguments are given,epsilonappears twice on the command line. - Each call leaves a temporary output directory under
_TMPDIR, removed only at interpreter exit. This is the same pattern as #867, which is being fixed forlog_probin #869.
Where
cmdstanpy/model.py, CmdStanModel.diagnose, on develop:
if epsilon is not None:
cmd.append(f"epsilon={epsilon}")
if error is not None:
cmd.append(f"epsilon={error}") # should be f"error={error}"
...
output_dir = tempfile.mkdtemp(prefix=self.name, dir=_TMPDIR) # never removed
CmdStan 2.40.0's argument tree accepts both sub-arguments under diagnose test=gradient (output of <model> diagnose help-all):
gradient
Valid subarguments: epsilon, error
epsilon=<double> Finite difference step size Defaults to 1e-6
error=<double> Error threshold Defaults to 1e-6
Effect
diagnose(error=x)silently sets the finite-difference step to x, and the error threshold stays at its default 1e-6. The gradient check then judges against a threshold the caller did not ask for, using a step size the caller did not ask for.diagnose(epsilon=a, error=b)passesepsilon=a epsilon=b.- The output directory accumulates in long-running processes, as described in #867.
Suggested fix
- Send
f"error={error}". - Scope the output directory with
tempfile.TemporaryDirectory(prefix=self.name, dir=_TMPDIR), the approach agreed on #869. - Add a test asserting that the command carries
error=(the logged command, as thelog_probtests do) and that_TMPDIR's entry count is unchanged after calls on both the success path and the failure path.
We can fold this into #869, or open a separate PR, whichever you prefer.
Versions
cmdstanpy develop (also 1.3.0), CmdStan 2.40.0, Python 3.12, Linux x86_64.
- 主要语言
- Python
- 星标
- 198
- 派生
- 82
- 平均合并
- 4 天 11 小时
- 30 天内合并 PR
- 3
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
stan-dev/cmdstanpy 的其他 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 70/100
-
laplace_sample: expose CmdStan's diagnostic_file (the Hessian at the mode)可能已有人在做 @atarutin 于 7 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 25/100
-
Release 2.0未关闭
难度 5/5 一周以上 新手友好度 30/100
-
feature
难度 5/5 一周以上 新手友好度 35/100
-
documentation
难度 2/5 1-3 小时 新手友好度 55/100
查看 stan-dev/cmdstanpy 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
cellrishi-code/claude-skills-atlas#165 ·
维护者通常 1 天内回复
-
bug confirmed issue
难度 2/5 1-3 小时 新手友好度 72/100
open-webui/open-webui#32635 · 1 条评论 ·
维护者通常 1 天内回复
-
Filters: ?field:ne=null matches NULL rows instead of non-NULL ones可能已有人在做 @rshdhere 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
Netflix/metaflow-service#504 ·
-
needs-triage
难度 2/5 1-3 小时 新手友好度 84/100
gke-labs/kube-agents#3394 ·
维护者通常 1 天内回复
-
A2A audit timestamps end in +00:00Z (invalid ISO 8601)可能已有人在做 @O1sumitkumar 今天认领。 未关闭bug good first issue help wanted python
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复