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

Open
#957 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

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.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Python
Stars
25
Forks
25
Avg merge
4h 5m
Merged PRs (30d)
10

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lanl/PyBNF

All issues in lanl/PyBNF

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.