NeuroML / pyNeuroML

A single package in Python unifying scripts and modules for reading, writing, simulating and analysing NeuroML2/LEMS models.
https://docs.neuroml.org/Userdocs/Software/pyNeuroML.html
GNU Lesser General Public License v3.0
36 stars 30 forks source link

Expose programmatic access to error messages #126

Closed jonrkarr closed 2 years ago

jonrkarr commented 2 years ago

Its hard to retrieve those messages programmatically since they are printed to the console.

Describe the solution you'd like Expose programmatic access to the messages, ideally a list of errors and warnings

Describe alternatives you've considered Programmatically collecting console output, such as using capturer or subprocess.

sanjayankur31 commented 2 years ago

Can you describe a use case please where one would need programmatic access to error messages? At the moment, they're meant to be printed on the console only. Users are not expected to parse these in their scripts.

jonrkarr commented 2 years ago

For example, to provide validation of NeuroML models in a UI, such as a website.

jonrkarr commented 2 years ago

A single string output would be a significant improvement

jonrkarr commented 2 years ago

Alternatively, if a different library does this (e.g., libNeuroML), we'd be happy to use that.

sanjayankur31 commented 2 years ago

libNeuroML will check the file against the schema, so it'll be able to say if it has a valid structure. pyneuroml, through jneuroml, also runs tests in addition to this one validation.

We can't return a single string, because then that's not appropriate for console output. We currently use logging when jnml is called:

https://github.com/NeuroML/pyNeuroML/blob/d0f58ca75fe52015f633cd3dcb01bceaca476c62/pyneuroml/pynml.py#L1964

This returns True or False to indicate whether the jnml command completed correctly.

We'll have to think of how to refactor this to also allow programmatic access to code. On our backlog now.

jonrkarr commented 2 years ago

Should we use pyNeuroML or libNeuroML?

sanjayankur31 commented 2 years ago

jneuroml via pyneuroml is the suggested validation tool.

https://docs.neuroml.org/Userdocs/ValidatingNeuroMLModels.html

sanjayankur31 commented 2 years ago

@jonrkarr : could you please take a quick look to see if #127 works for your use case?