Skip to content

Commit fa0c552

Browse files
Merge pull request #734 from MetaCell/release/1.0.0-notebook-fix
Notebook fix sync fix
2 parents 7211166 + 439836c commit fa0c552

26 files changed

Lines changed: 1277 additions & 991 deletions

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ ENV NEURON_HOME=/opt/conda
5757
# For lfpykit 0.4
5858
# RUN wget -P $(pip show LFPykit | grep "Location:" | awk '{print $2"/lfpykit"}') https://www.parralab.org/nyhead/sa_nyhead.mat
5959
# For lpfykit 0.5
60-
RUN wget --no-check-certificate -P ${FOLDER}/workspace https://www.parralab.org/nyhead/sa_nyhead.mat
60+
ENV NP_LFPYKIT_HEAD_FILE=/home/jovyan/nyhead.mat
61+
RUN wget --no-check-certificate -O $NP_LFPYKIT_HEAD_FILE https://www.parralab.org/nyhead/sa_nyhead.mat
6162

6263
USER $NB_UID
6364

netpyne_ui/__init__.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@
1111
"https://d8bf7e40eec34cb9891f6dd8207b5e83@sentry.metacell.us/6"
1212
)
1313

14+
HEAD_MODEL_FILE = os.getenv("NP_LFPYKIT_HEAD_FILE", "sa_nyhead.mat")
15+
1416
def init_eeg():
1517
import sys
1618
from netpyne_ui.constants import HERE
1719
# FIXES library asking for input to download
1820
sys.stdin = open(os.path.join(HERE, "resources/stdin.txt"),'r')
1921
from lfpykit.eegmegcalc import NYHeadModel
2022
try:
21-
NYHeadModel() # Downloads the model if does not exist
23+
NYHeadModel(HEAD_MODEL_FILE) # Downloads the model if does not exist
2224
except:
2325
logging.error("Error initializing the EEG head model", exc_info=True)
2426

25-
from multiprocessing import Process
26-
thread = Process(target = init_eeg)
27-
thread.start()
28-
27+
if not os.path.exists(HEAD_MODEL_FILE):
28+
from multiprocessing import Process
29+
thread = Process(target = init_eeg)
30+
thread.start()
2931

3032
RouteManager.add_controller(api.NetPyNEController)
3133

netpyne_ui/mod_utils.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import logging
12
import shutil
23
import subprocess
34
import os
@@ -26,24 +27,30 @@ def is_loaded_mechanisms():
2627
return True
2728

2829

29-
def loadModMechFiles(compileMod, modFolder):
30+
def loadModMechFiles(compileMod, modFolder, forceRecompile=False):
3031
# Create Symbolic link
3132

32-
if compileMod:
3333
try:
34+
3435
owd = os.getcwd()
35-
modPath = os.path.join(str(modFolder), "x86_64")
36+
if compileMod:
37+
38+
compiledModPath = os.path.join(str(modFolder), "x86_64")
3639

37-
if os.path.exists(modPath):
38-
shutil.rmtree(modPath)
40+
if os.path.exists(compiledModPath) and forceRecompile:
41+
logging.info("Forcing mod files to recompile in %s" % modFolder)
42+
shutil.rmtree(compiledModPath)
3943

40-
os.chdir(modFolder)
41-
subprocess.call(["nrnivmodl"])
42-
os.chdir('..')
44+
if not os.path.exists(compiledModPath):
45+
logging.info("Compiling mod files in %s" % modFolder)
46+
os.chdir(modFolder)
47+
subprocess.call(["nrnivmodl"])
48+
os.chdir('..')
4349

4450
try:
4551
neuron.load_mechanisms(str(modFolder))
4652
except:
53+
logging.exception("Error loading mechanisms")
4754
raise
4855
finally:
4956
os.chdir(owd)

netpyne_ui/netpyne_geppetto.py

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
os.chdir(constants.NETPYNE_WORKDIR_PATH)
4848

49-
neuron.nrn_dll_loaded.append(os.path.join(NETPYNE_WORKDIR_PATH, 'mod')) # Avoids to load workspace modfiles twice
5049

5150
class NetPyNEGeppetto:
5251

@@ -80,17 +79,6 @@ def __init__(self):
8079
if not simulations.local.is_running():
8180
[experiments.set_to_error(e) for e in running_exps]
8281

