`ExperimentsToSbmlConverter`: "no priority set" warning is unreachable
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
閱讀 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 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
PEtab-dev/libpetab-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
PEtab-dev/libpetab-python#568 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 73/100
PEtab-dev/libpetab-python#566 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
PEtab-dev/libpetab-python#549 ·
維護者通常 1 天內回覆
-
Deprecation warnings with pandas 3.1 (`inplace`, `read_csv(float_precision=...)`)可能已有人在做 @dweindl 於 1 天前認領。 未關閉
PEtab-dev/libpetab-python#570 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
`petablint` fails for PEtab v2 problems with only warnings可能已有人在做 @dweindl 於 2 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 35/100
PEtab-dev/libpetab-python#567 ·
維護者通常 1 天內回覆
查看 PEtab-dev/libpetab-python 的全部 Issue
相似的 Issue
-
style: article/section 📝 system: cloud.rc ☁️ system: security 🔐
難度 2/5 1-3 小時 新手友好度 65/100
uabrc/uabrc.github.io#1262 ·
-
documentation
難度 2/5 1-3 小時 新手友好度 70/100
NCAR/miles-credit#526 ·
-
documentation
難度 1/5 1-3 小時 新手友好度 76/100
conda/conda-lock#957 ·
維護者通常 1 天內回覆
-
Type: Bug
難度 2/5 1-3 小時 新手友好度 65/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
aws-samples/sample-per-model-bedrock#464 ·
維護者通常 1 天內回覆