OSBModelValidation 0.2.18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- OSBModelValidation-0.2.18.dist-info/METADATA +184 -0
- OSBModelValidation-0.2.18.dist-info/RECORD +98 -0
- OSBModelValidation-0.2.18.dist-info/WHEEL +5 -0
- OSBModelValidation-0.2.18.dist-info/entry_points.txt +2 -0
- OSBModelValidation-0.2.18.dist-info/top_level.txt +1 -0
- omv/__init__.py +8 -0
- omv/analyzers/__init__.py +21 -0
- omv/analyzers/activation.py +24 -0
- omv/analyzers/analyzer.py +80 -0
- omv/analyzers/dryrun.py +13 -0
- omv/analyzers/input_resistance.py +47 -0
- omv/analyzers/morphology.py +16 -0
- omv/analyzers/rates.py +97 -0
- omv/analyzers/resting.py +37 -0
- omv/analyzers/spikes.py +113 -0
- omv/analyzers/temperature.py +12 -0
- omv/analyzers/timeseries.py +57 -0
- omv/analyzers/utils/__init__.py +0 -0
- omv/analyzers/utils/filenode.py +73 -0
- omv/analyzers/utils/timeseries.py +293 -0
- omv/autogen.py +106 -0
- omv/common/__init__.py +0 -0
- omv/common/inout.py +154 -0
- omv/engines/__init__.py +53 -0
- omv/engines/arbor_.py +57 -0
- omv/engines/brian1.py +59 -0
- omv/engines/brian2_.py +57 -0
- omv/engines/eden_.py +63 -0
- omv/engines/engine.py +111 -0
- omv/engines/genesis.py +86 -0
- omv/engines/getarbor.py +15 -0
- omv/engines/getbrian1.py +42 -0
- omv/engines/getbrian2.py +17 -0
- omv/engines/geteden.py +17 -0
- omv/engines/getgenesis.py +56 -0
- omv/engines/getjlems.py +20 -0
- omv/engines/getjnml.py +48 -0
- omv/engines/getlibsbml.py +13 -0
- omv/engines/getmoose.py +15 -0
- omv/engines/getnest.py +62 -0
- omv/engines/getnetpyne.py +52 -0
- omv/engines/getneuroconstruct.py +31 -0
- omv/engines/getnml2.py +26 -0
- omv/engines/getnrn.py +60 -0
- omv/engines/getoctave.py +11 -0
- omv/engines/getpylems.py +13 -0
- omv/engines/getpyneuroml.py +14 -0
- omv/engines/getpynn.py +40 -0
- omv/engines/jlems.py +48 -0
- omv/engines/jneuroml.py +101 -0
- omv/engines/jneuromlbrian.py +65 -0
- omv/engines/jneuromlbrian2.py +61 -0
- omv/engines/jneuromleden.py +61 -0
- omv/engines/jneuromlmoose.py +63 -0
- omv/engines/jneuromlnetpyne.py +73 -0
- omv/engines/jneuromlnetpyne_np2.py +45 -0
- omv/engines/jneuromlnetpyne_np4.py +45 -0
- omv/engines/jneuromlnrn.py +78 -0
- omv/engines/jneuromlpynnnrn.py +75 -0
- omv/engines/jneuromlvalidate.py +62 -0
- omv/engines/jneuromlvalidatev1.py +58 -0
- omv/engines/moose_.py +86 -0
- omv/engines/nestsli.py +84 -0
- omv/engines/netpyne_.py +120 -0
- omv/engines/netpyne__np2.py +47 -0
- omv/engines/netpyne__np4.py +47 -0
- omv/engines/neuron_.py +205 -0
- omv/engines/octave.py +51 -0
- omv/engines/pylems.py +57 -0
- omv/engines/pylemsnml2.py +59 -0
- omv/engines/pynest.py +111 -0
- omv/engines/pyneuroconstruct.py +67 -0
- omv/engines/pyneuroml_.py +55 -0
- omv/engines/pyneuromlvalidatesbml.py +83 -0
- omv/engines/pyneuron.py +94 -0
- omv/engines/pynn.py +63 -0
- omv/engines/pynnbrian1.py +59 -0
- omv/engines/pynnbrian2.py +60 -0
- omv/engines/pynnnest.py +56 -0
- omv/engines/pynnneuroml.py +57 -0
- omv/engines/pynnneuron.py +94 -0
- omv/engines/utils/__init__.py +21 -0
- omv/engines/utils/genesis_utils.g +26 -0
- omv/engines/utils/wdir.py +15 -0
- omv/experiment.py +18 -0
- omv/find_tests.py +126 -0
- omv/omt_mep_parser.py +59 -0
- omv/omv_util.py +439 -0
- omv/parse_omt.py +118 -0
- omv/tally.py +112 -0
- omv/test/__init__.py +0 -0
- omv/test/test_rates.py +38 -0
- omv/test/test_types.py +29 -0
- omv/validation/__init__.py +0 -0
- omv/validation/rx_validator.py +35 -0
- omv/validation/utils.py +51 -0
- omv/validation/validate.py +53 -0
- omv/validation/validate_mep.py +15 -0
omv/engines/neuron_.py
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
from glob import glob
|
|
4
|
+
import platform
|
|
5
|
+
import subprocess as sp
|
|
6
|
+
from textwrap import dedent
|
|
7
|
+
from omv.engines.utils.wdir import working_dir
|
|
8
|
+
from omv.engines.engine import OMVEngine, EngineExecutionError
|
|
9
|
+
from os.path import dirname
|
|
10
|
+
from omv.common.inout import check_output, inform, is_verbose
|
|
11
|
+
from sysconfig import get_paths
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class NeuronEngine(OMVEngine):
|
|
15
|
+
name = "NEURON"
|
|
16
|
+
|
|
17
|
+
def __init__(self, target, do_not_check_install=False, engine_version=None):
|
|
18
|
+
super(NeuronEngine, self).__init__(target, do_not_check_install, engine_version)
|
|
19
|
+
|
|
20
|
+
inform(
|
|
21
|
+
"Checking whether %s (v %s) is already installed..."
|
|
22
|
+
% (self.name, engine_version),
|
|
23
|
+
indent=1,
|
|
24
|
+
verbosity=1,
|
|
25
|
+
)
|
|
26
|
+
if not self.is_installed():
|
|
27
|
+
try:
|
|
28
|
+
self.install(engine_version)
|
|
29
|
+
except Exception as e:
|
|
30
|
+
inform(e)
|
|
31
|
+
raise (EngineInstallationError(e))
|
|
32
|
+
|
|
33
|
+
self.environment_vars, self.path = NeuronEngine.get_nrn_environment()
|
|
34
|
+
self.set_environment()
|
|
35
|
+
self.set_path()
|
|
36
|
+
|
|
37
|
+
@staticmethod
|
|
38
|
+
def get_nrn_environment():
|
|
39
|
+
home = os.environ["HOME"]
|
|
40
|
+
arch = platform.machine()
|
|
41
|
+
pp = os.path.join(home, "local/lib/python/site-packages")
|
|
42
|
+
|
|
43
|
+
environment_vars = {"PYTHONPATH": pp}
|
|
44
|
+
|
|
45
|
+
if not "NEURON_HOME" in os.environ:
|
|
46
|
+
pip_install_dir1 = "/usr/local"
|
|
47
|
+
pip_install_nrniv1 = os.path.join(pip_install_dir1, "bin", "nrniv")
|
|
48
|
+
scripts_bin = get_paths()["scripts"]
|
|
49
|
+
pip_install_dir2 = scripts_bin[: scripts_bin.rfind("/")]
|
|
50
|
+
pip_install_nrniv2 = os.path.join(pip_install_dir2, "bin", "nrniv")
|
|
51
|
+
|
|
52
|
+
inform(
|
|
53
|
+
"Checking NEURON at: %s or %s (%s)"
|
|
54
|
+
% (pip_install_nrniv1, pip_install_nrniv2, get_paths()),
|
|
55
|
+
indent=1,
|
|
56
|
+
verbosity=1,
|
|
57
|
+
)
|
|
58
|
+
if os.path.isfile(pip_install_nrniv1):
|
|
59
|
+
environment_vars["NEURON_HOME"] = pip_install_dir1
|
|
60
|
+
path = os.path.join(pip_install_dir1, "bin")
|
|
61
|
+
elif os.path.isfile(pip_install_nrniv2):
|
|
62
|
+
environment_vars["NEURON_HOME"] = pip_install_dir2
|
|
63
|
+
path = os.path.join(pip_install_dir2, "bin")
|
|
64
|
+
else:
|
|
65
|
+
environment_vars["NEURON_HOME"] = os.path.join(
|
|
66
|
+
home, "neuron/nrn/", arch
|
|
67
|
+
)
|
|
68
|
+
path = os.path.join(home, "neuron/nrn/", arch, "bin")
|
|
69
|
+
else:
|
|
70
|
+
environment_vars["NEURON_HOME"] = os.environ["NEURON_HOME"]
|
|
71
|
+
path = os.path.join(os.environ["NEURON_HOME"], "bin")
|
|
72
|
+
|
|
73
|
+
inform(
|
|
74
|
+
"NEURON environment vars: %s, PATH: %s" % (environment_vars, path),
|
|
75
|
+
indent=1,
|
|
76
|
+
verbosity=1,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
return environment_vars, path
|
|
80
|
+
|
|
81
|
+
@staticmethod
|
|
82
|
+
def is_installed():
|
|
83
|
+
ret = True
|
|
84
|
+
if is_verbose():
|
|
85
|
+
inform("Checking whether %s is installed..." % NeuronEngine.name, indent=1)
|
|
86
|
+
try:
|
|
87
|
+
output = check_output(["nrniv", "--version"], verbosity=2)
|
|
88
|
+
if is_verbose():
|
|
89
|
+
inform(
|
|
90
|
+
"%s is installed; env: %s"
|
|
91
|
+
% (output.strip(), NeuronEngine.get_nrn_environment()),
|
|
92
|
+
indent=2,
|
|
93
|
+
)
|
|
94
|
+
ret = "v%s" % output.split()[3]
|
|
95
|
+
except OSError:
|
|
96
|
+
try:
|
|
97
|
+
environment_vars, path = NeuronEngine.get_nrn_environment()
|
|
98
|
+
if is_verbose():
|
|
99
|
+
inform(
|
|
100
|
+
"Testing NEURON with env: %s and path: %s"
|
|
101
|
+
% (environment_vars, path),
|
|
102
|
+
indent=2,
|
|
103
|
+
)
|
|
104
|
+
output = check_output([path + "/nrniv", "--version"], verbosity=3)
|
|
105
|
+
if is_verbose():
|
|
106
|
+
inform(
|
|
107
|
+
"%s was already installed (by OMV..?)" % output.strip(),
|
|
108
|
+
indent=2,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
ret = "v%s" % output.split()[3]
|
|
112
|
+
except OSError:
|
|
113
|
+
if is_verbose():
|
|
114
|
+
inform("NEURON not currently installed", indent=2)
|
|
115
|
+
ret = False
|
|
116
|
+
return ret
|
|
117
|
+
|
|
118
|
+
@classmethod
|
|
119
|
+
def install(cls, version):
|
|
120
|
+
from omv.engines.getnrn import install_neuron
|
|
121
|
+
|
|
122
|
+
inform("Will fetch and install the latest NEURON version", indent=2)
|
|
123
|
+
install_neuron(version)
|
|
124
|
+
|
|
125
|
+
cls.environment_vars, cls.path = NeuronEngine.get_nrn_environment()
|
|
126
|
+
|
|
127
|
+
@classmethod
|
|
128
|
+
def compile_modfiles(cls, modelpath):
|
|
129
|
+
with working_dir(dirname(modelpath)):
|
|
130
|
+
out = 0
|
|
131
|
+
if len(glob("*.mod")) > 0:
|
|
132
|
+
environment_vars, path = NeuronEngine.get_nrn_environment()
|
|
133
|
+
inform(
|
|
134
|
+
"Compiling all mod files in directory: %s" % dirname(modelpath),
|
|
135
|
+
indent=1,
|
|
136
|
+
)
|
|
137
|
+
out = check_output([path + "/nrnivmodl"])
|
|
138
|
+
inform(out, indent=2)
|
|
139
|
+
elif len(glob("modfiles/*.mod")) > 0:
|
|
140
|
+
environment_vars, path = NeuronEngine.get_nrn_environment()
|
|
141
|
+
mod_file_path = dirname(modelpath) + "/modfiles"
|
|
142
|
+
inform(
|
|
143
|
+
"Compiling all mod files in directory: %s" % mod_file_path, indent=1
|
|
144
|
+
)
|
|
145
|
+
out = check_output([path + "/nrnivmodl", "modfiles"])
|
|
146
|
+
inform(out, indent=2)
|
|
147
|
+
elif len(glob("mod_files/*.mod")) > 0:
|
|
148
|
+
environment_vars, path = NeuronEngine.get_nrn_environment()
|
|
149
|
+
mod_file_path = dirname(modelpath) + "/mod_files"
|
|
150
|
+
inform(
|
|
151
|
+
"Compiling all mod files in directory: %s" % mod_file_path, indent=1
|
|
152
|
+
)
|
|
153
|
+
out = check_output([path + "/nrnivmodl", "mod_files"])
|
|
154
|
+
inform(out, indent=2)
|
|
155
|
+
return out
|
|
156
|
+
|
|
157
|
+
def run(self):
|
|
158
|
+
try:
|
|
159
|
+
self.stdout = self.compile_modfiles(self.modelpath)
|
|
160
|
+
except sp.CalledProcessError as err:
|
|
161
|
+
self.stderr = err.output
|
|
162
|
+
self.returncode = err.returncode
|
|
163
|
+
inform("Error compiling modfiles:", self.stderr, indent=2)
|
|
164
|
+
|
|
165
|
+
with working_dir(dirname(self.modelpath)):
|
|
166
|
+
inform("Running %s on %s..." % (self.name, self.modelpath), indent=1)
|
|
167
|
+
p = sp.Popen(["nrniv"], stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE)
|
|
168
|
+
cmd = """\
|
|
169
|
+
load_file("noload.hoc")
|
|
170
|
+
//cvode_active(1)
|
|
171
|
+
load_file("%s")
|
|
172
|
+
%s
|
|
173
|
+
""" % (
|
|
174
|
+
self.modelpath,
|
|
175
|
+
"\n".join(self.extra_pars),
|
|
176
|
+
)
|
|
177
|
+
if sys.version_info[0] == 3:
|
|
178
|
+
c = dedent(cmd).encode()
|
|
179
|
+
else:
|
|
180
|
+
c = dedent(cmd)
|
|
181
|
+
stdout, stderr = p.communicate(c)
|
|
182
|
+
# with open('/tmp/omv_test.nrn.stdout', 'w') as f:
|
|
183
|
+
# f.write(stdout)
|
|
184
|
+
self.stdout = str(stdout.decode())
|
|
185
|
+
self.stderr = str(stderr.decode())
|
|
186
|
+
|
|
187
|
+
inform("OUT: %s" % self.stdout, verbosity=1, indent=2)
|
|
188
|
+
inform("ERR: %s" % self.stderr, verbosity=1, indent=2)
|
|
189
|
+
inform("returncode: [%s]" % p.returncode, verbosity=1, indent=2)
|
|
190
|
+
|
|
191
|
+
self.returncode = p.returncode
|
|
192
|
+
if self.returncode != 0:
|
|
193
|
+
raise EngineExecutionError
|
|
194
|
+
|
|
195
|
+
def build_query_string(self, name, cmd):
|
|
196
|
+
return '{{%s}{print "%s: ", %s}}' % (cmd, name, name)
|
|
197
|
+
|
|
198
|
+
def query_area(self, secname):
|
|
199
|
+
qname = "area_%s" % secname
|
|
200
|
+
qcmd = 'forsec "%s" {for (x,0) area_%s+=area(x)}' % (secname, secname)
|
|
201
|
+
name = self.register_query(qname, qcmd)
|
|
202
|
+
return name
|
|
203
|
+
|
|
204
|
+
def query_temperature(self):
|
|
205
|
+
return self.register_query("temperature", "temperature=celsius")
|
omv/engines/octave.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess as sp
|
|
3
|
+
|
|
4
|
+
from omv.common.inout import inform, trim_path, check_output, is_verbose
|
|
5
|
+
from omv.engines.engine import OMVEngine, EngineExecutionError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class OctaveEngine(OMVEngine):
|
|
9
|
+
name = "Octave"
|
|
10
|
+
|
|
11
|
+
@staticmethod
|
|
12
|
+
def is_installed():
|
|
13
|
+
ret = True
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
ret_str = check_output(["octave", "-v"], verbosity=1)
|
|
17
|
+
|
|
18
|
+
ret = "v%s" % str(ret_str).split()[3]
|
|
19
|
+
except OSError as err:
|
|
20
|
+
if is_verbose():
|
|
21
|
+
inform("Couldn't execute Octave!", err, indent=1)
|
|
22
|
+
ret = False
|
|
23
|
+
return ret
|
|
24
|
+
|
|
25
|
+
@staticmethod
|
|
26
|
+
def install(version):
|
|
27
|
+
from omv.engines.getoctave import install_octave
|
|
28
|
+
|
|
29
|
+
inform("Will fetch and install the latest Octave", indent=2)
|
|
30
|
+
install_octave()
|
|
31
|
+
inform("Done...", indent=2)
|
|
32
|
+
|
|
33
|
+
def run(self):
|
|
34
|
+
try:
|
|
35
|
+
inform(
|
|
36
|
+
"Running file %s with %s" % (trim_path(self.modelpath), self.name),
|
|
37
|
+
indent=1,
|
|
38
|
+
)
|
|
39
|
+
self.stdout = check_output(
|
|
40
|
+
["octave", "--no-window-system", "--silent", self.modelpath],
|
|
41
|
+
cwd=os.path.dirname(self.modelpath),
|
|
42
|
+
)
|
|
43
|
+
self.returncode = 0
|
|
44
|
+
except sp.CalledProcessError as err:
|
|
45
|
+
self.returncode = err.returncode
|
|
46
|
+
self.stdout = err.output
|
|
47
|
+
raise EngineExecutionError
|
|
48
|
+
except Exception as err:
|
|
49
|
+
inform("Another error with running %s: " % self.name, err, indent=1)
|
|
50
|
+
self.returncode = -1
|
|
51
|
+
self.stdout = "???"
|
omv/engines/pylems.py
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess as sp
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from omv.common.inout import inform, trim_path, check_output, is_verbose
|
|
6
|
+
from omv.engines.engine import OMVEngine, EngineExecutionError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PyLemsEngine(OMVEngine):
|
|
10
|
+
name = "PyLEMS"
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def is_installed():
|
|
14
|
+
ret = True
|
|
15
|
+
try:
|
|
16
|
+
import lems
|
|
17
|
+
|
|
18
|
+
ret = "v%s" % lems.__version__
|
|
19
|
+
inform("PyLEMS %s is correctly installed..." % ret, indent=2, verbosity=2)
|
|
20
|
+
|
|
21
|
+
except Exception as err:
|
|
22
|
+
if is_verbose():
|
|
23
|
+
inform("Couldn't execute/import PyLEMS: ", err, indent=1)
|
|
24
|
+
ret = False
|
|
25
|
+
return ret
|
|
26
|
+
|
|
27
|
+
@staticmethod
|
|
28
|
+
def install(version):
|
|
29
|
+
from omv.engines.getpylems import install_pylems
|
|
30
|
+
|
|
31
|
+
home = os.environ["HOME"]
|
|
32
|
+
p = os.path.join(home, "pylems")
|
|
33
|
+
PyLemsEngine.path = p
|
|
34
|
+
PyLemsEngine.environment_vars = {"PYLEMS_HOME": p}
|
|
35
|
+
inform("Will fetch and install the latest PyLEMS", indent=2)
|
|
36
|
+
install_pylems()
|
|
37
|
+
inform("Done...", indent=2)
|
|
38
|
+
|
|
39
|
+
def run(self):
|
|
40
|
+
try:
|
|
41
|
+
inform(
|
|
42
|
+
"Running file %s with %s" % (trim_path(self.modelpath), self.name),
|
|
43
|
+
indent=1,
|
|
44
|
+
)
|
|
45
|
+
self.stdout = check_output(
|
|
46
|
+
["pylems", self.modelpath, "-nogui"],
|
|
47
|
+
cwd=os.path.dirname(self.modelpath),
|
|
48
|
+
)
|
|
49
|
+
self.returncode = 0
|
|
50
|
+
except sp.CalledProcessError as err:
|
|
51
|
+
inform("Process error with %s: " % self.name, err, indent=1)
|
|
52
|
+
self.returncode = err.returncode
|
|
53
|
+
raise EngineExecutionError
|
|
54
|
+
except Exception as err:
|
|
55
|
+
inform("Another error with running %s: " % self.name, err, indent=1)
|
|
56
|
+
self.returncode = -1
|
|
57
|
+
self.stdout = "???"
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess as sp
|
|
3
|
+
|
|
4
|
+
from omv.engines.pylems import PyLemsEngine
|
|
5
|
+
from omv.engines.getnml2 import default_nml2_dir, install_nml2
|
|
6
|
+
|
|
7
|
+
from omv.common.inout import inform, trim_path, is_verbose
|
|
8
|
+
from omv.engines.engine import OMVEngine, EngineExecutionError
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PyLemsNeuroML2Engine(OMVEngine):
|
|
12
|
+
name = "PyLEMS_NeuroML2"
|
|
13
|
+
|
|
14
|
+
@staticmethod
|
|
15
|
+
def is_installed():
|
|
16
|
+
if is_verbose():
|
|
17
|
+
inform(
|
|
18
|
+
"Checking whether %s is installed..." % PyLemsNeuroML2Engine.name,
|
|
19
|
+
indent=1,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
nml2_installed = os.path.isdir(default_nml2_dir)
|
|
23
|
+
|
|
24
|
+
if nml2_installed and PyLemsEngine.is_installed():
|
|
25
|
+
return PyLemsEngine.is_installed()
|
|
26
|
+
else:
|
|
27
|
+
return False
|
|
28
|
+
|
|
29
|
+
def install(self, version):
|
|
30
|
+
if not PyLemsEngine.is_installed():
|
|
31
|
+
PyLemsEngine.install(None)
|
|
32
|
+
if not os.path.isdir(default_nml2_dir):
|
|
33
|
+
install_nml2()
|
|
34
|
+
|
|
35
|
+
inform("Finished installation of %s..." % self.name, indent=2)
|
|
36
|
+
|
|
37
|
+
def run(self):
|
|
38
|
+
try:
|
|
39
|
+
nml2_comp_type_def_dir = os.path.join(default_nml2_dir, "NeuroML2CoreTypes")
|
|
40
|
+
|
|
41
|
+
inform(
|
|
42
|
+
"Running file %s with %s, including path: %s"
|
|
43
|
+
% (trim_path(self.modelpath), self.name, nml2_comp_type_def_dir),
|
|
44
|
+
indent=1,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
self.stdout = sp.check_output(
|
|
48
|
+
["pylems", "-I", nml2_comp_type_def_dir, self.modelpath, "-nogui"],
|
|
49
|
+
cwd=os.path.dirname(self.modelpath),
|
|
50
|
+
)
|
|
51
|
+
self.returncode = 0
|
|
52
|
+
except sp.CalledProcessError as err:
|
|
53
|
+
self.returncode = err.returncode
|
|
54
|
+
self.stdout = err.output
|
|
55
|
+
raise EngineExecutionError
|
|
56
|
+
except Exception as err:
|
|
57
|
+
inform("Another error with running %s: " % self.name, err, indent=1)
|
|
58
|
+
self.returncode = -1
|
|
59
|
+
self.stdout = "???"
|
omv/engines/pynest.py
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess as sp
|
|
3
|
+
|
|
4
|
+
from omv.common.inout import inform, trim_path, check_output, is_verbose
|
|
5
|
+
from omv.engines.engine import OMVEngine, EngineExecutionError
|
|
6
|
+
|
|
7
|
+
from omv.engines.nestsli import NestEngine
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PyNestEngine(OMVEngine):
|
|
12
|
+
name = "PyNEST"
|
|
13
|
+
|
|
14
|
+
@staticmethod
|
|
15
|
+
def is_installed():
|
|
16
|
+
PyNestEngine.environment_vars = NestEngine.get_nest_environment()
|
|
17
|
+
sys.path.append(PyNestEngine.environment_vars["PYTHONPATH"])
|
|
18
|
+
|
|
19
|
+
ret = True
|
|
20
|
+
try:
|
|
21
|
+
# print('PN1')
|
|
22
|
+
try:
|
|
23
|
+
# print('PN1a')
|
|
24
|
+
ret_str_cmd_line = check_output(
|
|
25
|
+
[
|
|
26
|
+
"python -c \"import nest; print(nest.__version__ if hasattr(nest,'__version__') else nest.version())\""
|
|
27
|
+
],
|
|
28
|
+
shell=True,
|
|
29
|
+
verbosity=2,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
# if is_verbose():
|
|
33
|
+
# inform("NEST cmd line test: <<<%s>>>" % (ret_str_cmd_line), indent=2)
|
|
34
|
+
ret_str = (
|
|
35
|
+
ret_str_cmd_line.split("Version: ")[1].split("Built:")[0].strip()
|
|
36
|
+
)
|
|
37
|
+
# print("ret_str: %s"%ret_str)
|
|
38
|
+
except Exception as e:
|
|
39
|
+
if is_verbose():
|
|
40
|
+
print("NEST installed check exception: %s" % e)
|
|
41
|
+
import nest
|
|
42
|
+
|
|
43
|
+
# print('PN2')
|
|
44
|
+
if hasattr(nest, "__version__"):
|
|
45
|
+
# print('PN3')
|
|
46
|
+
ret_str = nest.__version__
|
|
47
|
+
else:
|
|
48
|
+
# print('PN4')
|
|
49
|
+
ret_str = nest.version()
|
|
50
|
+
|
|
51
|
+
ret = len(ret_str) > 0
|
|
52
|
+
|
|
53
|
+
if ret:
|
|
54
|
+
ret_str = ret_str.strip().split("\n")[-1]
|
|
55
|
+
# print('NEST info: %s; <<%s>>'%(ret, ret_str))
|
|
56
|
+
if "Version" in ret_str:
|
|
57
|
+
ret = "v%s" % ret_str.split("Version")[-1].split()[0]
|
|
58
|
+
elif "-" in ret_str:
|
|
59
|
+
ret = "v%s" % ret_str.split("-")[-1].split()[0]
|
|
60
|
+
else:
|
|
61
|
+
ret = "v%s" % ret_str.split()[-1]
|
|
62
|
+
|
|
63
|
+
if ret and is_verbose():
|
|
64
|
+
inform("%s is correctly installed..." % (PyNestEngine.name), indent=2)
|
|
65
|
+
|
|
66
|
+
if is_verbose():
|
|
67
|
+
inform("NEST is installed with Python support...", indent=2)
|
|
68
|
+
inform("Env vars: %s" % PyNestEngine.environment_vars, indent=2)
|
|
69
|
+
|
|
70
|
+
except Exception as err:
|
|
71
|
+
if is_verbose():
|
|
72
|
+
inform("Couldn't import (py)NEST into Python..: ", err, indent=1)
|
|
73
|
+
inform("NEST env vars: %s" % PyNestEngine.environment_vars, indent=1)
|
|
74
|
+
inform("sys.path: %s" % sys.path, indent=1)
|
|
75
|
+
ret = False
|
|
76
|
+
return ret
|
|
77
|
+
|
|
78
|
+
@staticmethod
|
|
79
|
+
def install(version):
|
|
80
|
+
NestEngine.install(version)
|
|
81
|
+
PyNestEngine.path = NestEngine.path
|
|
82
|
+
PyNestEngine.environment_vars = NestEngine.environment_vars
|
|
83
|
+
inform("Finished installation of PyNEST....", indent=2)
|
|
84
|
+
|
|
85
|
+
def run(self):
|
|
86
|
+
self.environment_vars = NestEngine.get_nest_environment()
|
|
87
|
+
self.set_environment()
|
|
88
|
+
|
|
89
|
+
sys.path.append(self.environment_vars["PYTHONPATH"])
|
|
90
|
+
|
|
91
|
+
inform("Env vars: %s" % self.environment_vars, indent=2)
|
|
92
|
+
inform("sys.path: %s" % sys.path, indent=1)
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
inform(
|
|
96
|
+
"Running the file %s with %s" % (trim_path(self.modelpath), self.name),
|
|
97
|
+
indent=1,
|
|
98
|
+
)
|
|
99
|
+
self.stdout = check_output(
|
|
100
|
+
["python", self.modelpath, "-nogui"],
|
|
101
|
+
cwd=os.path.dirname(self.modelpath),
|
|
102
|
+
)
|
|
103
|
+
self.returncode = 0
|
|
104
|
+
except sp.CalledProcessError as err:
|
|
105
|
+
self.returncode = err.returncode
|
|
106
|
+
self.stdout = err.output
|
|
107
|
+
raise EngineExecutionError
|
|
108
|
+
except Exception as err:
|
|
109
|
+
inform("Another error with running %s: " % self.name, err, indent=1)
|
|
110
|
+
self.returncode = -1
|
|
111
|
+
self.stdout = "???"
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
from omv.engines.utils.wdir import working_dir
|
|
4
|
+
|
|
5
|
+
from omv.common.inout import inform, check_output as co, trim_path, is_verbose
|
|
6
|
+
from omv.engines.engine import OMVEngine
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class PyneuroConstructEngine(OMVEngine):
|
|
10
|
+
name = "Py_neuroConstruct"
|
|
11
|
+
|
|
12
|
+
@staticmethod
|
|
13
|
+
def get_nC_environment():
|
|
14
|
+
nc_path = os.path.join(os.environ["HOME"], "neuroConstruct")
|
|
15
|
+
if "NC_HOME" in os.environ:
|
|
16
|
+
nc_path = os.environ["NC_HOME"] + "/"
|
|
17
|
+
|
|
18
|
+
environment_vars = {"NC_HOME": nc_path}
|
|
19
|
+
|
|
20
|
+
return environment_vars
|
|
21
|
+
|
|
22
|
+
@staticmethod
|
|
23
|
+
def is_installed():
|
|
24
|
+
nChome = PyneuroConstructEngine.get_nC_environment()["NC_HOME"]
|
|
25
|
+
inform(
|
|
26
|
+
"Checking whether neuroConstruct is installed (in %s)" % nChome,
|
|
27
|
+
indent=2,
|
|
28
|
+
verbosity=2,
|
|
29
|
+
)
|
|
30
|
+
ret = True
|
|
31
|
+
try:
|
|
32
|
+
with working_dir(nChome):
|
|
33
|
+
r = co(["./nC.sh", "-v"], verbosity=1)
|
|
34
|
+
ret = "v%s" % r.split("neuroConstruct, version: ")[-1].split()[0]
|
|
35
|
+
except Exception as err:
|
|
36
|
+
if is_verbose():
|
|
37
|
+
inform("Couldn't execute neuroConstruct:", err, indent=1)
|
|
38
|
+
ret = False
|
|
39
|
+
return ret
|
|
40
|
+
|
|
41
|
+
@staticmethod
|
|
42
|
+
def install(version):
|
|
43
|
+
from omv.engines.getneuroconstruct import install_neuroconstruct
|
|
44
|
+
|
|
45
|
+
inform("Will fetch and install the latest neuroConstruct", indent=2)
|
|
46
|
+
install_neuroconstruct()
|
|
47
|
+
inform("Done...", indent=2)
|
|
48
|
+
|
|
49
|
+
def run(self):
|
|
50
|
+
try:
|
|
51
|
+
inform(
|
|
52
|
+
"Running file %s with Py_neuroConstruct" % trim_path(self.modelpath),
|
|
53
|
+
indent=1,
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
nC_sh = os.path.join(
|
|
57
|
+
PyneuroConstructEngine.get_nC_environment()["NC_HOME"], "nC.sh"
|
|
58
|
+
)
|
|
59
|
+
self.stdout = co(
|
|
60
|
+
[nC_sh, "-python", self.modelpath, "-nogui"],
|
|
61
|
+
cwd=os.path.dirname(self.modelpath),
|
|
62
|
+
)
|
|
63
|
+
self.returncode = 0
|
|
64
|
+
except Exception as err:
|
|
65
|
+
inform("Error with running Py_neuroConstruct:", err, indent=1)
|
|
66
|
+
self.returncode = -1
|
|
67
|
+
self.stdout = "???"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess as sp
|
|
3
|
+
|
|
4
|
+
from omv.common.inout import inform, trim_path, is_verbose, check_output
|
|
5
|
+
from omv.engines.engine import OMVEngine, EngineExecutionError
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class PyNeuroMLEngine(OMVEngine):
|
|
9
|
+
name = "pyNeuroML"
|
|
10
|
+
|
|
11
|
+
@staticmethod
|
|
12
|
+
def is_installed():
|
|
13
|
+
ret = True
|
|
14
|
+
try:
|
|
15
|
+
inform(
|
|
16
|
+
"Checking whether %s is installed..." % PyNeuroMLEngine.name,
|
|
17
|
+
indent=1,
|
|
18
|
+
verbosity=2,
|
|
19
|
+
)
|
|
20
|
+
import pyneuroml
|
|
21
|
+
|
|
22
|
+
ret = "v%s" % pyneuroml.__version__
|
|
23
|
+
|
|
24
|
+
except Exception as err:
|
|
25
|
+
inform(
|
|
26
|
+
"Couldn't import %s into Python: " % PyNeuroMLEngine.name,
|
|
27
|
+
err,
|
|
28
|
+
indent=1,
|
|
29
|
+
verbosity=1,
|
|
30
|
+
)
|
|
31
|
+
ret = False
|
|
32
|
+
return ret
|
|
33
|
+
|
|
34
|
+
@staticmethod
|
|
35
|
+
def install(version):
|
|
36
|
+
from omv.engines.getpyneuroml import install_pynml
|
|
37
|
+
|
|
38
|
+
inform("Will fetch and install the latest pyNeuroML", indent=2)
|
|
39
|
+
install_pynml(version)
|
|
40
|
+
|
|
41
|
+
def run(self):
|
|
42
|
+
try:
|
|
43
|
+
inform(
|
|
44
|
+
"Running file %s with %s" % (trim_path(self.modelpath), self.name),
|
|
45
|
+
indent=1,
|
|
46
|
+
)
|
|
47
|
+
self.stdout = check_output(
|
|
48
|
+
["pynml" if os.name != "nt" else "pynml.bat", self.modelpath, "-nogui"],
|
|
49
|
+
cwd=os.path.dirname(self.modelpath),
|
|
50
|
+
)
|
|
51
|
+
self.returncode = 0
|
|
52
|
+
except sp.CalledProcessError as err:
|
|
53
|
+
self.returncode = err.returncode
|
|
54
|
+
self.stdout = err.output
|
|
55
|
+
raise EngineExecutionError
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import subprocess as sp
|
|
3
|
+
|
|
4
|
+
from omv.common.inout import inform, trim_path, check_output
|
|
5
|
+
from omv.engines.engine import EngineExecutionError
|
|
6
|
+
from omv.engines.pyneuroml_ import PyNeuroMLEngine
|
|
7
|
+
from omv.engines.engine import PATH_DELIMITER
|
|
8
|
+
from omv.engines.utils import resolve_paths
|
|
9
|
+
|
|
10
|
+
class PyNeuroMLValidateSBMLEngine(PyNeuroMLEngine):
|
|
11
|
+
name = "pyNeuroML_validate_sbml"
|
|
12
|
+
|
|
13
|
+
@staticmethod
|
|
14
|
+
def is_installed():
|
|
15
|
+
if not PyNeuroMLEngine.is_installed(): return False
|
|
16
|
+
|
|
17
|
+
ret = True
|
|
18
|
+
try:
|
|
19
|
+
inform(
|
|
20
|
+
"Checking whether %s is installed..." % PyNeuroMLValidateSBMLEngine.name,
|
|
21
|
+
indent=1,
|
|
22
|
+
verbosity=2,
|
|
23
|
+
)
|
|
24
|
+
import libsbml
|
|
25
|
+
|
|
26
|
+
ret = "v%s" % libsbml.__version__
|
|
27
|
+
|
|
28
|
+
except Exception as err:
|
|
29
|
+
inform(
|
|
30
|
+
"Couldn't import %s into Python: " % PyNeuroMLValidateSBMLEngine.name,
|
|
31
|
+
err,
|
|
32
|
+
indent=1,
|
|
33
|
+
verbosity=1,
|
|
34
|
+
)
|
|
35
|
+
ret = False
|
|
36
|
+
return ret
|
|
37
|
+
|
|
38
|
+
@staticmethod
|
|
39
|
+
def install(version):
|
|
40
|
+
if not PyNeuroMLEngine.is_installed(): PyNeuroMLEngine.install(None)
|
|
41
|
+
|
|
42
|
+
from omv.engines.getlibsbml import install_libsbml
|
|
43
|
+
|
|
44
|
+
inform("Will fetch and install the latest libsbml", indent=2)
|
|
45
|
+
install_libsbml(version)
|
|
46
|
+
|
|
47
|
+
def run(self):
|
|
48
|
+
try:
|
|
49
|
+
path_s = resolve_paths(self.modelpath)
|
|
50
|
+
|
|
51
|
+
inform(
|
|
52
|
+
"Path [%s] expanded to: %s" % (self.modelpath, path_s),
|
|
53
|
+
indent=1,
|
|
54
|
+
verbosity=1,
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
#pynml = PyNeuroMLEngine.get_executable() #could implement more flexible way to find the executeable
|
|
58
|
+
cmds = ["pynml", "-validate-sbml"]
|
|
59
|
+
for p in path_s:
|
|
60
|
+
cmds.append(p)
|
|
61
|
+
|
|
62
|
+
inform(
|
|
63
|
+
"Running with %s, using: %s..." % (PyNeuroMLValidateSBMLEngine.name, cmds),
|
|
64
|
+
indent=1,
|
|
65
|
+
)
|
|
66
|
+
self.stdout = check_output(
|
|
67
|
+
cmds,
|
|
68
|
+
cwd=os.path.dirname(self.modelpath.split(PATH_DELIMITER)[0])
|
|
69
|
+
#env=PyNeuroMLEngine.get_environment(),
|
|
70
|
+
)
|
|
71
|
+
inform(
|
|
72
|
+
"Success with running ",
|
|
73
|
+
PyNeuroMLValidateSBMLEngine.name,
|
|
74
|
+
indent=1,
|
|
75
|
+
verbosity=1,
|
|
76
|
+
)
|
|
77
|
+
self.returncode = 0
|
|
78
|
+
except sp.CalledProcessError as err:
|
|
79
|
+
inform("Error with ", PyNeuroMLValidateSBMLEngine.name, indent=1, verbosity=1)
|
|
80
|
+
self.returncode = err.returncode
|
|
81
|
+
self.stdout = err.output
|
|
82
|
+
raise EngineExecutionError
|
|
83
|
+
|