Skip to content

Commit f0bc346

Browse files
committed
Merge branch 'development'
2 parents 38cab82 + 65d7d5c commit f0bc346

File tree

9 files changed

+60
-72
lines changed

9 files changed

+60
-72
lines changed

.mypy.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[mypy]
2+
ignore_missing_imports = True

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See https://pre-commit.com for more information
2+
# See https://pre-commit.com/hooks.html for more hooks
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v4.4.0
6+
hooks:
7+
- id: trailing-whitespace
8+
- id: end-of-file-fixer
9+
- id: check-added-large-files
10+
args: [ "--maxkb=5000"]
11+
- repo: https://github.com/astral-sh/ruff-pre-commit
12+
rev: v0.4.1
13+
hooks:
14+
- id: ruff
15+
args: [ "--select", "I", "--fix" ]
16+
- id: ruff-format

omv/common/inout.py

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import yaml
2-
from collections import deque
31
import os
4-
import sys
52

63
# import textwrap
74
import subprocess as sp
5+
from collections import deque
6+
7+
import yaml
88

99
LINEWIDTH = 70
1010
__PROMPT__ = "[omv] "
@@ -25,10 +25,7 @@ def omvify(x):
2525

2626

2727
def check(b):
28-
if sys.version_info >= (3, 0):
29-
tick = "\u2714" if b else "\u2718"
30-
else:
31-
tick = "\u2714" if b else "\u2718"
28+
tick = "\u2714" if b else "\u2718"
3229
return tick
3330

3431

