From fe1ef8026aea9665484c6dd5e5b1b8f67912d5ed Mon Sep 17 00:00:00 2001 From: Justas Birgiolas Date: Sat, 20 Apr 2019 16:01:52 -0700 Subject: [PATCH 1/8] Update base.py --- neuronunit/models/backends/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neuronunit/models/backends/base.py b/neuronunit/models/backends/base.py index 19768b74b..49a5489cf 100644 --- a/neuronunit/models/backends/base.py +++ b/neuronunit/models/backends/base.py @@ -30,8 +30,8 @@ import neuron from neuron import h NEURON_SUPPORT = True - os.chdir(curr) temp.cleanup() + os.chdir(curr) except: neuron = None h = None From 2690759067c8cf029826f967d0dbe9302b4c9190 Mon Sep 17 00:00:00 2001 From: Justas Birgiolas Date: Sat, 20 Apr 2019 16:02:52 -0700 Subject: [PATCH 2/8] Update base.py --- neuronunit/models/backends/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neuronunit/models/backends/base.py b/neuronunit/models/backends/base.py index 49a5489cf..b94d20b0a 100644 --- a/neuronunit/models/backends/base.py +++ b/neuronunit/models/backends/base.py @@ -31,7 +31,7 @@ from neuron import h NEURON_SUPPORT = True temp.cleanup() - os.chdir(curr) + os.chdir(curr) except: neuron = None h = None From 7322c9a0ad7637264fb0f402ecd387e77e253ded Mon Sep 17 00:00:00 2001 From: Justas Birgiolas Date: Sat, 20 Apr 2019 16:13:32 -0700 Subject: [PATCH 3/8] Fixes urljoin import in Python 2 --- neuronunit/models/lems.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neuronunit/models/lems.py b/neuronunit/models/lems.py index 8153cbcee..4f22bbf92 100644 --- a/neuronunit/models/lems.py +++ b/neuronunit/models/lems.py @@ -5,7 +5,7 @@ try: from urllib.parse import urljoin except ImportError: - from urllib import urljoin + from urlparse import urljoin import requests import validators From 06fad1de74a53413a440e94af22421eb26de7a7f Mon Sep 17 00:00:00 2001 From: Justas Birgiolas Date: Sat, 20 Apr 2019 16:20:34 -0700 Subject: [PATCH 4/8] Update base.py --- neuronunit/models/backends/base.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/neuronunit/models/backends/base.py b/neuronunit/models/backends/base.py index b94d20b0a..38b39e281 100644 --- a/neuronunit/models/backends/base.py +++ b/neuronunit/models/backends/base.py @@ -20,22 +20,25 @@ from sciunit.utils import dict_hash, import_module_from_path, \ TemporaryDirectory + +# Never import neuron in the current directory, or it will automatically +# load mechanisms in that directory, which will then cause future calls +# to load_mechanisms() to fail due to already loaded mechanisms. +temp = TemporaryDirectory() +curr = os.getcwd() +os.chdir(temp.name) try: - # Never import neuron in the current directory, or it will automatically - # load mechanisms in that directory, which will then cause future calls - # to load_mechanisms() to fail due to already loaded mechanisms. - temp = TemporaryDirectory() - curr = os.getcwd() - os.chdir(temp.name) import neuron from neuron import h NEURON_SUPPORT = True - temp.cleanup() - os.chdir(curr) except: neuron = None h = None NEURON_SUPPORT = False +finally: + temp.cleanup() + os.chdir(curr) + try: import pyNN From 16e15ef7880f14bd9aea3740810b21b23a71837c Mon Sep 17 00:00:00 2001 From: Justas Birgiolas Date: Sat, 20 Apr 2019 16:21:09 -0700 Subject: [PATCH 5/8] Update base.py --- neuronunit/models/backends/base.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/neuronunit/models/backends/base.py b/neuronunit/models/backends/base.py index 38b39e281..9d0d82385 100644 --- a/neuronunit/models/backends/base.py +++ b/neuronunit/models/backends/base.py @@ -27,6 +27,7 @@ temp = TemporaryDirectory() curr = os.getcwd() os.chdir(temp.name) + try: import neuron from neuron import h @@ -35,9 +36,9 @@ neuron = None h = None NEURON_SUPPORT = False -finally: - temp.cleanup() - os.chdir(curr) + +temp.cleanup() +os.chdir(curr) try: From 9ab73676ef638ed9201f14dd30f10f2a2c92b8fb Mon Sep 17 00:00:00 2001 From: Justas Birgiolas Date: Sat, 20 Apr 2019 16:26:26 -0700 Subject: [PATCH 6/8] Update base.py --- neuronunit/models/backends/base.py | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/neuronunit/models/backends/base.py b/neuronunit/models/backends/base.py index 9d0d82385..419e8e12c 100644 --- a/neuronunit/models/backends/base.py +++ b/neuronunit/models/backends/base.py @@ -20,26 +20,9 @@ from sciunit.utils import dict_hash, import_module_from_path, \ TemporaryDirectory - -# Never import neuron in the current directory, or it will automatically -# load mechanisms in that directory, which will then cause future calls -# to load_mechanisms() to fail due to already loaded mechanisms. -temp = TemporaryDirectory() -curr = os.getcwd() -os.chdir(temp.name) - -try: - import neuron - from neuron import h - NEURON_SUPPORT = True -except: - neuron = None - h = None - NEURON_SUPPORT = False - -temp.cleanup() -os.chdir(curr) - +# Test for NEURON support in a separate python process +exit_code = os.system('python -c "import neuron"') +NEURON_SUPPORT = (exit_code == 0) try: import pyNN From 7cf4453750f1b40e595fe9b911a1a10bffd83b37 Mon Sep 17 00:00:00 2001 From: Justas Birgiolas Date: Sat, 20 Apr 2019 16:41:08 -0700 Subject: [PATCH 7/8] Fewer side-effect test for NEURON package --- neuronunit/models/backends/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/neuronunit/models/backends/base.py b/neuronunit/models/backends/base.py index 419e8e12c..0e2e9dd10 100644 --- a/neuronunit/models/backends/base.py +++ b/neuronunit/models/backends/base.py @@ -21,8 +21,7 @@ TemporaryDirectory # Test for NEURON support in a separate python process -exit_code = os.system('python -c "import neuron"') -NEURON_SUPPORT = (exit_code == 0) +NEURON_SUPPORT = (os.system('python -c "import neuron" >/dev/null') == 0) try: import pyNN From 372e7402fbb857c8b614fc0e79a4583fb7e3da1b Mon Sep 17 00:00:00 2001 From: Justas Birgiolas Date: Sun, 21 Apr 2019 10:37:39 -0700 Subject: [PATCH 8/8] hide neuron output during support test --- neuronunit/models/backends/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neuronunit/models/backends/base.py b/neuronunit/models/backends/base.py index 0e2e9dd10..22b9b9070 100644 --- a/neuronunit/models/backends/base.py +++ b/neuronunit/models/backends/base.py @@ -21,7 +21,7 @@ TemporaryDirectory # Test for NEURON support in a separate python process -NEURON_SUPPORT = (os.system('python -c "import neuron" >/dev/null') == 0) +NEURON_SUPPORT = (os.system("python -c 'import neuron' > /dev/null 2>&1") == 0) try: import pyNN