Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

`ExperimentsToSbmlConverter`: "no priority set" warning is unreachable

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

阅读 petab/v2/converters.py 第 166 行附近的警告保护逻辑,并使用 ExperimentsToSbmlConverter 通过 PEtab 测试用例 0030 复现。检查当原始模型事件没有优先级时,转换该用例是否会发出警告;该 issue 还提出了这样一个问题:是否应将警告限制在可能与条件变化同时触发的事件上。

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

描述

ExperimentsToSbmlConverter warns when a pre-existing model event has no priority, because in that case the relative order of that event and a co-triggering PEtab condition change is undefined. The guard for that warning can never be true for an event that actually lacks a priority (petab/v2/converters.py:166 on main):

for event in model.getListOfEvents():
    # Check for undefined event priorities and warn
    if (prio := event.getPriority()) and prio.getMath() is None:
        warnings.warn(
            f"Event `{event.getId()}` has no priority set. "
            ...

For an event with no <priority> element at all — the common case, and the one the warning is about — getPriority() returns None, so the walrus target is falsy and the branch is skipped. For an event that does have a priority, prio.getMath() is not None, so the branch is skipped as well. The only input that reaches the warning is a <priority> element that exists but carries no math, which essentially does not occur in practice.

The net effect is that converting a problem whose model has unprioritised events succeeds silently, and the downstream tool is left with undefined event ordering and no indication that anything is ambiguous.

Reproducible with PEtab test suite case 0030, whose model contains one event (_E0) with no priority, co-triggering with a PEtab condition change at t=10:

import warnings
import petabtests
from petab.v2 import Problem
from petab.v2.converters import ExperimentsToSbmlConverter

case_dir = petabtests.get_case_dir("0030", "sbml", "v2.0.0")
problem = Problem.from_yaml(case_dir / petabtests.problem_yaml_name("0030"))

with warnings.catch_warnings(record=True) as caught:
    warnings.simplefilter("always")
    ExperimentsToSbmlConverter(problem).convert()

print([str(w.message) for w in caught])  # no priority warning

The original event reports getPriority() is None, and both events in the converted model end up without a priority, so nothing downstream can distinguish "deliberately undefined" from "nobody thought about it".

The fix is presumably:

if (prio := event.getPriority()) is None or prio.getMath() is None:

This is not just cosmetic for consumers. A simulator with no notion of simultaneous event execution has to fall back on some internal ordering of the two co-timed events, and since the period-start event is created with useValuesFromTriggerTime=True, running it second makes its assignments overwrite the model event's effect entirely. Case 0030 then silently yields wrong results, with nothing in the conversion output hinting at why. The warning, had it fired, would have pointed straight at default_priority.

While here, it may be worth reconsidering whether the warning should be emitted only when an unprioritised event can plausibly co-trigger with a condition change, since for models with many events it will otherwise be noisy.

🤖 Generated with Claude Code

主要语言
Python
星标
18
派生
9
平均合并
1 天 8 小时
30 天内合并 PR
21

环境准备

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

从这里开始

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

PEtab-dev/libpetab-python 的其他 Issue

查看 PEtab-dev/libpetab-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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