The PEtab importer ignores a problem.yaml extension marked `required: true`, where the PEtab v2 spec says a tool that does not support it must reject the problem

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

Start in pybnf/petab/import_.py at read_problem_yaml (around lines 1429-1430, 1437, 1527, and 1579), then follow import_job around lines 244-245. Reproduce the with_ext and no_ext imports from the issue and compare their output. Done means a required unsupported extension is rejected with its name, while an extension marked required: false is ignored with a note.

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

描述

bug silent-incorrectness

A PEtab v2 problem.yaml can list extensions under an extensions: key. An extension marked required: true is one that "changes the mathematical interpretation" of the problem. For example, the SciML extension replaces part of the model with a neural network. The spec says: "Toolboxes must reject PEtab problems that use extensions with required: true that they do not support." PyBNF supports no extensions. Even so, its importer skips the whole extensions: block without a message and writes the same job it writes when the block is deleted. The user then fits a different problem from the one the file declares and is never told. PyBNF should refuse such a problem and name the extension.

Example

Take any PEtab v2 problem that PyBNF imports. For example, use a BNGL model m.bngl with 0 -> A() v3 and A() -> 0 k, one observable obsA = A, and a parameters table that estimates k. Append this to its problem.yaml:

extensions:
  my_ext:
    version: 1.0.0
    required: true

Then import it twice, once with the block and once without:

from pybnf.petab import import_job
import_job('with_ext/problem.yaml', 'imp_ext')
import_job('no_ext/problem.yaml', 'imp_noext')

Both calls return without printing anything, and diff -r imp_ext imp_noext finds no difference. A SciML-shaped block (sciml: with version, required: true, neural_networks:, hybridization_files: and array_files:) also gives output identical to the problem without it.

What PyBNF should do comes from the spec's Extensions section (petab.readthedocs.io, v2 data format), quoted above. The problem YAML schema defines required as whether "the extension is required for the mathematical interpretation of the problem". libpetab is a validator, not a simulator, so the rule does not bind it, but it does report the block. petab.v2.Problem.from_yaml records extensions: {'my_ext': ExtensionConfig(version='1.0.0', required=True)}, and lint_problem warns: The given problem uses the following extensions for which validation is not yet implemented: my_ext.

Why

read_problem_yaml (pybnf/petab/import_.py:1437) parses the file by hand. Since #902 it refuses any top-level key that the PEtab v2 schema does not allow. It accepts extensions as one of the allowed keys, with the comment "id and extensions carry nothing the importer reads" (import_.py:1429-1430). The key sets in_other (import_.py:1527), and every indented line beneath it is then skipped (import_.py:1579). import_job (import_.py:244-245) goes straight from this reader to the model-language check, so nothing records or checks an extension or its required flag.

Possible fix

In read_problem_yaml, record each entry under extensions: with its required value. In import_job, refuse any extension whose required is not literally false, naming the extension and quoting the spec's rule. The spec lets a tool ignore an extension with required: false, so for those a one-line note that PyBNF ignores it is enough.

Related: #902 (which rewrote this reader)

Found while fixing the PEtab issues #892–#908 (2026-09-25); reproduced on main at cd2be675.

主要语言
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 摘要。