83-
# sys.stdin = open(os.path.join(constants.HERE, "stdin.txt"),'r') # FIXES library asking for input to download -- eg lfpykit models
84-
85-
# from ipykernel import kernelbase
86-
87-
# def raw_input(self, prompt=''):
88-
# return "y"
89-
# kernelbase.Kernel.raw_input = raw_input
90-
91-
# from lfpykit.eegmegcalc import NYHeadModel
92-
# NYHeadModel()
93-
9482
def getData(self):
9583
return {
9684
"metadata": metadata,
@@ -550,7 +538,7 @@ def importModel(self, modelParameters):
550538
# Shouldn't be specific to Import
551539
sim.clearAll()
552540
try:
553-
loadModMechFiles(modelParameters['compileMod'], modelParameters['modFolder'])
541+
loadModMechFiles(modelParameters['compileMod'], modelParameters['modFolder'], modelParameters.get("forceRecompile", True))
554542
except Exception:
555543
message = "Error while importing/compiling mods"
556544
logging.exception(message)
@@ -592,7 +580,7 @@ def importModel(self, modelParameters):
592580
# Only on import or better before every simulation or network instantiation?
593581
sim.initialize()
594582
return utils.getJSONReply()
595-
except Exception:
583+
except:
596584
message = "Error while importing the NetPyNE model"
597585
logging.exception(message)
598586
return utils.getJSONError(message, sys.exc_info())
@@ -943,10 +931,10 @@ def getAvailableCellTypes(self):
943931
cell_types.add(p)
944932
return sorted(cell_types)
945933

946-
def getAvailableRxDSections(self, selectedRegion):
934+
def getAvailableRxDSections(self, selectedRegion = None):
947935
sections = set([])
948936
sections.add('all')
949-
if selectedRegion in self.netParams.rxdParams.regions and self.netParams.rxdParams.regions[selectedRegion].get('cells'):
937+
if selectedRegion and selectedRegion in self.netParams.rxdParams.regions and self.netParams.rxdParams.regions[selectedRegion].get('cells'):
950938
if 'all' in self.netParams.rxdParams.regions[selectedRegion]['cells']:
951939
for cellRule in self.netParams.cellParams:
952940
for cellSect in self.netParams.cellParams[cellRule]['secs']:

utilities/install.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def main(netpyne_branch, workspace_branch, geppetto_branch=None, skipNpm=False,
125125
cprint("Cloning workspace")
126126
clone(repository=WORKSPACE, branch_or_tag=workspace_branch, folder=WORKSPACE_DIR, cwdp=ROOT_DIR)
127127
cprint("Compiling workspace modules")
128-
compile_mod()
128+
#compile_mod()
129129

130130
if not skipNpm and os.path.exists(os.path.join(DEPS_DIR, META_DIR, JUPYTER_DIR)):
131131
cprint("Building Jupyter Geppetto extension...")

webapp/components/definition/cellRules/NetPyNECellRules.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,8 @@ export default class NetPyNECellRules extends React.Component {
338338
}
339339

340340
componentDidUpdate (prevProps, prevState) {
341+
if (this.props.commands !== prevProps.commands)
342+
this.forceUpdate();
341343
// we need to check if any of the three entities have been renamed and if that's the case change the state for the selection variable
342344
const newCellRuleName = this.hasSelectedCellRuleBeenRenamed(
343345
prevState,

webapp/components/definition/connectivity/NetPyNEConnectivityRules.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ export default class NetPyNEConnectivityRules extends Component {
103103
}
104104

105105
componentDidUpdate (prevProps, prevState) {
106+
if (this.props.commands !== prevProps.commands)
107+
this.forceUpdate();
106108
// we need to check if any of the three entities have been renamed and if that's the case change the state for the selection variable
107109
const newConnectivityRuleName = this.hasSelectedConnectivityRuleBeenRenamed(
108110
prevState,

webapp/components/definition/plots/NetPyNEPlots.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ export default class NetPyNEPlots extends React.Component {
3030
this.handleNewPlot = this.handleNewPlot.bind(this);
3131
}
3232

33+
componentDidUpdate (prevProps, prevState) {
34+
if (this.props.commands !== prevProps.commands)
35+
this.forceUpdate();
36+
}
37+
3338
selectPlot (plot) {
3439
this.setState({ selectedPlot: plot });
3540
}

webapp/components/definition/stimulationTargets/NetPyNEStimulationTargets.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ export default class NetPyNEStimulationTargets extends Component {
9494
}
9595

9696
componentDidUpdate (prevProps, prevState) {
97+
if (this.props.commands !== prevProps.commands)
98+
this.forceUpdate();
9799
const newStimulationTargetName = this.hasSelectedStimulationTargetBeenRenamed(
98100
prevState,
99101
this.state,

webapp/components/general/AdapterComponent.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export default class AdapterComponent extends Component {
2727
}
2828

2929
componentDidUpdate (prevProps, prevState) {
30+
if (this.props.commands !== prevProps.commands)
31+
this.forceUpdate();
3032
const newValue = this.props.convertFromPython(prevProps, prevState, this.props.value);
3133
if (newValue != undefined) {
3234
this.setState(newValue);

0 commit comments

Comments
 (0)