Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta Para iniciantes
#525 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
python
Domínio
backend

Direção de pesquisa

Leia a guarda de aviso em petab/v2/converters.py por volta da linha 166 e reproduza-a com o caso de teste 0030 do PEtab usando ExperimentsToSbmlConverter. Verifique se a conversão do caso emite um aviso quando o evento do modelo original não tem prioridade; a issue também levanta a questão de se os avisos devem ser limitados a eventos que podem ser acionados em conjunto com alterações nas condições.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
Python
Estrelas
18
Forks
9
Merge médio
1d 8h
PRs com merge (30d)
21

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de PEtab-dev/libpetab-python

Todas as issues de PEtab-dev/libpetab-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.