Skip to content

Raise exceptions on ill-formatted actions #21

Open

Description

@jonrkarr

Here's an example of an ill-formatted action (missing end }) that pyBioNetGen doesn't raise an exception for and doesn't parse as intended

simulate_ssa({t_start=>0,t_end=>1000000,n_steps=>1000,seed=>2);

The parsed args for the action can be accessed as below

model.actions.items[0].args

This returns this data structure

[
    ('{t_start=>0', None), 
    ('t_end=>1000000', None), 
    ('n_steps=>1000', None), 
    ('seed=>2', None)
]

The first argument is not parsed as intended.

Activity

  1. ASinanSaglam commented on Sep 16, 2021

    @ASinanSaglam
    Contributor

    We have a solution coming for this soon but it won't have custom exceptions unfortunately. Once we have a better parsing solution we'll have custom errors that will let the user know. I'll update the issue with the fix once the fix is pushed but I'll keep the issue open until the better parsing solution is implemented.

  2. jonrkarr commented on Sep 16, 2021

    @jonrkarr
    Author

    I was imagining basic validation that just recognizes the general syntax for actions (comma-separated list enclosed in curly brackets).

    Validation of the specific attributes associated with particular actions would be even better, but I wasn't trying to suggest that. Basic validation as outlined above would be helpful.

  3. ASinanSaglam commented on Sep 20, 2021

    @ASinanSaglam
    Contributor

    This is partially addressed with 0.4.6 release. The actions now know their possible arguments and will raise an error if the argument is incorrect. Eventually with the full parser I'm hoping to point out the exact reason why something fails but until then this should catch majority of these hopefully.

  4. added a commit that references this issue on Mar 17, 2026
    212b198
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions