Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise exceptions on ill-formatted actions #21

Open
jonrkarr opened this issue Sep 10, 2021 · 3 comments
Open

Raise exceptions on ill-formatted actions #21

jonrkarr opened this issue Sep 10, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@jonrkarr
Copy link

jonrkarr commented Sep 10, 2021

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.

@ASinanSaglam
Copy link
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.

@ASinanSaglam ASinanSaglam added the bug Something isn't working label Sep 16, 2021
@jonrkarr
Copy link
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.

@ASinanSaglam
Copy link
Contributor

ASinanSaglam commented Sep 20, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants