Skip to content

Commit 49707af

Browse files
author
Lucas Rebscher
committed
#263 Integration of cleanup improvement with sim.clearAll
* Enabling Tut 1 -> Simulate -> Tut 2 -> Simulate flow without causing kernel crash * Only POC that it's possible, need to understand the lifecycle methods of netpyne and when each of them should be called
1 parent 19de8fb commit 49707af

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ def simulateNetPyNEModelInGeppetto(self, args):
104104
logging.info("Starting simulation")
105105
if not 'usePrevInst' in args or not args['usePrevInst']:
106106
logging.debug('Instantiating single thread simulation')
107-
netpyne_model = self.instantiateNetPyNEModel()
108-
self.geppetto_model = self.model_interpreter.getGeppettoModel(netpyne_model)
107+
108+
# TODO: we should instantiate the network before simulation per default
109+
# or we need a mechanism to detect if the currently instantiated network matches with
110+
# the current net params and simConfig. When I import a new model or change sth and directly simulate
111+
# we run simulation with an old network but new config, this causes issues!
112+
netpyne_model = self.instantiateNetPyNEModel()
113+
self.geppetto_model = self.model_interpreter.getGeppettoModel(netpyne_model)
109114

110115
logging.debug('Running single thread simulation')
111116
netpyne_model = self.simulateNetPyNEModel()
@@ -218,6 +223,12 @@ def importModel(self, modelParameters):
218223
:param modelParameters:
219224
:return:
220225
"""
226+
# TODO: Still need attributes check to avoid exception with empty sim
227+
if getattr(sim, "pc", None):
228+
# TODO: this must be integrated into the general lifecycle of "model change -> simulate"
229+
# Shouldn't be specific to Import
230+
sim.clearAll()
231+
221232
try:
222233
# Get Current dir
223234
owd = os.getcwd()
@@ -247,6 +258,9 @@ def importModel(self, modelParameters):
247258
# Import Model attributes
248259
self.simConfig = getattr(simConfigModuleName, str(modelParameters["simConfigVariable"]))
249260

261+
# TODO: when should sim.initialize be called?
262+
# Only on import or better before every simulation or network instantiation?
263+
sim.initialize()
250264
return utils.getJSONReply()
251265
except:
252266
return utils.getJSONError("Error while importing the NetPyNE model", sys.exc_info())

0 commit comments

Comments
 (0)