Skip to content

Commit 87ce93d

Browse files
committed
Fix mod files double loading issues
1 parent e230a3d commit 87ce93d

3 files changed

Lines changed: 16 additions & 13 deletions

File tree

netpyne_ui/mod_utils.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import shutil
23
import subprocess
34
import os
@@ -29,24 +30,27 @@ def is_loaded_mechanisms():
2930
def loadModMechFiles(compileMod, modFolder, forceRecompile=False):
3031
# Create Symbolic link
3132

32-
if compileMod:
3333
try:
34+
3435
owd = os.getcwd()
35-
modPath = os.path.join(str(modFolder), "x86_64")
36+
if compileMod:
37+
38+
compiledModPath = os.path.join(str(modFolder), "x86_64")
3639

37-
if os.path.exists(modPath):
38-
if forceRecompile:
39-
shutil.rmtree(modPath)
40-
else:
41-
return
40+
if os.path.exists(compiledModPath) and forceRecompile:
41+
logging.info("Forcing mod files to recompile in %s" % modFolder)
42+
shutil.rmtree(compiledModPath)
4243

43-
os.chdir(modFolder)
44-
subprocess.call(["nrnivmodl"])
45-
os.chdir('..')
44+
if not os.path.exists(compiledModPath):
45+
logging.info("Compiling mod files in %s" % modFolder)
46+
os.chdir(modFolder)
47+
subprocess.call(["nrnivmodl"])
48+
os.chdir('..')
4649

4750
try:
4851
neuron.load_mechanisms(str(modFolder))
4952
except:
53+
logging.exception("Error loading mechanisms")
5054
raise
5155
finally:
5256
os.chdir(owd)

netpyne_ui/netpyne_geppetto.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
os.chdir(constants.NETPYNE_WORKDIR_PATH)
4848

49-
neuron.nrn_dll_loaded.append(os.path.join(NETPYNE_WORKDIR_PATH, 'mod')) # Avoids to load workspace modfiles twice
5049

5150
class NetPyNEGeppetto:
5251

@@ -581,7 +580,7 @@ def importModel(self, modelParameters):
581580
# Only on import or better before every simulation or network instantiation?
582581
sim.initialize()
583582
return utils.getJSONReply()
584-
except Exception:
583+
except:
585584
message = "Error while importing the NetPyNE model"
586585
logging.exception(message)
587586
return utils.getJSONError(message, sys.exc_info())

webapp/redux/middleware/middleware.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ export default (store) => (next) => (action) => {
400400

401401
const params = {
402402
modFolder: dirname + '/mod',
403-
loadMod: false,
403+
loadMod: true,
404404
compileMod: true,
405405
forceRecompile: false,
406406

0 commit comments

Comments
 (0)