Bug Fixes for XML Parser in get_rule_mod#67
Open
akutuva21 wants to merge 21 commits intoRuleWorld:mainfrom
Open
Bug Fixes for XML Parser in get_rule_mod#67akutuva21 wants to merge 21 commits intoRuleWorld:mainfrom
get_rule_mod#67akutuva21 wants to merge 21 commits intoRuleWorld:mainfrom
Conversation
…resources Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
…t_sbml.xml Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Co-authored-by: akutuva21 <44119804+akutuva21@users.noreply.github.com>
Resolved conflict in xmlparsers.py by keeping the more robust version that uses .get() with default value for @DeleteMolecules attribute. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…35337824748401789 ⚡ Bolt: [performance improvement] Cache find_BNG_path and remove pkg_resources
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.
Pull Request: Bug Fixes for XML Parser in
get_rule_modSummary
This PR addresses four critical parser bugs in the
xmlparsers.pyfile'sget_rule_modmethod that were causing runtime errors and incorrect parsing behavior when processing BioNetGen XML files. The fixes ensure robust handling of missing attributes, type inconsistencies, and iteration bugs in the rule modification parser.Note on branch history: While the
bolt-performance-optimizationbranch contains 19+ commits with various experimental improvements, after merging with upstreammain, only the parser bug fixes remain as net changes. Other experimental work (CI updates, performance optimizations) was superseded by upstream updates including PR #63.Changes Made
Files Modified
bionetgen/modelapi/xmlparsers.py- 16 lines modified (8 additions, 8 deletions)tests/test_get_rule_mod.py- New file with 125 lines of comprehensive test coverageBug Fixes in
xmlparsers.py1. Fixed Missing
@DeleteMoleculesAttribute Handling (Line 705)Before:
After:
Issue: KeyError when
@DeleteMoleculesattribute was missing from Delete operations.Fix: Use
.get()with default value "0" to safely handle missing attributes.2. Fixed
all()Function Misuse (Line 708)Before:
After:
Issue:
all()returns a boolean, not an integer. ComparingTrue == 1worked accidentally but was semantically incorrect.Fix: Properly check if all values in the list equal "1".
3. Fixed Variable Reference Bug in MoveConnected Loop (Lines 734-737)
Before:
After:
Issue: Loop variable was
mobut code was referencingmove_op(the list, not the item). This would fail for lists or append incorrect data for single dictionaries.Fix: Changed all references from
move_optomoto use the loop iteration variable.4. Fixed TotalRate Type Handling and Missing Attribute (Lines 742-747)
Before:
After:
Issues:
@totalrateattribute was missing@totalratecould be string "1" or integer 1 from XML parserFix:
.get()with default "0" to handle missing attributesTest Coverage
Added comprehensive unit tests in
tests/test_get_rule_mod.pycovering:TotalRate handling:
@totalrate: 1)@totalrate: "1")@totalrate: "0")DeleteMolecules handling:
@DeleteMoleculesattributeMoveConnected handling:
Precedence testing:
All tests pass and verify that the parser no longer crashes on edge cases and handles both string and integer attribute values correctly.
Impact
These fixes prevent runtime crashes and ensure correct parsing of BioNetGen XML files with:
@DeleteMoleculesattributesTesting
To run the new tests:
All existing tests continue to pass, confirming backward compatibility.
Branch History
The
bolt-performance-optimizationbranch originally contained multiple experimental changes:find_BNG_path, removingpkg_resources)However, after merging upstream
main(which included PR #63 with SBML compatibility improvements), most experimental changes were superseded by the upstream versions. Only the xmlparsers bug fixes remain as net changes from this branch.Key Commits
065c6fd- ⚡ Bolt: [performance improvement] Cache find_BNG_path (superseded by merge)dd1a811through2706407- CI/CD improvements (superseded by merge)acaa6e8throughbb65478- Parser bug fixes (retained after merge)d011fac- Merge main into branch (resolved conflicts, kept parser fixes)Checklist
Branch:
bolt-performance-optimization-6035337824748401789Base:
mainAuthor: @akutuva21