`ExperimentsToSbmlConverter`: "no priority set" warning is unreachable
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 72/100
Piste de recherche
Lisez la garde d’avertissement dans petab/v2/converters.py autour de la ligne 166 et reproduisez-la avec le cas de test PEtab 0030 en utilisant ExperimentsToSbmlConverter. Vérifiez que la conversion du cas émet un avertissement lorsque l’événement du modèle d’origine n’a pas de priorité ; l’issue soulève également la question de savoir si les avertissements devraient être limités aux événements qui peuvent se déclencher conjointement avec des changements de condition.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- Python
- Étoiles
- 18
- Forks
- 9
- Merge moyen
- 1 j 8 h
- PR mergées (30 j)
- 21
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de PEtab-dev/libpetab-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
PEtab-dev/libpetab-python#568 ·
Les mainteneurs répondent en général sous 1 jour
-
`petab_files_1to2` keeps a stale model file when converting into a non-empty output directoryOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
PEtab-dev/libpetab-python#566 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
PEtab-dev/libpetab-python#549 ·
Les mainteneurs répondent en général sous 1 jour
-
Deprecation warnings with pandas 3.1 (`inplace`, `read_csv(float_precision=...)`)Peut-être pris @dweindl l’a pris il y a 1 jour. Ouverte
PEtab-dev/libpetab-python#570 · 1 personne assignée ·
Les mainteneurs répondent en général sous 1 jour
-
`petablint` fails for PEtab v2 problems with only warningsPeut-être pris @dweindl l’a pris il y a 2 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 35/100
PEtab-dev/libpetab-python#567 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de PEtab-dev/libpetab-python
Issues similaires
-
style: article/section 📝 system: cloud.rc ☁️ system: security 🔐
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
uabrc/uabrc.github.io#1262 ·
-
documentation
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
NCAR/miles-credit#526 ·
-
documentation
Difficulté 1/5 1-3 heures Accessibilité débutants 76/100
conda/conda-lock#957 ·
Les mainteneurs répondent en général sous 1 jour
-
Type: Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
aws-samples/sample-per-model-bedrock#464 ·
Les mainteneurs répondent en général sous 1 jour