def install(version): if not NeuronEngine.is_installed(None): NeuronEngine.install(None) inform("%s installed NEURON..." % PyNNNRNEngine.name, indent=2, verbosity =1) if not PyNNEngine.is_installed(None): PyNNEngine.install(None) inform("%s installed PyNN..." % PyNNNRNEngine.name, indent=2, verbosity =1) PyNNNRNEngine.path = PyNNEngine.path + \ ":" + NeuronEngine.path PyNNNRNEngine.environment_vars = {} PyNNNRNEngine.environment_vars.update( PyNNEngine.environment_vars) PyNNNRNEngine.environment_vars.update( NeuronEngine.environment_vars) inform("PATH: " + PyNNNRNEngine.path, indent=2, verbosity =1) inform("Env vars: %s" % PyNNNRNEngine.environment_vars, indent=2, verbosity =1) pynn_loc = sp.check_output(['python -c "import pyNN,os; print(os.path.dirname(pyNN.__file__))"'], shell=True,stderr=sp.STDOUT).strip() pynn_mod_dir = '%s/neuron/nmodl/'%pynn_loc inform("Attempting to compile PyNN mod files for standard models in %s..."%pynn_mod_dir, indent=2, verbosity =1) print(check_output(['ls', pynn_mod_dir], cwd=pynn_mod_dir)) environment_vars, path = NeuronEngine.get_nrn_environment() inform("Using NEURON with env %s at %s..."%(environment_vars, path), indent=2, verbosity =1) print(check_output([environment_vars['NEURON_HOME']+'/bin/nrnivmodl'], cwd=pynn_mod_dir))
def install(version): if not JNeuroMLEngine.is_installed(None): JNeuroMLEngine.install(None) if not NeuronEngine.is_installed(None): NeuronEngine.install(None) JNeuroMLNRNEngine.get_jnmlnrnenv()
def install(version): if not NeuronEngine.is_installed(None): NeuronEngine.install(version) # interpret version as version of NEURON! inform("%s installed NEURON..." % PyNRNEngine.name, indent=2, verbosity =1) environment_vars_nrn, path_nrn = NeuronEngine.get_nrn_environment() PyNRNEngine.path = path_nrn PyNRNEngine.environment_vars = {} PyNRNEngine.environment_vars.update(environment_vars_nrn) inform("PATH: " + PyNRNEngine.path, indent=2, verbosity =1) inform("Env vars: %s" % PyNRNEngine.environment_vars, indent=2, verbosity =1)
def is_installed(version): if is_verbose(): inform("Checking whether %s is installed..." % JNeuroMLNRNEngine.name, indent=1) return JNeuroMLEngine.is_installed(None) and NeuronEngine.is_installed( None)
def install(version): if not JNeuroMLEngine.is_installed(None): JNeuroMLEngine.install(None) inform("%s installed JNeuroML..." % JNeuroMLNetPyNEEngine.name, indent=2, verbosity=1) if not NetPyNEEngine.is_installed(None): NetPyNEEngine.install(None) inform("%s installed NetPyNE (& NEURON)..." % JNeuroMLNetPyNEEngine.name, indent=2, verbosity=1) environment_vars_nrn, path_nrn = NeuronEngine.get_nrn_environment() JNeuroMLNetPyNEEngine.path = JNeuroMLEngine.path + ":" + path_nrn JNeuroMLNetPyNEEngine.environment_vars = {} JNeuroMLNetPyNEEngine.environment_vars.update( JNeuroMLEngine.environment_vars) JNeuroMLNetPyNEEngine.environment_vars.update( NetPyNEEngine.environment_vars) JNeuroMLNetPyNEEngine.environment_vars.update(environment_vars_nrn) inform("PATH: " + JNeuroMLNetPyNEEngine.path) inform("Env vars: %s" % JNeuroMLNetPyNEEngine.environment_vars)
def run(self): try: self.stdout = NeuronEngine.compile_modfiles(self.modelpath) except sp.CalledProcessError as err: self.stderr = err.output self.returncode = err.returncode inform('Error compiling modfiles:', self.stderr, indent=2) with working_dir(dirname(self.modelpath)): inform("Running %s on %s..." % (self.name, self.modelpath), indent=1) p = sp.Popen(['nrniv', '-python', self.modelpath, '-nogui'], stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) cmd = '''\ %s ''' % ('\n'.join(self.extra_pars)) stdout, stderr = p.communicate(dedent(cmd)) # with open('/tmp/omv_test.nrn.stdout', 'w') as f: # f.write(stdout) self.stdout = stdout self.stderr = stderr inform("OUT: ", stdout, verbosity=1, indent=2) inform("ERR: ", stderr, verbosity=1, indent=2) inform("returncode: ", p.returncode, verbosity=1, indent=2) self.returncode = p.returncode if self.returncode is not 0: raise EngineExecutionError
def is_installed(version): if is_verbose(): inform("Checking whether %s is installed correctly..." % PyNNNRNEngine.name, indent=1) installed = PyNNEngine.is_installed(None) and NeuronEngine.is_installed(None) return installed
def run(self): try: self.stdout = NeuronEngine.compile_modfiles(self.modelpath) except sp.CalledProcessError as err: self.stderr = err.output self.returncode = err.returncode inform('Error compiling modfiles:', self.stderr, indent=2) try: inform("Running file %s with %s" % (trim_path(self.modelpath), self.name), indent=1) self.stdout = check_output(['python', self.modelpath, 'neuron'], cwd=os.path.dirname(self.modelpath)) self.returncode = 0 except sp.CalledProcessError as err: self.returncode = err.returncode self.stdout = err.output raise EngineExecutionError except Exception as err: inform("Another error with running %s: " % self.name, err, indent=1) self.returncode = -1 self.stdout = "???"
def run(self): try: self.stdout = NeuronEngine.compile_modfiles(self.modelpath) except sp.CalledProcessError as err: self.stderr = err.output self.returncode = err.returncode inform('Error compiling modfiles:', self.stderr, indent=2) with working_dir(dirname(self.modelpath)): inform("Running %s on %s..." % (self.name, self.modelpath), indent=1) p = sp.Popen(['nrniv', '-python', self.modelpath, '-nogui'], stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) cmd = '''\ %s ''' % ('\n'.join(self.extra_pars)) if sys.version_info[0]==3: c = dedent(cmd).encode() else: c = dedent(cmd) stdout, stderr = p.communicate(c) # with open('/tmp/omv_test.nrn.stdout', 'w') as f: # f.write(stdout) self.stdout = str(stdout.decode()) self.stderr = str(stderr.decode()) inform("OUT: %s"% self.stdout, verbosity=1, indent=2) inform("ERR: %s"% self.stderr, verbosity=1, indent=2) inform("returncode: [%s]"% p.returncode, verbosity=1, indent=2) self.returncode = p.returncode if self.returncode != 0: raise EngineExecutionError
def install(version): if not JNeuroMLEngine.is_installed(None): JNeuroMLEngine.install(None) if not NeuronEngine.is_installed(None): NeuronEngine.install(None) environment_vars_nrn, path_nrn = NeuronEngine.get_nrn_environment() JNeuroMLNRNEngine.path = JNeuroMLEngine.path + \ ":" + path_nrn JNeuroMLNRNEngine.environment_vars = {} JNeuroMLNRNEngine.environment_vars.update( JNeuroMLEngine.environment_vars) JNeuroMLNRNEngine.environment_vars.update(environment_vars_nrn) inform("PATH: " + JNeuroMLNRNEngine.path) inform("Env vars: %s" % JNeuroMLNRNEngine.environment_vars)
def install(version): if not JNeuroMLEngine.is_installed(None): JNeuroMLEngine.install(None) if not NeuronEngine.is_installed(None): NeuronEngine.install(None) environment_vars_nrn, path_nrn = NeuronEngine.get_nrn_environment() JNeuroMLNRNEngine.path = JNeuroMLEngine.path + \ ":" + path_nrn JNeuroMLNRNEngine.environment_vars = {} JNeuroMLNRNEngine.environment_vars.update( JNeuroMLEngine.environment_vars) JNeuroMLNRNEngine.environment_vars.update( environment_vars_nrn) inform("PATH: " + JNeuroMLNRNEngine.path) inform("Env vars: %s" % JNeuroMLNRNEngine.environment_vars)
def is_installed(version): if is_verbose(): inform("Checking whether %s is installed correctly..." % PyNNNRNEngine.name, indent=1) installed = PyNNEngine.is_installed( None) and NeuronEngine.is_installed(None) return installed
def install(version): if not NeuronEngine.is_installed(None): NeuronEngine.install(None) inform("%s installed NEURON..." % PyNNNRNEngine.name, indent=2, verbosity=1) if not PyNNEngine.is_installed(None): PyNNEngine.install(None) inform("%s installed PyNN..." % PyNNNRNEngine.name, indent=2, verbosity=1) PyNNNRNEngine.path = PyNNEngine.path + \ ":" + NeuronEngine.path PyNNNRNEngine.environment_vars = {} PyNNNRNEngine.environment_vars.update(PyNNEngine.environment_vars) PyNNNRNEngine.environment_vars.update(NeuronEngine.environment_vars) inform("PATH: " + PyNNNRNEngine.path, indent=2, verbosity=1) inform("Env vars: %s" % PyNNNRNEngine.environment_vars, indent=2, verbosity=1) import pyNN pynn_mod_dir = os.path.dirname(pyNN.__file__) + '/neuron/nmodl/' inform( "Attempting to compile PyNN mod files for standard models in %s..." % pynn_mod_dir, indent=2, verbosity=1) print(check_output(['ls', pynn_mod_dir], cwd=pynn_mod_dir)) environment_vars, path = NeuronEngine.get_nrn_environment() inform("Using NEURON with env %s at %s..." % (environment_vars, path), indent=2, verbosity=1) print( check_output([environment_vars['NEURON_HOME'] + '/bin/nrnivmodl'], cwd=pynn_mod_dir))
def install(version): if not JNeuroMLEngine.is_installed(None): JNeuroMLEngine.install(None) inform("%s installed JNeuroML..." % JNeuroMLNetPyNEEngine.name, indent=2, verbosity =1) if not NetPyNEEngine.is_installed(None): NetPyNEEngine.install(None) inform("%s installed NetPyNE (& NEURON)..." % JNeuroMLNetPyNEEngine.name, indent=2, verbosity =1) environment_vars_nrn, path_nrn = NeuronEngine.get_nrn_environment() JNeuroMLNetPyNEEngine.path = JNeuroMLEngine.path+":"+path_nrn JNeuroMLNetPyNEEngine.environment_vars = {} JNeuroMLNetPyNEEngine.environment_vars.update(JNeuroMLEngine.environment_vars) JNeuroMLNetPyNEEngine.environment_vars.update(NetPyNEEngine.environment_vars) JNeuroMLNetPyNEEngine.environment_vars.update(environment_vars_nrn) inform("PATH: " + JNeuroMLNetPyNEEngine.path) inform("Env vars: %s" % JNeuroMLNetPyNEEngine.environment_vars)
def get_jnmlnrnenv(): environment_vars_nrn, path_nrn = NeuronEngine.get_nrn_environment() JNeuroMLNRNEngine.path = JNeuroMLEngine.path + \ ":" + path_nrn JNeuroMLNRNEngine.environment_vars = {} JNeuroMLNRNEngine.environment_vars.update( JNeuroMLEngine.environment_vars) JNeuroMLNRNEngine.environment_vars.update(environment_vars_nrn) JNeuroMLNRNEngine.environment_vars.update( JNeuroMLEngine.get_environment()) inform("PATH: " + JNeuroMLNRNEngine.path) inform("Env vars: %s" % JNeuroMLNRNEngine.environment_vars) del JNeuroMLNRNEngine.environment_vars['PYTHONPATH'] return JNeuroMLNRNEngine.environment_vars
def run(self): try: self.stdout = NeuronEngine.compile_modfiles(self.modelpath) except sp.CalledProcessError as err: self.stderr = err.output self.returncode = err.returncode inform('Error compiling modfiles:', self.stderr, indent=2) try: inform("Running file %s with %s" % (trim_path(self.modelpath), self.name), indent=1) self.stdout = check_output(['python', self.modelpath, 'neuron'], cwd=os.path.dirname(self.modelpath)) self.returncode = 0 except sp.CalledProcessError as err: self.returncode = err.returncode self.stdout = err.output raise EngineExecutionError except Exception as err: inform("Another error with running %s: "%self.name, err, indent=1) self.returncode = -1 self.stdout = "???"
def is_installed(version): if is_verbose(): inform("Checking whether %s is installed..." % JNeuroMLNRNEngine.name, indent=1) return JNeuroMLEngine.is_installed(None) and NeuronEngine.is_installed(None)
def main(): arguments = docopt(__doc__, version='OpenSourceBrain Model Validation %s'%version) set_env_vars() if arguments['--verbose']: set_verbosity(1) if arguments['test']: try: test_one(arguments['<testMe.omt>']) except AssertionError: inform("Failed due to non passing tests") exit(1) elif arguments['all']: try: if platform.python_version_tuple()[0]=='3': inform("Python 3. Ignoring tests for non Py3 compatible engines: %s"%arguments['--ignore-non-py3']) test_all(only_this_engine=arguments['--engine'], ignore_non_py3=arguments['--ignore-non-py3']) except AssertionError: inform("Failed due to non passing tests") exit(1) # Includes *.omt_, i.e. temporary test files elif arguments['all_']: try: test_all(only_this_engine=arguments['--engine'],include_temp_tests=True, ignore_non_py3=arguments['--ignore-non-py3']) except AssertionError: inform("Failed due to non passing tests") exit(1) elif arguments['find']: try: test_all(do_not_run=True) except AssertionError: inform("Failed due to non passing tests") exit(1) elif arguments['validate-mep']: validate_mep.validate(arguments['<mepfile>']) elif arguments['validate-omt']: inform('OMT validation not implemented yet!') exit(1) elif arguments['install']: set_verbosity(1) eng = arguments['<engine>'] engine_version=None if ':' in eng: ee = eng.split(':') eng = ee[0] engine_version = ee[1] inform('Engine %s version %s will be used...'%(eng, engine_version)) else: inform('Engine %s, default version will be used...'%(eng)) if eng.lower() not in [e.lower() for e in OMVEngines]: inform('Engine ' + eng + ' unknown!') else: inform('Trying to install: %s'% eng) already_installed = False if eng.lower() == 'NEURON'.lower(): from omv.engines.neuron_ import NeuronEngine if not NeuronEngine.is_installed(None): from omv.engines.getnrn import install_neuron install_neuron(engine_version) else: already_installed = True elif eng.lower() == 'PyNEURON'.lower(): from omv.engines.pyneuron import PyNRNEngine if not PyNRNEngine.is_installed(None): from omv.engines.getnrn import install_neuron install_neuron(engine_version) else: already_installed = True elif eng.lower() == 'jLEMS'.lower(): from omv.engines.jlems import JLemsEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getjlems import install_jlems install_jlems() elif eng.lower() == 'jNeuroML'.lower(): from omv.engines.jneuroml import JNeuroMLEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getjnml import install_jnml install_jnml() elif eng.lower() == 'neuroConstruct' or eng == 'Py_neuroConstruct'.lower(): from omv.engines.pyneuroconstruct import PyneuroConstructEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getneuroconstruct import install_neuroconstruct install_neuroconstruct() elif eng.lower() == 'pyNeuroML'.lower(): from omv.engines.pyneuroml_ import PyNeuroMLEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getpyneuroml import install_pynml install_pynml() elif eng.lower() == 'PyLEMS_NeuroML2'.lower(): from omv.engines.getpylems import install_pylems install_pylems() from omv.engines.getnml2 import install_nml2 install_nml2() elif eng.lower() == 'genesis'.lower(): from omv.engines.getgenesis import install_genesis install_genesis() elif eng.lower() == 'Moose'.lower(): from omv.engines.getmoose import install_moose install_moose() elif eng.lower() == 'NetPyNE'.lower(): from omv.engines.getnetpyne import install_netpyne install_netpyne() elif eng.lower() == 'Brian'.lower(): from omv.engines.getbrian1 import install_brian install_brian() elif eng.lower() == 'Brian2'.lower(): from omv.engines.getbrian2 import install_brian2 install_brian2(engine_version) elif eng.lower() == 'NEST'.lower(): from omv.engines.getnest import install_nest install_nest(engine_version) elif eng.lower() == 'PyNN'.lower(): from omv.engines.getpynn import install_pynn install_pynn() else: inform('Code not implemented yet for installing %s using: omv install! Try running a test using this engine.'%eng) exit(1) if already_installed: inform('Engine %s was already installed'%eng) elif arguments['list-engines'] or arguments['list']: inform('OMV is checking which engines are currently installed...') set_verbosity(0) engines = sorted(OMVEngines.keys()) installed = {} for engine in engines: installed[engine] = OMVEngines[engine].is_installed('') inform('') inform('The following engines are currently supported by OMV:') inform('') for engine in engines: py3_info = '' if OMVEngines[engine].python3_compatible else '; non Py3 compatible' inform(' %s%s(installed: %s%s)'%(engine, ' '*(30-len(engine)), installed[engine], py3_info)) inform('') if arguments['--verbose']: inform('Additional Python (v%s) packages:'%platform.python_version()) inform('') for m in ['matplotlib','numpy','pandas','scipy','sympy','tables','neo','lazyarray','pyelectro','pyneuroml','neuroml']: installed_ver = False try: exec('import %s'%m) installed_ver = eval('%s.__version__'%m) except: pass inform(' %s%s(installed: %s)'%(m, ' '*(30-len(m)), installed_ver)) inform('') elif arguments['autogen']: inform('Automatically generating model validation files') dry = arguments['--dryrun'] auto = arguments['-y'] autogen(auto, dry)
def main(): arguments = docopt(__doc__, version='OpenSourceBrain Model Validation %s' % version) set_env_vars() if arguments['--verbose']: set_verbosity(1) if arguments['test']: try: test_one(arguments['<testMe.omt>']) except AssertionError: inform("Failed due to non passing tests") exit(1) elif arguments['all']: try: if platform.python_version_tuple()[0] == '3': inform( "Python 3. Ignoring tests for non Py3 compatible engines: %s" % arguments['--ignore-non-py3']) test_all(only_this_engine=arguments['--engine'], ignore_non_py3=arguments['--ignore-non-py3']) except AssertionError: inform("Failed due to non passing tests") exit(1) # Includes *.omt_, i.e. temporary test files elif arguments['all_']: try: test_all(only_this_engine=arguments['--engine'], include_temp_tests=True, ignore_non_py3=arguments['--ignore-non-py3']) except AssertionError: inform("Failed due to non passing tests") exit(1) elif arguments['find']: try: test_all(do_not_run=True) except AssertionError: inform("Failed due to non passing tests") exit(1) elif arguments['validate-mep']: validate_mep.validate(arguments['<mepfile>']) elif arguments['validate-omt']: inform('OMT validation not implemented yet!') exit(1) elif arguments['install']: set_verbosity(1) eng = arguments['<engine>'] engine_version = None if ':' in eng: ee = eng.split(':') eng = ee[0] engine_version = ee[1] inform('Engine %s version %s will be used...' % (eng, engine_version)) else: inform('Engine %s, default version will be used...' % (eng)) if eng.lower() not in [e.lower() for e in OMVEngines]: inform('Engine ' + eng + ' unknown!') else: inform('Trying to install: %s' % eng) already_installed = False if eng.lower() == 'NEURON'.lower(): from omv.engines.neuron_ import NeuronEngine if not NeuronEngine.is_installed(None): from omv.engines.getnrn import install_neuron install_neuron(engine_version) else: already_installed = True elif eng.lower() == 'PyNEURON'.lower(): from omv.engines.pyneuron import PyNRNEngine if not PyNRNEngine.is_installed(None): from omv.engines.getnrn import install_neuron install_neuron(engine_version) else: already_installed = True elif eng.lower() == 'jLEMS'.lower(): from omv.engines.jlems import JLemsEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getjlems import install_jlems install_jlems() elif eng.lower() == 'jNeuroML'.lower(): from omv.engines.jneuroml import JNeuroMLEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getjnml import install_jnml install_jnml() elif eng.lower( ) == 'neuroConstruct' or eng == 'Py_neuroConstruct'.lower(): from omv.engines.pyneuroconstruct import PyneuroConstructEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getneuroconstruct import install_neuroconstruct install_neuroconstruct() elif eng.lower() == 'pyNeuroML'.lower(): from omv.engines.pyneuroml_ import PyNeuroMLEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getpyneuroml import install_pynml install_pynml() elif eng.lower() == 'PyLEMS'.lower(): from omv.engines.pylems import PyLemsEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getpylems import install_pylems install_pylems() elif eng.lower() == 'PyLEMS_NeuroML2'.lower(): pylems_already_installed = False nml2_already_installed = False from omv.engines.pylems import PyLemsEngine as ee if ee.is_installed(None): pylems_already_installed = True else: from omv.engines.getpylems import install_pylems install_pylems() from omv.engines.getnml2 import install_nml2, is_nml2_installed if is_nml2_installed(): nml2_already_installed = True else: install_nml2() already_installed = nml2_already_installed and pylems_already_installed elif eng.lower() == 'Py_neuroConstruct'.lower(): from omv.engines.pyneuroconstruct import PyneuroConstructEngine as ee if ee.is_installed(None): already_installed = True else: from omv.engines.getneuroconstruct import install_neuroconstruct install_neuroconstruct() elif eng.lower() == 'genesis'.lower(): from omv.engines.getgenesis import install_genesis install_genesis() elif eng.lower() == 'Moose'.lower(): from omv.engines.getmoose import install_moose install_moose() elif eng.lower() == 'NetPyNE'.lower(): from omv.engines.getnetpyne import install_netpyne install_netpyne() elif eng.lower() == 'Brian'.lower(): from omv.engines.getbrian1 import install_brian install_brian() elif eng.lower() == 'Brian2'.lower(): from omv.engines.getbrian2 import install_brian2 install_brian2(engine_version) elif eng.lower() == 'NEST'.lower(): from omv.engines.getnest import install_nest install_nest(engine_version) elif eng.lower() == 'PyNEST'.lower(): from omv.engines.getnest import install_nest install_nest(engine_version) elif eng.lower() == 'PyNN'.lower(): from omv.engines.getpynn import install_pynn install_pynn() else: inform( 'Code not implemented yet for installing %s using: omv install! Try running a test using this engine.' % eng) exit(1) if already_installed: inform('Engine %s was already installed' % eng) elif arguments['list-engines'] or arguments['list']: inform('OMV is checking which engines are currently installed...') set_verbosity(0) engines = sorted(OMVEngines.keys()) installed = {} for engine in engines: installed[engine] = OMVEngines[engine].is_installed('') inform('') inform('The following engines are currently supported by OMV (v%s):' % version) inform('') for engine in engines: py3_info = '' if OMVEngines[ engine].python3_compatible else '; non Py3 compatible' inform(' %s%s(installed: %s%s)' % (engine, ' ' * (30 - len(engine)), installed[engine], py3_info)) inform('') if arguments['--verbose']: inform('Additional Python (v%s) packages:' % platform.python_version()) inform('') for m in [ 'matplotlib', 'numpy', 'pandas', 'scipy', 'sympy', 'tables', 'h5py', 'neo', 'lazyarray', 'pyelectro', 'pyneuroml', 'neuroml', 'neuromllite' ]: installed_ver = False try: exec('import %s' % m) installed_ver = 'v%s' % eval('%s.__version__' % m) except: pass inform(' %s%s(installed: %s)' % (m, ' ' * (30 - len(m)), installed_ver)) inform('') elif arguments['autogen']: inform('Automatically generating model validation files') dry = arguments['--dryrun'] auto = arguments['-y'] autogen(auto, dry)