`ExperimentsToSbmlConverter`: "no priority set" warning is unreachable
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 72/100
Rechercherichtung
Lesen Sie die Warnungsprüfung in petab/v2/converters.py um Zeile 166 und reproduzieren Sie sie mit dem PEtab-Testfall 0030 unter Verwendung von ExperimentsToSbmlConverter. Prüfen Sie, dass die Konvertierung des Falls eine Warnung ausgibt, wenn das Ereignis des ursprünglichen Modells keine Priorität hat; das Issue wirft außerdem die Frage auf, ob Warnungen auf Ereignisse beschränkt werden sollten, die gleichzeitig mit Bedingungsänderungen ausgelöst werden können.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 18
- Forks
- 9
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 21
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus PEtab-dev/libpetab-python
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
PEtab-dev/libpetab-python#568 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 73/100
PEtab-dev/libpetab-python#566 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
PEtab-dev/libpetab-python#549 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Deprecation warnings with pandas 3.1 (`inplace`, `read_csv(float_precision=...)`)Evtl. vergeben @dweindl hat das vor 1 Tag übernommen. Offen
PEtab-dev/libpetab-python#570 · 1 zugewiesene Person ·
Maintainer antworten meist innerhalb von 1 Tag
-
`petablint` fails for PEtab v2 problems with only warningsEvtl. vergeben @dweindl hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 35/100
PEtab-dev/libpetab-python#567 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in PEtab-dev/libpetab-python
Ähnliche Issues
-
style: article/section 📝 system: cloud.rc ☁️ system: security 🔐
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
uabrc/uabrc.github.io#1262 ·
-
documentation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
NCAR/miles-credit#526 ·
-
documentation
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 76/100
conda/conda-lock#957 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Type: Bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
aws-samples/sample-per-model-bedrock#464 ·
Maintainer antworten meist innerhalb von 1 Tag