Changes by Jules#104
Open
akutuva21 wants to merge 796 commits into
Open
Conversation
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
…uery-6421710193914332157
…-5796961617997413746
…check-9132657053277532450
…label-9136102342659150753
…er-2975277189199558942
…or-test-13611885534457943203
…th-6196402775437548583
…710193914332157 ⚡ perf: fix N+1 query bottleneck in naming database annotation insertion
…6102342659150753 🧪 Test value/type error handling in structs
…-func-body-5109138640418052702 🧪 Improve testing for _extract_function_body in sympy_odes.py
…7189199558942 🧹 Refactor to add warning for renaming reserved keyword e in Atomizer
…3611885534457943203 🧪 test: add test coverage for Pattern.canonicalize ImportError
…17997413746 🧹 Refactor rawSpeciesName sorting to fix TODO
…2657053277532450 Fix detection of mass action kinetics in sbml2bngl
…2775437548583 🧹 Refactor BNGResult initialization to consolidate file and folder paths
Adds tests to verify that the `graphdiff` command in the `bionetgen` CLI correctly parses arguments and routes them to the underlying `graphDiff` tool. Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
The reduceComponentSymmetryFactors method was entirely broken and commented out. This commit fixes the following issues: 1. Removes the `rReactant` and `rProduct` block which called `append` with 2 arguments instead of 1, because non-constant stoichiometry errors are already checked correctly inside `__getRawRules`. 2. Fixes the broken dictionary comparison logic `rcomponent[key] == 1` by properly indexing the inner element (`rcomponent[key][element] == 1`). 3. Integrates the method into `sbml2bngl.py` by multiplying the computed component-level symmetry factors (`sl_comp, sr_comp`) with the species-level symmetry factors (`sl_spec, sr_spec`) to properly account for both symmetries in the BNGL output. Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Added unit tests `test_extract_odes_from_cvode_mex_direct` and `test_extract_odes_from_cvode_mex_inference` to `tests/test_sympy_odes.py` to cover the happy path and inference fallback of cvode mex parsing. Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
…2893446415596560176 Fix assignment rule renaming breakage
…-11490878634659662031 🧹 [code health improvement] Fix broken logic in assignment rule substitution
…tabase-15527366226394001331 ⚡ Optimize dictionary comprehensions in namingDatabase.py
…9383128 🧹 Remove commented out adjust_concentrations method
…95465865337956691 ⚡ Optimize regular expression performance in bnglWriter.py
…47221959 🧪 test: add cli argument tests for graphdiff command
…ors-15407715538739994464'
…ion-bottleneck-17973124674409253647'
…hecks-10773285539339568587'
…notebook-13162292659203895014'
…89043388907110236'
…13061356770607576383' # Conflicts: # bionetgen/atomizer/writer/bnglWriter.py
…hip-11294642204568800377'
…15236466194492171232'
…316388816443941394'
…on-5986959215111163739' # Conflicts: # bionetgen/atomizer/writer/bnglWriter.py
…ptions-7277840821812432296'
…5030303034692340617' # Conflicts: # bionetgen/atomizer/writer/bnglWriter.py
…26899485272141817'
…ation-resolver-9110844215045688974'
…154240589924040179'
…7027425954342234185' # Conflicts: # bionetgen/atomizer/writer/bnglWriter.py
…graph-10639770207778011296' # Conflicts: # bionetgen/atomizer/writer/bnglWriter.py
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.
PyBioNetGen: Security, Performance, Code Health, and Test Coverage Overhaul
Summary
This PR rolls up 419 commits spanning April 13 – June 4, 2026 into a single contribution against PyBioNetGen. It touches 151 unique files with roughly +10,800 / −9,100 lines changed across the run. The work is a broad maintenance and hardening pass over the codebase — closing security holes, eliminating long-standing
TODO/FIXME/assertdebt, optimizing hot paths, and substantially expanding test coverage — alongside a set of targeted bug fixes in the SBML→BNGL atomizer and the simulator/runner stack.Work was developed with assistance from AI coding agents (Jules), with all commits co-authored and reviewed;
Co-authored-bytrailers creditgoogle-labs-jules[bot]on ~115 commits.Commit breakdown by category
Most-affected files
atomizer/sbml2bngl.py,core/tools/visualize.py,modelapi/runner.py,atomizer/bngModel.py,simulator/csimulator.py,atomizer/libsbml2bngl.py,modelapi/bngfile.py, andmerging/namingDatabase.py, plus a large number of new and expanded test modules undertests/.1. Security fixes
Hardening focused on unsafe deserialization, code injection vectors, XML parsing, path traversal, and leaked secrets.
pickle.loadwithjson.loadinatomizer/contactMap.pyandannotationComparison.py, and fixed insecure deserialization indetectOntology.py.eval()→ast.literal_eval()across the atomizer andpostAnalysis.pyto remove arbitrary-code-execution risk.ast.literal_evalDoS vulnerabilities fixed inpostAnalysis.pyandanalyzeTrends(untrusted assumption strings), with one path further hardened by switching tojson.loads.readBNGXML.pyand a full migration todefusedxmlfor safe XML parsing.tarfile.extractallresolved.yaml.load→yaml.safe_load).pathwaycommons.py; the key is now read from theBIOGRID_API_KEYenvironment variable with a graceful warning-and-skip fallback when unset.molec.namein the atomizer.2. Performance optimizations
NamingDatabaseSQLite layer: persistent connection handling and reduced per-query overhead, reported as a ~3.7x query speedup; fixed an N+1 query in annotation insertion; batched annotation-ID caching to avoid full-table refetches; batched SQL in namespace detection.join/buffered builds inbnglReaction,bnglWriter.py,BNGResult.__repr__,bngmodel.__str__, andside_string.moleculeCreation,smallStructures,classifyReactions, atomizer constant lists).bnglWriter.pyanddistanceToModification; Levenshtein distance memoized inanalyzeSBML.type() == listchecks withisinstance(), removed redundant.keys()lookups andlen() == 0checks, and added early-exit traversal indeleteMolecule.queryActiveSitewithin theresolveSCTloop.3. Code health & refactoring
assertstatements to structuredBNGError/BNGParseErrorplusBNGLoggeracross reactions parsing,csimulatorinit,network.py, and model parsing; replaced bareexceptclauses with specific exceptions; converted silent assignment failures to logged warnings.os.chdir/ CWD discipline: a large sustained effort to eliminate working-directory leaks — refactoredVisResultandvisualize.pyto avoidos.chdir, wrapped directory changes intry/finally, replaced a module-level app instantiation that corrupted CWD, and usedTemporaryDirectorycontexts correctly. This resolved widespread WindowsPermissionError/WinError 32andFileNotFoundErrorfailures in CI.libsbml2bngl.pyandbngModel.pyrefactored to usenetworkxtopological sort (Kahn's algorithm).TODO/FIXMEitems and removed dead code throughout the atomizer, network structs, and model API; standardizedshutilimport (dropped theimport shutil as spawnalias); refactored oversized files (e.g. splittingsbml2bngl.pyhelpers into utility modules) and long methods (ActionList.__init__).blackformatting and removal of stray test/build artifacts.4. Bug fixes
observablesDictwhen overridden by assignment rules. Fixednl/nrassignment when reactants/products appear in rate expressions.Pattern, dimer component classification, volume adjustment for multiple species in rate functions, double-modification queueing inSCTSolver, and parameter namespace collisions inbngModelassignment rules.gdiff): fixed single-node-to-list conversion and nested node recoloring/renaming.bngl2xmlnow runs with a multiprocessing/subprocess timeout; fixedrunner.pySectionProxyattribute error; restored CWD infinallyblocks across visualize/runner/atomizer/simulator.--versionflag (after one revert/re-land cycle); fixedBNGPATHresolution whenBNG2.plis onPATH.ListOfBondstag handling inxmltodictparsing; invalid escape sequences in parameter rate-rule regexes;setup.pyduplicate manifest inclusions.5. New features
poplevel,check_product_scale) and apsasimulation method.sympyinParameterBlock/NetworkBlock.add_item.BNGResultextension-based file filtering; standalonefind_dat_files/load_resultsmethods; consolidated path argument in the constructor.add_bngl_functionhelper migrated into thebngModelclass.6. Test coverage
~88 commits add or expand tests, with new suites for
pathwaycommons(BioGRID/Reactome/Uniprot query paths and HTTPError fallbacks),detectOntology.levenshtein,sbml2jsonutilities, thecsimulator/libRRSimulatorwrappers,BNGSimulatorproperties,gdiff,sympy_odes,Patternequality,ModelObj/ActionBlockoperations, the runner, and thenotebook/graphdiffCLI commands. Several commits specifically add exception-path and edge-case coverage (e.g.add_block,_safe_rmtreeOS errors,_get_color_id).Notes for reviewers
blackformatting,pytest-mock→unittest.mock, Python 3.8 compatibility for parenthesizedwith) that account for some apparent duplication in the log; the net effect is a green, cross-platform test suite.Merging PR #340–#367) and a few others fold in earlier sub-PRs from the same branch series.