Skip to content

Commit

Permalink
Merge pull request #122 from OpenSourceBrain/test_xpp
Browse files Browse the repository at this point in the history
XPP updates: Add JNeuroMLXppEngine and pyNEURON_XPP_LEMS
  • Loading branch information
pgleeson authored Apr 23, 2024
2 parents 991f7cd + 159a08f commit 843199a
Show file tree
Hide file tree
Showing 18 changed files with 177 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ jobs:
- jNeuroML_PyNN_NEURON
- jNeuroML_validate
- jNeuroML_validatev1
- jNeuroML_XPP
- Py_neuroConstruct
- pyNeuroML
- pyNeuroML_validate_sbml
- pyNEURON_XPP_LEMS
- jNeuroML_Moose
- MOOSE:3.1.5
- XPP
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,8 @@ report*.txt
/utilities/tests/*_eden.py
arm64
/*ken.sh
/utilities/tests/LEMS_NML2_Ex9_FN.ode
/utilities/tests/LEMS_nca.xml
/utilities/tests/nca.model.xml
/utilities/tests/NML2_SingleCompHHCell.nml__flattened.xml
/utilities/tests/lems/simp2.dat
2 changes: 2 additions & 0 deletions omv/engines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# from omv.engines.jneuromlbrian import JNeuroMLBrianEngine
from omv.engines.jneuromleden import JNeuroMLEdenEngine
from omv.engines.jneuromlbrian2 import JNeuroMLBrian2Engine
from omv.engines.jneuromlxpp import JNeuroMLXppEngine
from omv.engines.jneuromlmoose import JNeuroMLMooseEngine
from omv.engines.jneuromlvalidate import JNeuroMLValidateEngine
from omv.engines.jneuromlvalidatev1 import JNeuroMLValidateV1Engine
Expand Down Expand Up @@ -43,6 +44,7 @@
from omv.engines.pyneuroconstruct import PyneuroConstructEngine
from omv.engines.pyneuroml_ import PyNeuroMLEngine
from omv.engines.pyneuromlvalidatesbml import PyNeuroMLValidateSBMLEngine
from omv.engines.pyneuromlxpp import PyNeuroMLXppEngine


OMVEngines = {
Expand Down
2 changes: 1 addition & 1 deletion omv/engines/jneuromlbrian.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def install(version):
if not JNeuroMLEngine.is_installed():
JNeuroMLEngine.install(None)
if not Brian1Engine.is_installed():
Brian1Engine.install(None)
Brian1Engine.install(version)

JNeuroMLBrianEngine.path = JNeuroMLEngine.path + ":" + Brian1Engine.path
JNeuroMLBrianEngine.environment_vars = {}
Expand Down
2 changes: 1 addition & 1 deletion omv/engines/jneuromlnetpyne.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def install(version):
verbosity=1,
)
if not NetPyNEEngine.is_installed():
NetPyNEEngine.install(None)
NetPyNEEngine.install(version)
inform(
"%s installed NetPyNE (& NEURON)..." % JNeuroMLNetPyNEEngine.name,
indent=2,
Expand Down
2 changes: 1 addition & 1 deletion omv/engines/jneuromlpynnnrn.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def install(version):
verbosity=1,
)
if not PyNNNRNEngine.is_installed():
PyNNNRNEngine.install(None)
PyNNNRNEngine.install(version)
inform(
"%s installed PyNN & NRN..." % JNeuroMLPyNNNRNEngine.name,
indent=2,
Expand Down
2 changes: 1 addition & 1 deletion omv/engines/jneuromlvalidate.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def is_installed():
@staticmethod
def install(version):
if not JNeuroMLEngine.is_installed():
JNeuroMLEngine.install(None)
JNeuroMLEngine.install(version)

JNeuroMLValidateEngine.path = JNeuroMLEngine.path
JNeuroMLValidateEngine.environment_vars = {}
Expand Down
2 changes: 1 addition & 1 deletion omv/engines/jneuromlvalidatev1.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def is_installed():
@staticmethod
def install(version):
if not JNeuroMLEngine.is_installed():
JNeuroMLEngine.install(None)
JNeuroMLEngine.install(version)

JNeuroMLValidateV1Engine.path = JNeuroMLEngine.path
JNeuroMLValidateV1Engine.environment_vars = {}
Expand Down
59 changes: 59 additions & 0 deletions omv/engines/jneuromlxpp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import os
import subprocess as sp

from omv.engines.jneuroml import JNeuroMLEngine
from omv.engines.xpp import XppEngine
from omv.common.inout import inform, trim_path, check_output, is_verbose
from omv.engines.engine import EngineExecutionError


class JNeuroMLXppEngine(JNeuroMLEngine):
name = "jNeuroML_XPP"

@staticmethod
def is_installed():
if is_verbose():
inform(
"Checking whether %s is installed..." % JNeuroMLXppEngine.name,
indent=1,
)
return JNeuroMLEngine.is_installed() and XppEngine.is_installed()

@staticmethod
def install(xpp_version):
if not JNeuroMLEngine.is_installed():
JNeuroMLEngine.install(None)
if not XppEngine.is_installed():
XppEngine.install(xpp_version)


def run(self):
self.environment_vars = XppEngine.get_xpp_environment()
self.set_environment()
try:
inform(
"Running file %s with %s"
% (trim_path(self.modelpath), JNeuroMLXppEngine.name),
indent=1,
)
from omv.engines.jneuroml import JNeuroMLEngine

jnml = JNeuroMLEngine.get_executable()
self.stdout = check_output(
[jnml, self.modelpath, "-xpp"],
cwd=os.path.dirname(self.modelpath),
env=JNeuroMLEngine.get_environment(),
)

self.stdout = check_output(
[self.environment_vars["XPP_HOME"] + "/xppaut", self.modelpath.replace('.xml','.ode'), '-silent'],
cwd=os.path.dirname(self.modelpath),
)

inform("Success with running ", JNeuroMLXppEngine.name, indent=1)
self.returncode = 0
except sp.CalledProcessError as err:
inform("Error with ", JNeuroMLXppEngine.name, indent=1)
self.returncode = err.returncode
self.stdout = err.output
raise EngineExecutionError
2 changes: 1 addition & 1 deletion omv/engines/netpyne_.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def install(version):

home = os.environ["HOME"]
inform("Will fetch and install the latest NetPyNE..", indent=2)
install_netpyne()
install_netpyne(version)
inform("Done, NetPyNE is correctly installed...", indent=2)

NetPyNEEngine.path = PyNRNEngine.path
Expand Down
2 changes: 1 addition & 1 deletion omv/engines/pylemsnml2.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def is_installed():

def install(self, version):
if not PyLemsEngine.is_installed():
PyLemsEngine.install(None)
PyLemsEngine.install(version)
if not os.path.isdir(default_nml2_dir):
install_nml2()

Expand Down
56 changes: 56 additions & 0 deletions omv/engines/pyneuromlxpp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os
import subprocess as sp

from omv.common.inout import inform, trim_path, check_output
from omv.engines.engine import EngineExecutionError
from omv.engines.pyneuroml_ import PyNeuroMLEngine
from omv.engines.engine import PATH_DELIMITER
from omv.engines.utils import resolve_paths

class PyNeuroMLXppEngine(PyNeuroMLEngine):
name = "pyNEURON_XPP_LEMS"

@staticmethod
def is_installed():
pynml_ver = PyNeuroMLEngine.is_installed()
if not pynml_ver:
return False
else:
return pynml_ver


@staticmethod
def install(version):
if not PyNeuroMLEngine.is_installed(): PyNeuroMLEngine.install(version)


def run(self):
try:

#pynml = PyNeuroMLEngine.get_executable() #could implement more flexible way to find the executeable
cmds = ["pynml-xpp"]
cmds.append(self.modelpath)
cmds.append('-lems')
cmds.append('-run')

inform(
"Running with %s, using: %s..." % (PyNeuroMLXppEngine.name, cmds),
indent=1,
)
self.stdout = check_output(
cmds,
cwd=os.path.dirname(self.modelpath)
)
inform(
"Success with running ",
PyNeuroMLXppEngine.name,
indent=1,
verbosity=1,
)
self.returncode = 0
except sp.CalledProcessError as err:
inform("Error with ", PyNeuroMLXppEngine.name, indent=1, verbosity=1)
self.returncode = err.returncode
self.stdout = err.output
raise EngineExecutionError

2 changes: 1 addition & 1 deletion omv/engines/pynnneuroml.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def is_installed():
@staticmethod
def install(version):
if not PyNeuroMLEngine.is_installed():
PyNeuroMLEngine.install(None)
PyNeuroMLEngine.install(version)
inform(
"%s installed PyNeuroML..." % PyNNNeuroMLEngine.name,
indent=2,
Expand Down
2 changes: 1 addition & 1 deletion omv/engines/pynnneuron.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def is_installed():
@staticmethod
def install(version=None):
if not NeuronEngine.is_installed():
NeuronEngine.install(None)
NeuronEngine.install(version)
inform("%s installed NEURON..." % PyNNNRNEngine.name, indent=2, verbosity=1)
if not PyNNEngine.is_installed():
PyNNEngine.install(None)
Expand Down
26 changes: 26 additions & 0 deletions utilities/tests/.test.ex9.jnmlxpp.omt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Script for running automated tests on OSB using Travis-CI, see https://github.com/OpenSourceBrain/osb-model-validation

target: LEMS_NML2_Ex9_FN.xml
engine: jNeuroML_XPP
mep: .test.ex9.mep
experiments:
V:
observables:
spike times:
file:
path: output.dat
columns: [0,1]
scaling: [1000, 1000]
spike detection:
method: derivative
tolerance: 0.004098360655737705
W:
observables:
spike times:
file:
path: output.dat
columns: [0,2]
scaling: [1000, 1]
spike detection:
method: derivative
tolerance: 0.00033585982982530405
File renamed without changes.
17 changes: 17 additions & 0 deletions utilities/tests/.test.nca.pynmlxpplems.omt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
target: nca.ode
engine: pyNEURON_XPP_LEMS

mep: .test.nca.mep
experiments:
spikes:
observables:
spike times:
file:
path: output.dat
columns: [0,14]
scaling: [1000, 1]
spike detection:
method: threshold
threshold: 0
tolerance: 0.009999966556292568

2 changes: 1 addition & 1 deletion utilities/tests/.test.xpp.omt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
target: nca.ode
engine: XPP

mep: .test.xpp.mep
mep: .test.nca.mep
experiments:
spikes:
observables:
Expand Down

0 comments on commit 843199a

Please sign in to comment.