Skip to content

Commit 181a11f

Browse files
committed
Merged conflicts
2 parents 42ca516 + b9632b3 commit 181a11f

30 files changed

Lines changed: 983 additions & 1218 deletions

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ RUN jupyter nbextension enable --py --sys-prefix jupyter_geppetto
4646
RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension
4747
RUN jupyter serverextension enable --py --sys-prefix jupyter_geppetto
4848

49-
RUN python utilities/install.py ${BUILD_ARGS} --geppetto ${GEPPETTO_VERSION} --netpyne $NETPYNE_VERSION --workspace WORKSPACE_VERSION --npm-skip
49+
RUN python utilities/install.py ${BUILD_ARGS} --geppetto ${GEPPETTO_VERSION} --workspace WORKSPACE_VERSION --npm-skip
5050

5151
RUN jupyter labextension disable @jupyterlab/hub-extension
5252

netpyne_ui/mod_utils.py

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,22 @@ def is_loaded_mechanisms():
2828

2929
def loadModMechFiles(compileMod, modFolder):
3030
# Create Symbolic link
31-
if compileMod:
32-
modPath = os.path.join(str(modFolder), "x86_64")
33-
34-
if os.path.exists(modPath):
35-
shutil.rmtree(modPath)
3631

37-
os.chdir(modFolder)
38-
subprocess.call(["nrnivmodl"])
39-
os.chdir('..')
40-
41-
try:
42-
neuron.load_mechanisms(str(modFolder))
43-
except:
44-
raise
32+
if compileMod:
33+
try:
34+
owd = os.getcwd()
35+
modPath = os.path.join(str(modFolder), "x86_64")
36+
37+
if os.path.exists(modPath):
38+
shutil.rmtree(modPath)
39+
40+
os.chdir(modFolder)
41+
subprocess.call(["nrnivmodl"])
42+
os.chdir('..')
43+
44+
try:
45+
neuron.load_mechanisms(str(modFolder))
46+
except:
47+
raise
48+
finally:
49+
os.chdir(owd)

netpyne_ui/netpyne_geppetto.py

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import json
1414
import logging
1515
import os
16+
from pathlib import Path
1617
import pprint
1718
import re
1819
import sys
@@ -511,7 +512,32 @@ def _create3D_shapes(self, json_path: str):
511512
# Load again because gatherData removed simData
512513
sim.loadSimData(json_path)
513514

515+
def loadFromIndexFile(self, json_path: str):
516+
cfg, netParams = sim.loadModel(json_path, loadMechs=True, ignoreMechAlreadyExistsError=True)
517+
self.simConfig = cfg
518+
self.netParams = netParams
514519

520+
if isinstance(self.netParams, dict):
521+
self.netParams = specs.NetParams(self.netParams)
522+
523+
if isinstance(self.simConfig, dict):
524+
self.simConfig = specs.SimConfig(self.simConfig)
525+
526+
for key, value in self.netParams.cellParams.items():
527+
if hasattr(value, 'todict'):
528+
self.netParams.cellParams[key] = value.todict()
529+
530+
# TODO: when should sim.initialize be called?
531+
# Only on import or better before every simulation or network instantiation?
532+
sim.initialize()
533+
534+
def saveToIndexFile(self, srcPath, dstPath, exportNetParamsAsPython, exportSimConfigAsPython):
535+
sim.saveModel(netParams=self.netParams,
536+
simConfig=self.simConfig,
537+
srcPath=srcPath,
538+
dstPath=dstPath,
539+
exportNetParamsAsPython=exportNetParamsAsPython,
540+
exportSimConfigAsPython=exportSimConfigAsPython)
515541