@@ -57,11 +54,7 @@ def inform(
5754
else:
5855
p = pars if pars else ""
5956
# print("msg is %s"%msg.__class__)
60-
msgstr = (
61-
msg.encode("utf-8")
62-
if sys.version_info[0] == 2 and isinstance(msg, unicode)
63-
else str(msg)
64-
)
57+
msgstr = str(msg)
6558
infostr = msgstr + str(p)
6659
block = deque([infostr])
6760

@@ -120,29 +113,18 @@ def check_output(cmds, cwd=".", shell=False, verbosity=0, env=None):
120113
return ret_string
121114

122115
except sp.CalledProcessError as err:
123-
inform(
124-
"CalledProcessError running commands: %s in %s (return code: %s), output:\n%s"
125-
% (cmds, cwd, err.returncode, err.output),
126-
indent=2,
127-
verbosity=verbosity,
128-
)
129116
inform("Error: %s" % (err), indent=2, verbosity=verbosity)
130117
raise err
131118
except Exception as err:
132-
inform(
133-
"Error running commands: %s in (%s)!" % (cmds, cwd),
134-
indent=2,
135-
verbosity=verbosity,
136-
)
137119
inform("Error: %s" % (err), indent=2, verbosity=verbosity)
138120
raise err
139121

140122

141123
def pip_install(packages, version=None):
142-
pip = "pip3" if sys.version_info.major == 3 else "pip"
124+
pip = "pip"
143125
cmds = [pip, "install"]
144-
if type(packages) == str:
145-
if version == None:
126+
if isinstance(packages, str):
127+
if version is None:
146128
cmds.append(packages)
147129
else:
148130
cmds.append("%s==%s" % (packages, version))

omv/engines/getjnml.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99

1010
def install_jnml(version):
11+
"""Install JNeuroML from GitHub tar."""
1112
if not version:
1213
version = "v0.14.0"
1314

omv/engines/jneuroml.py

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,23 @@
22
import shutil
33
import subprocess as sp
44
from pathlib import Path
5-
import platform
65

7-
from omv.common.inout import inform, trim_path, is_verbose, check_output
8-
from omv.engines.engine import OMVEngine, EngineExecutionError
6+
from omv.common.inout import check_output, inform, is_verbose, trim_path
7+
from omv.engines.engine import EngineExecutionError, OMVEngine
98

109

1110
class JNeuroMLEngine(OMVEngine):
1211
name = "jNeuroML"
12+
e_name = "jnml"
1313

1414
@staticmethod
1515
def get_environment():
1616
if "JNML_HOME" in os.environ:
1717
jnmlhome = os.environ["JNML_HOME"]
18-
elif shutil.which("jnml") is not None:
19-
jnmlhome = Path(shutil.which("jnml")).parent
18+
elif shutil.which(JNeuroMLEngine.e_name) is not None:
19+
jnmlhome = Path(shutil.which(JNeuroMLEngine.e_name)).parent
2020
else:
21-
osname = platform.system()
22-
if osname == "Linux":
23-
try:
24-
jnmlhome = os.path.join(
25-
os.environ["XDG_DATA_HOME"], "jnml/jNeuroMLJar"
26-
)
27-
except KeyError:
28-
localsharepath = os.path.join(os.environ["HOME"], ".local/share")
29-
if os.path.isdir(localsharepath):
30-
jnmlhome = os.path.join(
31-
os.environ["HOME"], ".local/share/jnml/jNeuroMLJar"
32-
)
33-
else:
34-
jnmlhome = os.path.join(os.environ["HOME"], "jnml/jNeuroMLJar")
35-
36-
elif osname == "Darwin":
37-
jnmlhome = os.path.join(os.environ["HOME"], "Library/jnml/jNeuroMLJar")
38-
else:
39-
jnmlhome = os.path.join(os.environ["HOME"], "jnml/jNeuroMLJar")
21+
jnmlhome = ""
4022

4123
environment_vars = {"JNML_HOME": jnmlhome}
4224

@@ -45,9 +27,7 @@ def get_environment():
4527
@staticmethod
4628
def get_executable():
4729
environment_vars = JNeuroMLEngine.get_environment()
48-
jnml = os.path.join(
49-
environment_vars["JNML_HOME"], "jnml" if os.name != "nt" else "jnml.bat"
50-
)
30+
jnml = os.path.join(environment_vars["JNML_HOME"], JNeuroMLEngine.e_name)
5131
return jnml
5232

5333
@staticmethod
@@ -59,7 +39,6 @@ def is_installed():
5939
"Checking whether %s is installed..." % JNeuroMLEngine.name,
6040
indent=1,
6141
)
62-
FNULL = open(os.devnull, "w")
6342
jnml = JNeuroMLEngine.get_executable()
6443
r = check_output(
6544
[jnml, "-v"], verbosity=2, env=JNeuroMLEngine.get_environment()
@@ -76,10 +55,10 @@ def is_installed():
7655

7756
@staticmethod
7857
def install(version):
79-
from omv.engines.getjnml import install_jnml
58+
from omv.engines.getpyneuroml import install_pynml
8059

81-
inform("Will fetch and install jNeuroML jar", indent=2)
82-
install_jnml(version)
60+
inform("Will install PyNeuroML for jnml", indent=2)
61+
install_pynml(version)
8362

8463
if not JNeuroMLEngine.is_installed():
8564
inform("Failure to install, exiting", indent=1)

omv/engines/jneuromlvalidate.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ def run(self):
2828
path_s = resolve_paths(self.modelpath)
2929

3030
inform(
31-
"Path [%s] expanded to: %s" % (self.modelpath, path_s),
31+
"Path [%s] expanded to: \n %s" % (self.modelpath, '\n '.join(path_s)),
3232
indent=1,
3333
verbosity=1,
3434
)
35+
if len(path_s) == 0:
36+
raise EngineExecutionError(
37+
"Could not determine list of files for validation from string: %s" % self.modelpath
38+
)
3539

3640
from omv.engines.jneuroml import JNeuroMLEngine
3741

omv/engines/utils/__init__.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@ def resolve_paths(path_s):
66
Make explicit list from: '*.nml myfile.xml' etc.
77
"""
88

9-
if "*" in path_s:
10-
import glob
9+
import glob
10+
11+
if PATH_DELIMITER in path_s:
12+
all_paths = []
13+
for p in path_s.split(PATH_DELIMITER):
14+
for g in glob.glob(p):
15+
print('Found path:', g)
16+
all_paths.append(g)
17+
path_s = all_paths
18+
else:
19+
all_paths = []
20+
21+
for g in glob.glob(path_s):
22+
print('Found path:', g)
23+
all_paths.append(g)
24+
path_s = all_paths
1125

12-
if PATH_DELIMITER in path_s:
13-
all_paths = []
14-
for p in path_s.split(PATH_DELIMITER):
15-
for g in glob.glob(p):
16-
all_paths.append(g)
17-
path_s = all_paths
18-
else:
19-
path_s = glob.glob(path_s)
2026

2127
return path_s

omv/omv_util.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,7 @@ def _install_engine(eng):
228228
if ee.is_installed():
229229
already_installed = True
230230
else:
231-
from omv.engines.getjnml import install_jnml
232-
233-
install_jnml(engine_version)
231+
ee.install(None)
234232

235233
elif eng.lower() == "neuroConstruct" or eng == "Py_neuroConstruct".lower():
236234
from omv.engines.pyneuroconstruct import PyneuroConstructEngine as ee

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = OSBModelValidation
3-
version = 0.3.8
3+
version = 0.3.9
44
author = Boris Marin, Padraig Gleeson
55
author_email = [email protected]
66
url = https://github.com/OpenSourceBrain/osb-model-validation

0 commit comments

Comments
 (0)