Optional BNGsim integration: in-process simulation + multi-format input#102
Draft
wshlavacek wants to merge 2 commits into
Draft
Optional BNGsim integration: in-process simulation + multi-format input#102wshlavacek wants to merge 2 commits into
wshlavacek wants to merge 2 commits into
Conversation
Optional in-process simulation backend, used iff `import bngsim` succeeds; otherwise the existing BNG2.pl / run_network / NFsim path is used unchanged, so behavior is identical when bngsim is absent. bngsim is never an install dependency (pure soft-import). Adds the bridge module, the BNG2.pl backend-hook helper, the in-process parameter_scan driver, CLI/runner routing (auto / --no-bngsim), version reporting, and tests. Touchpoints are additive; the non-bngsim path is left byte-for-byte upstream. Toward RuleWorld#66.
Packaging (B3): add extras_require={"bngsim": ["bngsim>=0.9.10"]} so the
optional in-process engine is discoverable via `pip install bionetgen[bngsim]`,
while keeping bngsim out of install_requires (never a hard dependency). The
extra's floor matches MINIMUM_BNGSIM_VERSION in the bridge.
Bridge: bump MINIMUM_BNGSIM_VERSION 0.6.0 -> 0.9.10. 0.9.0 settled the
method-independent gdat/scan output schema (bngsim RuleWorld#58) the parity differ
normalizes against; 0.9.10 is the current validated release. Refresh the
floor-rationale comment, which still cited the stale 0.6.0/RuleWorld#40 reason.
Update the version-guard test's minimum-version case to 0.9.10.
With bngsim absent the bridge soft-imports to the legacy subprocess path
unchanged; the bngsim test files skip/pass cleanly (239 passed, 9 skipped,
0 errors with bngsim genuinely uninstalled).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds BNGsim as an optional in-process simulation engine for PyBioNetGen.
The integration is a pure soft-import: if
bngsimis not installed, everysimulation routes through the existing subprocess BNG2.pl / run_network / NFsim
path exactly as today. With bngsim absent, behavior is unchanged — the
contract this PR is built around.
bngsim is never an install dependency. It is offered as an optional extra
(
pip install bionetgen[bngsim], floorbngsim>=0.9.10) and gated at runtimeby a single
BNGSIM_AVAILABLEflag; aBIONETGEN_NO_BNGSIM=1kill-switch and aversion floor (
MINIMUM_BNGSIM_VERSION = 0.9.10) force the legacy path when setor when an older bngsim is present.
New capabilities (only active when bngsim is installed)
for the simulation step).
.bngl,.net, SBML (.xml),and Antimony (
.ant) — plus an explicit override (--format/format=).tfun(inline tabulated functions): models usingtfun(...)run correctlyin-process (the bridge routes them to the interpreted RHS, since bngsim
codegen + tfun is not yet stable).
fallback to the interpreted RHS where codegen is unsafe.
persistent helper process to amortize bngsim import cost across scan points.
run:--method,--format,--timeout,--no-bngsim.bionetgen.run(...)kwargs:simulator=(default"auto"),method=,format=,t_span=,n_points=,timeout=.Issues addressed
Closes #66 — BNGsim integration: in-process simulation + multi-format support.
Closes #65 —
tfun(inline tabulated functions) now run in-process.Addresses #6 — input-format auto-detection removes the hard file-extension
requirement (with an explicit
--format/format=hint).Addresses #22 — the in-process engine removes Perl from the simulation step
(a different mechanism than the py-perl5 suggestion, but the same goal); left
open for the remaining broader work.
Scope of the diff
Purely additive against
upstream/main— 20 files, +7976/−53 (the deletions arere-routings inside three existing entry points, not feature removals):
core/tools/bngsim_bridge.py(the soft-import + routingcore),
core/tools/bngsim_backend_helper.py,core/tools/bngsim_parameter_scan.py.__init__.py(+3, exportBNGSIM_AVAILABLE),core/tools/__init__.py(+13),core/tools/info.py(+16, banner line).main.py(the new CLI flags),core/tools/cli.py,modelapi/runner.py.setup.py(+9) — adds onlyextras_require={"bngsim": [...]};bngsim stays out of
install_requires.tests/conftest.py(+34,require_bng2/require_atomizerfixtures)and 9 new
tests/test_bngsim_*.pyfiles.Test plan / verification
the in-process path and produces output.
239 passed / 9 skipped / 0 errors (the 9 skips are the real-engine paths,
guarded by
skipif(not BNGSIM_AVAILABLE)); no collection-timeimport bngsim.test_model_running_CLIis identical on this branchwith bngsim disabled vs. pristine
upstream/main(same pre-existing results) —i.e. zero regression on the no-bngsim path.
black --checkclean on all added/changed files; Python 3.8–3.12 safe.Trying the optional engine (not required to use this PR)
bngsim is a compiled extension and is not on PyPI yet, so
pip install bionetgen[bngsim]will not resolve until it is published. To try the in-processengine now, install a prebuilt wheel from the release:
CI does not install bngsim, so none of this affects the green-checks contract.