Skip to content

Commit 780322c

Browse files
Merge branch 'feature/meta_migration' into feature/403-remove-console-flood
2 parents 2346681 + fec1db8 commit 780322c

17 files changed

Lines changed: 408 additions & 975 deletions

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def viewExperimentResult(self, payload: dict):
138138

139139
file = experiments.get_trial_output_path(name, trial)
140140
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.", "")
141+
return utils.getJSONError(f"Couldn't find output file of condition. Please take a look at the simulation log.", "")
142142

143143
if self.doIhaveInstOrSimData()['haveInstance']:
144144
sim.clearAll()
@@ -184,7 +184,7 @@ def instantiateNetPyNEModelInGeppetto(self, args):
184184
self.geppetto_model = self.model_interpreter.getGeppettoModel(netpyne_model)
185185

186186
return json.loads(GeppettoModelSerializer.serialize(self.geppetto_model))
187-
except Exception:
187+
except Exception as e:
188188
message = "Error while instantiating the NetPyNE model"
189189
logging.exception(message)
190190
return utils.getJSONError(message, sys.exc_info())

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()

webapp/Main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ Sentry.init({
1919
new CaptureConsole({
2020
levels: ['error']
2121
})
22-
, new Integrations.BrowserTracing()
2322
],
24-
tracesSampleRate: 1.0,
23+
tracesSampleRate: 1.0
2524
});
2625

2726
initGeppetto();

webapp/components/experiments/ExperimentEdit.js

Lines changed: 81 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ import Utils from '../../Utils';
2525
import ParameterMenu from './ParameterMenu';
2626
import useStyles from './ExperimentEditStyle';
2727
import * as ExperimentHelper from './ExperimentHelper';
28+
import DialogBox from '../general/DialogBox';
2829

2930
const RANGE_VALUE = 0;
3031
const SUPPORTED_TYPES = [REAL_TYPE.INT, REAL_TYPE.FLOAT, REAL_TYPE.STR, REAL_TYPE.BOOL];
32+
const MAX_TRIALS = 100;
3133