516542
def importModel(self, modelParameters):
517543
""" Imports a model stored in form of Python files.
@@ -575,7 +601,7 @@ def importModel(self, modelParameters):
575601

576602
def importNeuroML(self, modelParameters):
577603
from netpyne_ui.helpers import neuroml
578-
604+
579605

580606
try:
581607
# Get Current dir
@@ -584,9 +610,9 @@ def importNeuroML(self, modelParameters):
584610
with redirect_stdout(sys.__stdout__):
585611
# NetParams
586612
filename = str(modelParameters["fileName"])
587-
613+
588614
json_fname = neuroml.convertNeuroML2(filename, compileMod=modelParameters["compileMod"])
589-
615+
590616
return self.loadModel(args=dict(
591617
compileMod=True,
592618
modFolder=os.path.dirname(json_fname),
@@ -605,7 +631,7 @@ def importNeuroML(self, modelParameters):
605631

606632
def importLEMS(self, modelParameters):
607633
from netpyne_ui.helpers import neuroml
608-
634+
609635

610636
try:
611637
# Get Current dir
@@ -614,7 +640,7 @@ def importLEMS(self, modelParameters):
614640
with redirect_stdout(sys.__stdout__):
615641
# NetParams
616642
filename = str(modelParameters["fileName"])
617-
643+
618644
json_fname = neuroml.convertLEMSSimulation(filename)
619645

620646
return self.loadModel(args=dict(
@@ -789,10 +815,21 @@ def getPlotSettings(self, plot_name):
789815
return self.simConfig.analysis[plot_name]
790816
return {}
791817

792-
def getDirList(self, dir=None, onlyDirs=False, filterFiles=False):
793-
# Get Current dir
818+
def checkFileExists(self, path):
819+
path = Path(path or '')
820+
return path.exists()
821+
822+
def getFullPath(self, dir, subDir):
794823
if dir is None or dir == '':
795-
dir = os.path.join(os.getcwd(), constants.NETPYNE_WORKDIR_PATH)
824+
base = constants.NETPYNE_WORKDIR_PATH
825+
if subDir:
826+
base = os.path.join(base, subDir)
827+
dir = os.path.join(os.getcwd(), base)
828+
return dir
829+
830+
def getDirList(self, dir=None, onlyDirs=False, filterFiles=False, subDir=None):
831+
# Get Current dir
832+
dir = self.getFullPath(dir, subDir)
796833
dir_list = []
797834
file_list = []
798835
for f in sorted(os.listdir(str(dir)), key=str.lower):
@@ -810,6 +847,13 @@ def checkAvailablePlots(self):
810847
def getPlot(self, plotName, LFPflavour, theme='gui'):
811848
try:
812849
with redirect_stdout(sys.__stdout__):
850+
availablePlots = self.checkAvailablePlots()
851+
checkCondition = availablePlots.get(plotName.replace('iplot', 'plot'), False)
852+
853+
if checkCondition is False:
854+
logging.info("Plot " + plotName + " not available")
855+
return -1
856+
813857
args = self.getPlotSettings(plotName)
814858
if LFPflavour:
815859
args['plots'] = [LFPflavour]

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jupyterthemes==0.20.0
3434
kiwisolver==1.2.0
3535
lesscpy==0.14.0
3636
libNeuroML==0.4.0
37-
lfpykit==0.5
37+
lfpykit==0.5.1
3838
lxml==4.5.1
3939
Mako==1.1.0
4040
MarkupSafe==1.1.1
@@ -44,7 +44,7 @@ mistune==0.8.4
4444
multimethod==1.3
4545
nbconvert==5.6.1
4646
nbformat==5.0.6
47-
netpyne==1.0.3.1
47+
netpyne==1.0.4.1
4848
NEURON==8.2.2
4949
numpy==1.18.5
5050
oauthlib==3.0.1

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
setuptools.setup(
2020
name="netpyne_ui",
21-
version="0.9.1",
21+
version="1.0.0",
2222
url="https://github.com/MetaCell/NetPyNE-UI",
2323
author="MetaCell",
2424
author_email="info@metacell.us",
@@ -41,8 +41,8 @@
4141
],
4242
install_requires=[
4343
'jupyter-geppetto>=1.0.0',
44-
'NEURON>=8.0.2',
45-
'netpyne>=1.0.3.1',
44+
'NEURON>=8.2.2',
45+
'netpyne>=1.0.4.1',
4646
'neuromllite==0.5.1',
4747
'pyNeuroML>=0.7.1',
4848
'sentry_sdk>=1.5.2',

webapp/Main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { LoadingSpinner } from '@metacell/geppetto-meta-client/components';
88
import { NetPyNE } from './components';
99
import theme from './theme';
1010
import store from './redux/store';
11-
import '@metacell/geppetto-meta-ui/flex-layout/style/dark.scss';
11+
import '@metacell/geppetto-meta-ui/flex-layout/style/dark.css';
1212

1313
global.GEPPETTO_CONFIGURATION = require('./GeppettoConfiguration.json');
1414
const { initGeppetto } = require('@metacell/geppetto-meta-client/GEPPETTO');

webapp/components/NetPyNE.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
LaunchDialog,
1313
TutorialObserver
1414
} from 'netpyne/components';
15-
15+
import { loadModel } from '../redux/actions/general';
1616

1717
const styles = ({ zIndex }) => ({
1818
root: {
@@ -41,15 +41,11 @@ const styles = ({ zIndex }) => ({
4141
});
4242

4343

44-
4544
class NetPyNE extends React.Component {
4645
constructor (props) {
4746
super(props);
4847
this.openPythonCallDialog = this.openPythonCallDialog.bind(this);
49-
}
50-
51-
componentDidUpdate() {
52-
console.log('updated')
48+
this.loaded = false;
5349
}
5450

5551
componentDidMount () {
@@ -60,6 +56,35 @@ class NetPyNE extends React.Component {
6056
} = this.props;
6157

6258
setDefaultWidgets();
59+
60+
// Listen messages
61+
const loadFromEvent = (event) => {
62+
// Here we would expect some cross-origin check, but we don't do anything more than load a model here
63+
switch (event.data.type) {
64+
case 'INIT_INSTANCE':
65+
if (this.loaded) {
66+
return;
67+
}
68+
this.loaded = true;
69+
console.log('Netpyne is ready');
70+
if (window !== window.parent) {
71+
window.parent.postMessage({
72+
type: 'APP_READY',
73+
}, '*');
74+
}
75+
break;
76+
case 'LOAD_RESOURCE':
77+
// eslint-disable-next-line no-case-declarations
78+
const resource = event.data.payload;
79+
this.props.dispatchAction(loadModel(resource));
80+
break;
81+
default:
82+
break;
83+
}
84+
};
85+
// A message from the parent frame can specify the file to load
86+
window.addEventListener('message', loadFromEvent);
87+
// window.load = loadFromEvent
6388
}
6489

6590
componentWillUnmount () {
@@ -80,8 +105,6 @@ class NetPyNE extends React.Component {
80105
}
81106
}
82107

83-
84-
85108
render () {
86109
const { classes } = this.props;
87110

webapp/components/definition/connectivity/NetPyNEConnectivityRule.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,12 +198,9 @@ export default class NetPyNEConnectivityRule extends React.Component {
198198
`netParams.connParams['${this.props.name}']['synMech']`
199199
}
200200
fullWidth
201+
multiple
201202
method="netpyne_geppetto.getAvailableSynMech"
202-
postProcessItems={(pythonData, selected) => pythonData.map((name) => (
203-
<MenuItem id={`${name}MenuItem`} key={name} value={name}>
204-
{name}
205-
</MenuItem>
206-
))}
203+
postProcessItems={this.postProcessMenuItems}
207204
/>
208205
</NetPyNEField>
209206

webapp/components/general/Dialog.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ const AboutContent = withStyles(styles)(({ classes }) => (
2626
<img width="250" src={logoNetpyne} />
2727
<Box m={1}>
2828
<Link variant="h5" style={{ display: 'block' }} href="https://github.com/MetaCell/NetPyNE-UI" target="_blank">
29-
NetPyNE-UI v0.9.1
29+
NetPyNE-UI v1.0.0
3030
</Link>
3131
<Link variant="h5" style={{ display: 'block' }} href="https://github.com/Neurosim-lab/netpyne" target="_blank">
32-
NetPyNE v1.0.3.1
32+
NetPyNE v1.0.4.1
3333
</Link>
3434
<Link variant="h5" style={{ display: 'block' }} href="https://www.neuron.yale.edu/neuron/" target="_blank">
35-
NEURON v8.0.2
35+
NEURON v8.2.2
3636
</Link>
3737
</Box>
3838

3939
<Box m={1}>
4040
<Typography variant="body2" color={secondaryColor}>
4141
NetPyNE is a Python package to facilitate the development, simulation,
4242
parallelization, and analysis of biological neuronal networks using the
43-
NEURON simulator. Checkout our
43+
NEURON simulator. Check out our
4444
{' '}
4545
<Link href="https://elifesciences.org/articles/44494" target="_blank">
4646
eLife paper.

0 commit comments

Comments
 (0)