@@ -32,7 +32,7 @@ def is_dir_non_empty(directory):
3232
3333
3434class ModelRun (dict ):
35- def __init__ (self , model , working_dir , clean = False ):
35+ def __init__ (self , model , working_dir , clean = False , norun = False ):
3636 self ._model = model
3737 self ._working_dir = os .path .abspath (working_dir )
3838 self ._logs = []
@@ -43,6 +43,7 @@ def __init__(self, model, working_dir, clean=False):
4343 self ._run_time = 0
4444 self ._run_py = False
4545 self ._clean = clean
46+ self ._norun = norun
4647
4748 self ["run_info" ] = {}
4849
@@ -63,6 +64,9 @@ def _fetch_model(self):
6364 else :
6465 self ["run" ] = ["verify_graph_()" ]
6566
67+ if self ._norun :
68+ self ["norun" ] = True
69+
6670 run_info = property (lambda self : self ["run_info" ])
6771
6872 logs = property (lambda self : self ._logs )
@@ -244,21 +248,26 @@ def run_model(model):
244248 append_log (model , model .logs , traceback .format_exc ())
245249
246250 # run NEURON
247- try :
248- nrn_exe = "./x86_64/special" if mods is not None and len (mods ) else "nrniv"
249- # '-nogui' creates segfault
250- model_run_cmds = [nrn_exe , '-nobanner' ]
251- if model .run_py :
252- model_run_cmds .append ('-python' )
253- model_run_cmds += [model .run_info ["init" ], model .run_info ["driver" ]]
254- append_log (model , model .nrn_run , "RUNNING -> {}" .format (" " .join (model_run_cmds )))
255- run_neuron_cmds (model , model_run_cmds )
256- if os .path .isfile (os .path .join (model .model_dir , "gout" )):
257- with open (os .path .join (model .model_dir , "gout" ), 'r' ) as gout :
258- model ._gout = gout .readlines ()
259- except Exception : # noqa
260- append_log (model , model .nrn_run , traceback .format_exc ())
261- model ._nrn_run_error = True
251+ if "norun" in model :
252+ append_log (model , model .logs ,
253+ "Model is not run due to --norun option"
254+ )
255+ else :
256+ try :
257+ nrn_exe = "./x86_64/special" if mods is not None and len (mods ) else "nrniv"
258+ # '-nogui' creates segfault
259+ model_run_cmds = [nrn_exe , '-nobanner' ]
260+ if model .run_py :
261+ model_run_cmds .append ('-python' )
262+ model_run_cmds += [model .run_info ["init" ], model .run_info ["driver" ]]
263+ append_log (model , model .nrn_run , "RUNNING -> {}" .format (" " .join (model_run_cmds )))
264+ run_neuron_cmds (model , model_run_cmds )
265+ if os .path .isfile (os .path .join (model .model_dir , "gout" )):
266+ with open (os .path .join (model .model_dir , "gout" ), 'r' ) as gout :
267+ model ._gout = gout .readlines ()
268+ except Exception : # noqa
269+ append_log (model , model .nrn_run , traceback .format_exc ())
270+ model ._nrn_run_error = True
262271
263272 stop_time = time .perf_counter ()
264273
@@ -268,7 +277,7 @@ def run_model(model):
268277
269278
270279class ModelRunManager (object ):
271- def __init__ (self , master_dir , gout = False , clean = False ):
280+ def __init__ (self , master_dir , gout = False , clean = False , norun = False ):
272281 self .master_dir = master_dir
273282 self .logfile = str (master_dir ) + ".log"
274283 self .dumpfile = str (master_dir ) + ".json"
@@ -279,6 +288,7 @@ def __init__(self, master_dir, gout=False, clean=False):
279288 self .run_logs = {}
280289 self ._gout = gout
281290 self ._clean = clean
291+ self ._norun = norun
282292
283293 def _setup_logging (self ):
284294 self .logger = logging .getLogger ("dev" )
@@ -400,7 +410,7 @@ def run_models(self, model_list=None):
400410
401411 # prepare ModelRun objects
402412 models_to_run = (
403- ModelRun (mdl , self .master_dir , self ._clean ) for mdl in models_selected
413+ ModelRun (mdl , self .master_dir , self ._clean , self . _norun ) for mdl in models_selected
404414 )
405415
406416 # number of models
0 commit comments