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

`run_lems_with_jneuroml_brian2` surprisingly requires the path to the LEMS file to be in the current directory #135

Open jonrkarr opened 2 years ago

jonrkarr commented 2 years ago

This is the problematic statement: https://github.com/NeuroML/pyNeuroML/blob/development/pyneuroml/pynml.py#L1592

This statement requires the LEMS file to be on the Python path and more specifically in the current directory. This is surprising because this is atypical, and not required to execute LEMS files with pyNeuroML itself. Managing this is also complicated by LEMS files referencing other files.

A more flexible option to dynamically import modules is to use the importlib module. This would also enable this method to work on LEMS files whose names wouldn't be names of valid python modules (e.g., names with dashes).

Ideally, this method would also not rely on the extension of the LEMS file being .xml, and allow other extensions.

jonrkarr commented 2 years ago

I managed to get this to work, but it requires an unexpected amount of hacking beyond what's required to run simulations with jNeuroML: