A malformed noise_model line is reported as "noise_model is not a valid configuration key", and every config parse error reports the line before the right one

未关闭 适合新手
#1,033 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
backend

调研方向

从pybnf/parse.py开始:检查第876行附近的配置解析循环和第1359行附近的格式提示分支,然后查找涵盖格式错误配置值的解析器测试。使用 issue 中格式错误的noise_model行,在examples/tutorial/36_estimate_noise/estimated_sigma.conf中复现问题。完成标准是:错误信息指出正确的从1开始计数的行号,区分未知键与已知键的无效值,并且测试覆盖这些情况。

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

描述

bug minor

Writing a fixed noise level as a bare number is an easy mistake:

noise_model = normal, sigma = 4

The correct form is sigma = fix_at 4. PyBNF reports the mistake as

Error: Parsing configuration key 'noise_model' on line 42.
noise_model is not a valid configuration key.

Both parts of the message are wrong.

  1. noise_model is a valid key. The value is what failed to parse. In pybnf/parse.py, after a line fails the grammar, a chain of elif key == ... branches picks a format hint for the key. A key with no branch falls through to fmt == '' and gets "is not a valid configuration key". The comment on the data branch (around line 1359) describes this same problem for data and fixes it for that one key only. noise_model has no branch, and neither does any other real key not in the chain.

  2. The line number is off by one. With the reproduction below, the noise_model line is line 43 of the file (grep -n agrees), and the message says 42. The number is the index i from for i, line in enumerate(ls) (around line 876), which counts from 0. Every message built from it, including the Misconfigured config key ... at line: {i} text, points at the line before the one at fault.

Reproduction: in examples/tutorial/36_estimate_noise/estimated_sigma.conf, replace the noise_model line with noise_model = normal, sigma = 4, delete the loguniform_var = noise_level ... line, and run pybnf -c on it.

Suggested fix: report a line number counted from 1. When the key is a real configuration key but its value does not parse, say so and give the accepted forms, as the data branch does. Use "is not a valid configuration key" only for a key PyBNF does not know. A test that runs every known key with a malformed value through the parser would keep the next new key from falling through.

主要语言
Python
星标
25
派生
25
平均合并
4 小时 5 分钟
30 天内合并 PR
10

环境准备

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

从这里开始

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

lanl/PyBNF 的其他 Issue

查看 lanl/PyBNF 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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