suny-downstate-medical-center / netpyne

A Python package to facilitate the development, parallel simulation, optimization and analysis of multiscale biological neuronal networks in NEURON.
http://www.netpyne.org
MIT License
144 stars 135 forks source link

Wrapper to run the script from index.npjson #689

Closed vvbragin closed 1 year ago

salvadord commented 2 years ago

Valery: "The idea, as we discussed, is to keep init.py as clear as possible, and not confusing for users. But on the other hand, the code in this script (namely, the way we import netParams and cfg) should be sort of universal, to be run both on it own and from that wrapper around index file. I was trying to keep regular import statements in it, and with help of some tricks override those modules when being run from wrapper. But I couldn't make it work (unless the workarounds getting too much hacky..), so I propose to use sys.argv to distinguish between these cases (run init.py on its own vs run from wrapper). And depending on it - either import cfg and netParams, or load them from index. Of course it makes init.py a little bit dirtier, but still intuitive, as for me"

salvadord commented 2 years ago

Thanks for this solution, Valery, I think it is quite reasonable. As you mention, it’s not ideal to add that extra code to init.py since it means all init.py will need to be modified accordingly, but that may be inevitable. Also it seems to me the file format is somehow overcomplicating things: First, runFromIndex() checks the index file to find and run init.py; and then init.py checks again the index file (and needs to know the name of the index file!) to load cfg and netParams Anyway, I’ll bring it up in the next GUI meeting, see what the others think.

@pgleeson @tarelli @ddelpiano for context, we were trying to figure out how regular programmatic users would use the new file format to run netpyne simulations.

vvbragin commented 2 years ago

Thanks for you feedback, Salvador. Based on it, I've just added demonstration of another option. It uses existing method readCmdLineArgs(), which is also consistent with batch simulation cases