`ExperimentsToSbmlConverter`: "no priority set" warning is unreachable
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
Lea la guarda de advertencia en petab/v2/converters.py alrededor de la línea 166 y reprodúzcala con el caso de prueba 0030 de PEtab usando ExperimentsToSbmlConverter. Compruebe que la conversión del caso emita una advertencia cuando el evento del modelo original no tenga prioridad; el issue también plantea la cuestión de si las advertencias deberían limitarse a los eventos que pueden activarse conjuntamente con cambios en las condiciones.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
- Lenguaje dominante
- Python
- Estrellas
- 18
- Forks
- 9
- Merge medio
- 1 d 8 h
- PR fusionados (30 d)
- 21
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de PEtab-dev/libpetab-python
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
PEtab-dev/libpetab-python#568 ·
Los mantenedores suelen responder en 1 día
-
`petab_files_1to2` keeps a stale model file when converting into a non-empty output directoryAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 73/100
PEtab-dev/libpetab-python#566 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
PEtab-dev/libpetab-python#549 ·
Los mantenedores suelen responder en 1 día
-
Deprecation warnings with pandas 3.1 (`inplace`, `read_csv(float_precision=...)`)Posiblemente ocupada @dweindl la tomó hace 1 día. Abierto
PEtab-dev/libpetab-python#570 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
`petablint` fails for PEtab v2 problems with only warningsPosiblemente ocupada @dweindl la tomó hace 2 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
PEtab-dev/libpetab-python#567 ·
Los mantenedores suelen responder en 1 día
Todos los issues de PEtab-dev/libpetab-python
Issues similares
-
style: article/section 📝 system: cloud.rc ☁️ system: security 🔐
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
uabrc/uabrc.github.io#1262 ·
-
documentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
NCAR/miles-credit#526 ·
-
documentation
Dificultad 1/5 1-3 horas Aptitud para principiantes 76/100
conda/conda-lock#957 ·
Los mantenedores suelen responder en 1 día
-
Type: Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
aws-samples/sample-per-model-bedrock#464 ·
Los mantenedores suelen responder en 1 día