Skip to content

Commit 668f4b3

Browse files
committed
Implemented ErrorDialogManager in the middleware
1 parent e8bb57b commit 668f4b3

3 files changed

Lines changed: 154 additions & 118 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from shutil import copyfile
1515
from dacite import from_dict
1616
import base64
17+
import jsonpickle
1718

1819
import neuron
1920
import numpy as np
@@ -266,6 +267,7 @@ def simulateNetPyNEModelInGeppetto(self, args):
266267
"""
267268
allTrials = args.get('allTrials', True)
268269
use_prev_inst = args.get('usePrevInst', False)
270+
sim_id = args.get('simId', 0)
269271

270272
try:
271273
experiment = experiments.get_current()
@@ -289,15 +291,15 @@ def simulateNetPyNEModelInGeppetto(self, args):
289291
return self.simulate_single_model(experiment, use_prev_inst)
290292
except Exception:
291293
experiment.state = model.ExperimentState.ERROR
292-
message = "Unknown error during simulation of Experiment"
294+
message = ("Unknown error during simulation of Experiment. SimulationId %i" % sim_id)
293295
logging.exception(message)
294296
return utils.getJSONError("Unknown error during simulation of Experiment", sys.exc_info())
295297

296298
else:
297299
return self.simulate_single_model(use_prev_inst=use_prev_inst)
298300

299-
except Exception:
300-
message = "Error while simulating the NetPyNE model"
301+
except Exception as e :
302+
message = ("Error while simulating the NetPyNE model: %s. SimulationId %f" % (e, sim_id))
301303
logging.exception(message)
302304
return utils.getJSONError(message, sys.exc_info())
303305

@@ -647,6 +649,8 @@ def instantiateNetPyNEModel(self):
647649
saveData = sim.allSimData if hasattr(sim, 'allSimData') and 'spkt' in sim.allSimData.keys() and len(
648650
sim.allSimData['spkt']) > 0 else False
649651

652+
#netcoded = jsonpickle.encode(self.netParams, unpicklable=False)
653+
#simcoded = jsonpickle.encode(self.simConfig, unpicklable=False)
650654
sim.create(self.netParams, self.simConfig)
651655
sim.net.defineCellShapes() # creates 3d pt for cells with stylized geometries
652656
sim.gatherData(gatherLFP=False)

webapp/redux/middleware/middleware.js

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,33 @@ const simulateNetwork = (payload) => createSimulateBackendCall(
106106
GEPPETTO.Resources.RUNNING_SIMULATION,
107107
);
108108

109+
class ErrorDialogManager {
110+
errorTag = 'SimulationId ';
111+
errorIds = [];
112+
addId(id){ this.errorIds.push(id); }
113+
getErrorId(s) {
114+
let errorId = 0 ;
115+
const i = s.indexOf(this.errorTag);
116+
if (i > -1)
117+
errorId = parseFloat(s.substring(i + this.errorTag.length, s.length-1));
118+
return errorId ;
119+
}
120+
shouldLaunch(s) {
121+
const errorId = this.getErrorId(s);
122+
if (this.errorIds.indexOf(errorId) == -1 && errorId > 0)
123+
{
124+
this.errorIds.push(errorId);
125+
return true ;
126+
}
127+
if (errorId == 0)
128+
return true ;
129+
if (this.errorIds.indexOf(errorId) >= 0)
130+
return false;
131+
}
132+
}
133+
134+
const errorDialogManager = new ErrorDialogManager();
135+
109136
export default (store) => (next) => (action) => {
110137
const switchLayoutAction = (edit = true, reset = true) => {
111138
previousLayout[store.getState().general.editMode ? 'edit' : 'network'] = store.getState().layout;
@@ -129,7 +156,10 @@ export default (store) => (next) => (action) => {
129156

130157
const pythonErrorCallback = (error) => {
131158
console.debug(Utils.getPlainStackTrace(error.errorDetails));
132-
return next(openBackendErrorDialog(error));
159+
if (errorDialogManager.shouldLaunch(error.errorMessage))
160+
return next(openBackendErrorDialog(error));
161+
else
162+
return next(action);
133163
};
134164

135165
switch (action.type) {
@@ -166,12 +196,14 @@ export default (store) => (next) => (action) => {
166196
break;
167197
}
168198
case CREATE_SIMULATE_NETWORK: {
169-
simulateNetwork({ allTrials: false })
199+
const payload = { allTrials: false, simId: new Date().getTime() }
200+
simulateNetwork(payload)
170201
.then(toNetworkCallback(false), pythonErrorCallback);
171202
break;
172203
}
173204
case SIMULATE_NETWORK:
174-
simulateNetwork({ allTrials: action.payload, usePrevInst: false })
205+
const payload = { allTrials: action.payload, simId: new Date().getTime(), usePrevInst: false }
206+
simulateNetwork(payload)
175207
.then(toNetworkCallback(false), pythonErrorCallback);
176208
break;
177209
case PYTHON_CALL: {

0 commit comments

Comments
 (0)