Skip to content

Commit 9771859

Browse files
committed
changes as requested by PR
1 parent 668f4b3 commit 9771859

4 files changed

Lines changed: 136 additions & 113 deletions

File tree

netpyne_ui/netpyne_geppetto.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,15 @@ def simulateNetPyNEModelInGeppetto(self, args):
293293
experiment.state = model.ExperimentState.ERROR
294294
message = ("Unknown error during simulation of Experiment. SimulationId %i" % sim_id)
295295
logging.exception(message)
296-
return utils.getJSONError("Unknown error during simulation of Experiment", sys.exc_info())
296+
return utils.getJSONError("Unknown error during simulation of Experiment", sys.exc_info(), { "sim_id": sim_id})
297297

298298
else:
299299
return self.simulate_single_model(use_prev_inst=use_prev_inst)
300300

301301
except Exception as e :
302302
message = ("Error while simulating the NetPyNE model: %s. SimulationId %f" % (e, sim_id))
303303
logging.exception(message)
304-
return utils.getJSONError(message, sys.exc_info())
304+
return utils.getJSONError(message, sys.exc_info(), { "sim_id": sim_id})
305305

306306
def _prepare_simulation_files(self, experiment: model.Experiment = None, use_prev_inst: bool = False) -> str:
307307
"""Prepares template files and netpyne model files for a single simulation """

webapp/Utils.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ const Utils = {
195195
} else if (Object.prototype.hasOwnProperty.call(parsedData, 'websocket')) {
196196
error.message = parsedData.websocket;
197197
}
198+
if (Object.prototype.hasOwnProperty.call(parsedData, 'additional_info')) {
199+
error.additionalInfo = parsedData.additional_info ;
200+
}
198201
return error;
199202
}
200203
return null;

webapp/redux/middleware/middleware.js

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export const processError = (response) => {
3939
return {
4040
errorMessage: parsedResponse.message,
4141
errorDetails: parsedResponse.details,
42+
additionalInfo: parsedResponse.additionalInfo
4243
};
4344
}
4445
return false;
@@ -106,32 +107,25 @@ const simulateNetwork = (payload) => createSimulateBackendCall(
106107
GEPPETTO.Resources.RUNNING_SIMULATION,
107108
);
108109

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);
110+
class PythonMessageFilter {
111+
errorIds = new Set();
112+
shouldLaunch(e) {
113+
const errorId = e.additionalInfo?.sim_id ;
114+
if (!errorId)
125115
return true ;
116+
if (errorId)
117+
{
118+
if(this.errorIds.has(errorId))
119+
return false ;
120+
else {
121+
this.errorIds.add(errorId);
122+
return true ;
123+
}
126124
}
127-
if (errorId == 0)
128-
return true ;
129-
if (this.errorIds.indexOf(errorId) >= 0)
130-
return false;
131125
}
132126
}
133127

134-
const errorDialogManager = new ErrorDialogManager();
128+
const errorMessageFilter = new PythonMessageFilter();
135129

136130
export default (store) => (next) => (action) => {
137131
const switchLayoutAction = (edit = true, reset = true) => {
@@ -156,7 +150,7 @@ export default (store) => (next) => (action) => {
156150

157151
const pythonErrorCallback = (error) => {
158152
console.debug(Utils.getPlainStackTrace(error.errorDetails));
159-
if (errorDialogManager.shouldLaunch(error.errorMessage))
153+
if (errorMessageFilter.shouldLaunch(error))
160154
return next(openBackendErrorDialog(error));
161155
else
162156
return next(action);

0 commit comments

Comments
 (0)