3234
const {
3335
RANGE,
@@ -189,11 +191,14 @@ const ExperimentEdit = (props) => {
189191
const [experimentName, setExperimentName] = useState('');
190192
const [experimentNameError, setExperimentNameError] = useState('');
191193
const [selectionParams, setSelectionParams] = useState([]);
194+
const [trialNumberErrorDialogOpen, setTrialNumberErrorDialogOpen] = useState({ condition: false, number: 1 });
192195

193196
// Existing Experiment.
194197
const [experiment, setExperiment] = useState(null);
195198
const experiments = useSelector((state) => state.experiments.experiments);
196199

200+
let numberOfTrials = 1;
201+
197202
const validateParameter = (param) => {
198203
let updatedParam = param;
199204
if (param.type === LIST) {
@@ -339,7 +344,19 @@ const ExperimentEdit = (props) => {
339344
params,
340345
};
341346

342-
if (editState) {
347+
numberOfTrials = 1;
348+
349+
params.forEach((param) => {
350+
if (param.type === LIST) {
351+
numberOfTrials *= param.values.length;
352+
} else if (param.type === RANGE) {
353+
numberOfTrials *= Math.ceil((param.max - param.min) / param.step);
354+
}
355+
});
356+
357+
if (numberOfTrials > MAX_TRIALS) {
358+
setTrialNumberErrorDialogOpen({ condition: true, number: numberOfTrials });
359+
} else if (editState) {
343360
ExperimentsApi.editExperiment(experiment?.name, newExperimentDetails)
344361
.then(() => {
345362
setView(EXPERIMENT_VIEWS.list);
@@ -467,34 +484,35 @@ const ExperimentEdit = (props) => {
467484
};
468485

469486
return (
470-
<GridLayout className={classes.root}>
471-
<Box className="editExperimentContainer">
472-
<Box my={3} className="editExperimentBack">
473-
<ArrowBackIcon onClick={() => setView(EXPERIMENT_VIEWS.list)} />
474-
<Typography variant="body2">{!editState ? 'New Experiment' : 'Edit Experiment'}</Typography>
475-
</Box>
476-
<Box mb={2} className="editExperimentHead">
477-
<form noValidate autoComplete="off">
478-
<TextField
479-
id="experiment-name"
480-
label="Experiment Name"
481-
variant="filled"
482-
value={experimentName}
483-
onChange={(e) => setExperimentNameInfo(e.target.value)}
484-
error={experimentNameError !== ''}
485-
helperText={experimentNameError}
486-
/>
487-
</form>
488-
<Box mt={3}>
489-
<Divider />
487+
<>
488+
<GridLayout className={classes.root}>
489+
<Box className="editExperimentContainer">
490+
<Box my={3} className="editExperimentBack">
491+
<ArrowBackIcon onClick={() => setView(EXPERIMENT_VIEWS.list)} />
492+
<Typography variant="body2">{!editState ? 'New Experiment' : 'Edit Experiment'}</Typography>
490493
</Box>
491-
</Box>
492-
<Box className="editExperimentContent">
493-
<Box mb={1} className="editExperimentDefault">
494-
<Box mb={2} className="editExperimentBreadcrumb">
495-
<Typography variant="body2">Parameters</Typography>
494+
<Box mb={2} className="editExperimentHead">
495+
<form noValidate autoComplete="off">
496+
<TextField
497+
id="experiment-name"
498+
label="Experiment Name"
499+
variant="filled"
500+
value={experimentName}
501+
onChange={(e) => setExperimentNameInfo(e.target.value)}
502+
error={experimentNameError !== ''}
503+
helperText={experimentNameError}
504+
/>
505+
</form>
506+
<Box mt={3}>
507+
<Divider />
496508
</Box>
497-
{groupParameters.length > 0 && (
509+
</Box>
510+
<Box className="editExperimentContent">
511+
<Box mb={1} className="editExperimentDefault">
512+
<Box mb={2} className="editExperimentBreadcrumb">
513+
<Typography variant="body2">Parameters</Typography>
514+
</Box>
515+
{groupParameters.length > 0 && (
498516
<Box mb={2} className="editExperimentGroup">
499517
<Box mb={2} className="editExperimentBreadcrumb">
500518
<Typography variant="body2">Grouped Parameters</Typography>
@@ -512,43 +530,53 @@ const ExperimentEdit = (props) => {
512530
</Box>
513531
)}
514532
</Box>
515-
)}
516-
{selectionParams.length > 0 && (
533+
)}
534+
{selectionParams.length > 0 && (
517535
<Box className="editExperimentRow">
518536
{parameters.map((parameter, index) => (
519537
ParameterRow(parameter, index, handleParamSelection, handleChange,
520538
handleRangeInput, handleInputValues, addToGroup, removeFromGroup,
521539
removeParameter, selectionParams, classes)
522540
))}
523541
</Box>
524-
)}
542+
)}
543+
</Box>
544+
</Box>
545+
<Box>
546+
<Link to="true" color="primary" onClick={addParameter}>
547+
<AddIcon />
548+
Add parameter
549+
</Link>
525550
</Box>
526551
</Box>
527-
<Box>
528-
<Link to="true" color="primary" onClick={addParameter}>
529-
<AddIcon />
530-
Add parameter
531-
</Link>
532-
</Box>
533-
</Box>
534-
<Box
535-
className="scrollbar scrollchild"
536-
mt={1}
537-
display="flex"
538-
flexWrap="wrap"
539-
>
540-
<Box className="editExperimentFooter">
541-
<Box display="flex">
542-
<Button color="secondary" onClick={() => setView(EXPERIMENT_VIEWS.list)}>
543-
Cancel
544-
</Button>
545-
<Button variant="contained" color="primary" onClick={submit}>
546-
{editState ? 'Save' : 'Create'}
547-
</Button>
552+
<Box
553+
className="scrollbar scrollchild"
554+
mt={1}
555+
display="flex"
556+
flexWrap="wrap"
557+
>
558+
<Box className="editExperimentFooter">
559+
<Box display="flex">
560+
<Button color="secondary" onClick={() => setView(EXPERIMENT_VIEWS.list)}>
561+
Cancel
562+
</Button>
563+
<Button variant="contained" color="primary" onClick={submit}>
564+
{editState ? 'Save' : 'Create'}
565+
</Button>
566+
</Box>
548567
</Box>
549568
</Box>
550-
</Box>
551-
</GridLayout>
569+
</GridLayout>
570+
<DialogBox
571+
open={trialNumberErrorDialogOpen.condition}
572+
onDialogResponse={() => setTrialNumberErrorDialogOpen({ condition: false, number: 1 })}
573+
textForDialog={{
574+
heading: 'Error - Number of conditions is too large',
575+
content: `Please change your exploration parameters to
576+
reduce the number of experimental conditions to less than 100. Last number of conditions: ${trialNumberErrorDialogOpen.number}`,
577+
}}
578+
/>
579+
</>
552580
);
553581
};
554582

webapp/components/experiments/ExperimentView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ function EnhancedTableHead (props) {
269269
id: 'name',
270270
numeric: false,
271271
disablePadding: true,
272-
label: 'TRIAL NAME',
272+
label: 'EXPERIMENTAL CONDITIONS',
273273
},
274274
...paramHeaders,
275275
];
@@ -564,7 +564,7 @@ const ExperimentView = (props) => {
564564
experimentFinished={experimentFinished}
565565
/>
566566
<TableBody>
567-
{stableSort(filteredRows, getComparator(order, orderBy))
567+
{stableSort(filteredRows, getComparator(order, 'indices'))
568568
.slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
569569
.map((row) => (
570570
<TableRow tabIndex={-1} key={row.name}>

webapp/components/general/GeppettoJupyterUtils.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const handle_output = function (data) {
1010
GEPPETTO.trigger(GEPPETTO.Events.Hide_spinner);
1111
break;
1212
case 'execute_result':
13-
console.log(data.content.data['text/plain'].trim(), true);
1413
try {
1514
var response = JSON.parse(data.content.data['text/plain'].replace(/^'(.*)'$/, '$1'));
1615
} catch (error) {
@@ -27,7 +26,6 @@ const handle_output = function (data) {
2726
};
2827

2928
const execPythonMessage = function (command, callback = handle_output) {
30-
console.log(`Executing Python command: ${command}`, true);
3129
const { kernel } = IPython.notebook;
3230
const messageID = kernel.execute(command, { iopub: { output: callback } }, { silent: false, stop_on_error: true, store_history: true });
3331

webapp/components/general/PlotViewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import HTMLViewer from '../index';
2+
import HTMLViewer from './HTMLViewer';
33

44
const PlotViewer = ({ key, id, method }) => {
55
const data = window.plotCache[id];

webapp/components/index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,6 @@ export const SelectCellTemplate = connect(
357357
}),
358358
)(_SelectCellTemplate);
359359

360-
export const PlotViewer = connect(
361-
null,
362-
null,
363-
)(_PlotViewer);
364360
// ---------------------------------------------------------------------------------------- //
365361

366362
// DEFAULTS

webapp/components/instantiation/NetPyNEInstantiated.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import CameraControls from '@metacell/geppetto-meta-ui/camera-controls/CameraCon
77
// import ControlPanel from 'geppetto-client/js/components/interface/controlPanel/controlpanel';
88

99
import { NetWorkControlButtons } from 'netpyne/components';
10-
import { primaryColor, canvasBgDark, canvasBgLight } from '../../theme';
10+
import { primaryColor, canvasBgDark, canvasBgLight, bgRegular } from '../../theme';
1111
import { THEMES } from '../../constants';
1212

1313
const CANVAS_LIGHT = 'canvas-toolbar-btns-light';
@@ -222,7 +222,7 @@ class NetPyNEInstantiated extends React.Component {
222222
cameraOptions={camOptions}
223223
key="CanvasContainer"
224224
data={canvasData}
225-
backgroundColor="#000000"
225+
backgroundColor={bgRegular}
226226
/>
227227
<div id="controlpanel" style={{ top: 0 }}>
228228
{/* TODO: refactor the control panel with the list viewer

0 commit comments

Comments
 (0)