Skip to content

Commit 831e749

Browse files
committed
merged latest development
2 parents 2cc7bbd + 493dcb5 commit 831e749

48 files changed

Lines changed: 18700 additions & 552 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

netpyne_ui/experiments.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def get_model_specification(name: str, trial: str) -> dict:
154154
"""
155155
path = get_trial_output_path(name, trial, fallback=True)
156156
if path is None or not os.path.exists(path):
157-
raise ExperimentsError(f"Trial file {path} not found")
157+
raise ExperimentsError(f"Condition file {path} not found")
158158

159159
with open(path, "r") as f:
160160
trial_output = json.load(f)
@@ -273,7 +273,7 @@ def onerror(func, path, exc_info):
273273

274274

275275
def _create_base_model_trial() -> model.Trial:
276-
return model.Trial(name="Trial 1", id=BASE_TRIAL_ID)
276+
return model.Trial(name="Condition 1", id=BASE_TRIAL_ID)
277277

278278

279279
def _create_trials(experiment: model.Experiment) -> List[model.Trial]:
@@ -315,7 +315,7 @@ def _create_trials(experiment: model.Experiment) -> List[model.Trial]:
315315

316316
filename = combinations["filenames"][combIdx][1:]
317317
indices = combinations["indices"][combIdx]
318-
name = f"Trial {combIdx + 1}"
318+
name = f"Condition {combIdx + 1}"
319319

320320
trials.append(
321321
model.Trial(name=name, params=params, indices=indices, id=filename)

netpyne_ui/netpyne_geppetto.py

Lines changed: 11 additions & 7 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
@@ -138,7 +139,7 @@ def viewExperimentResult(self, payload: dict):
138139

139140
file = experiments.get_trial_output_path(name, trial)
140141
if file is None or not os.path.exists(file):
141-
return utils.getJSONError(f"Couldn't find output file of trial. Please take a look at the simulation log.", "")
142+
return utils.getJSONError(f"Couldn't find output file of condition. Please take a look at the simulation log.", "")
142143

143144
if self.doIhaveInstOrSimData()['haveInstance']:
144145
sim.clearAll()
@@ -184,7 +185,7 @@ def instantiateNetPyNEModelInGeppetto(self, args):
184185
self.geppetto_model = self.model_interpreter.getGeppettoModel(netpyne_model)
185186

186187
return json.loads(GeppettoModelSerializer.serialize(self.geppetto_model))
187-
except Exception:
188+
except Exception as e:
188189
message = "Error while instantiating the NetPyNE model"
189190
logging.exception(message)
190191
return utils.getJSONError(message, sys.exc_info())
@@ -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,17 +291,17 @@ 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)
294-
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})
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)
302-
return utils.getJSONError(message, sys.exc_info())
304+
return utils.getJSONError(message, sys.exc_info(), { "sim_id": sim_id})
303305

304306
def _prepare_simulation_files(self, experiment: model.Experiment = None, use_prev_inst: bool = False) -> str:
305307
"""Prepares template files and netpyne model files for a single simulation """
@@ -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)

package.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ ipython-genutils==0.2.0
2020
ipywidgets==7.5.1
2121
jedi==0.17.0
2222
Jinja2==2.11.2
23+
jsonpickle==2.1.0
2324
jsonschema==3.2.0
2425
jupyter==1.0.0
2526
jupyter-client==6.1.3

tests/backend/netypne_model_importer_test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def setUpClass(cls):
3636
logging.error("Error loading mechanisms", exc_info=True)
3737

3838
def test_dict_import_1(self):
39+
assert 0
3940
print("------------------------------------")
4041
print("Dictionary transform importModel:")
4142
print("------------------------------------")
@@ -60,6 +61,40 @@ def test_dict_import_1(self):
6061
netpyne = NetPyNEGeppetto()
6162
netpyne.importModel(netpyne_info)
6263

64+
def test_netpyne_exported_model_1(self):
65+
print("------------------------------------")
66+
print("Netpyne exported model sim run")
67+
print("------------------------------------")
68+
69+
params = {}
70+
71+
HERE = os.path.dirname(os.path.realpath(__file__))
72+
ROOT = os.path.dirname(HERE)
73+
74+
params["areModFieldsRequired"] = False
75+
params["compileMod"] = False
76+
params["exploreOnlyDirs"] = False
77+
params["explorerDialogOpen"] = False
78+
params["explorerParameter"] = ""
79+
params["freezeInstance"] = True
80+
params["freezeSimulation"] = True
81+
params["jsonModelFolder"] = ROOT + "/workspace/HHCellNetwork.txt_data.json"
82+
params["jsonPath"] = ""
83+
params["loadNet"] = True
84+
params["loadNetParams"] = True
85+
params["loadSimCfg"] = True
86+
params["loadSimData"] = True
87+
params["modFolder"] = ""
88+
params["modPath"] = ""
89+
params["tab"] = "simulate"
90+
91+
netpyne = NetPyNEGeppetto()
92+
93+
netpyne.loadModel(params)
94+
netpyne.instantiateNetPyNEModel()
95+
96+
return False
97+
6398
if __name__ == '__main__':
6499
try:
65100
unittest.main()

0 commit comments

Comments
 (0)