Skip to content

Capture stdout/stderr in run_command's timeout path so BNG2.pl errors reach callers#83

Open
wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
wshlavacek:modelapi-b8-capture-stderr
Open

Capture stdout/stderr in run_command's timeout path so BNG2.pl errors reach callers#83
wshlavacek wants to merge 1 commit intoRuleWorld:mainfrom
wshlavacek:modelapi-b8-capture-stderr

Conversation

@wshlavacek
Copy link
Copy Markdown

Summary

`run_command(suppress=True, timeout=set)` in `bionetgen/core/utils/utils.py` redirects stdout/stderr to `DEVNULL`, so when `BNGCLI` raises `BNGRunError` on a failing BNG2.pl invocation, the actual diagnostic message (e.g. `Missing end parentheses ... at and(...)`) never reaches the user.

Fix

Always capture stdout/stderr. With a timeout set, `subprocess.run` buffers all output anyway, so the `suppress` distinction is already a no-op for the user during the run — what it does do is discard the bytes needed to build a useful error message after the fact.

After this, the `_run.log` for a failing BNG2.pl call shows the real ABORT message, which makes round-trip / regenerated-BNGL bugs trivial to localize.

Test plan

  • Existing CI passes
  • A failing BNG2.pl invocation surfaces its stdout/stderr tail through whatever caller wraps `run_command` (e.g. `BNGCLI`'s `BNGRunError` message)

… reach callers

`run_command(suppress=True, timeout=set)` was redirecting stdout/stderr
to `DEVNULL`, so when `BNGCLI` raised `BNGRunError` on a failing BNG2.pl
invocation, the actual diagnostic message (e.g. `Missing end parentheses
... at and(...)`) never reached the user.

Always capture instead. With a timeout set, `subprocess.run` buffers all
output anyway, so the `suppress` distinction was already a no-op for the
user during the run — what it did do was discard the bytes needed to
build a useful error message after the fact.

After this, the `_run.log` for a failing BNG2.pl call shows the real
ABORT message, which makes round-trip / regenerated-BNGL bugs trivial
to localize.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant