Skip to content

Commit eb3b3a3

Browse files
authored
Merge pull request #825 from MetaCell/release/1.1.0
sync master
2 parents 594146c + 421bbd0 commit eb3b3a3

File tree

71 files changed

+5870
-8694
lines changed

Some content is hidden

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

71 files changed

+5870
-8694
lines changed

.github/workflows/tests.yml

+256-256
Large diffs are not rendered by default.

Dockerfile

+64-30
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,101 @@
1-
FROM node:14.21.3-bullseye as jsbuild
1+
FROM node:18 as jsbuild
22

3-
WORKDIR /app
4-
5-
COPY --chown=1000:1000 webapp/package.json .
6-
COPY --chown=1000:1000 webapp/yarn.lock .
3+
ENV FOLDER=netpyne
74

5+
WORKDIR $FOLDER/webapp
6+
COPY webapp/package.json .
7+
COPY webapp/yarn.lock .
88

99
RUN yarn install --network-timeout 1000000000
1010

11-
COPY webapp/ .
11+
COPY webapp .
1212
RUN yarn build-dev
1313

14-
15-
RUN rm -Rf node_modules/*
14+
### Download on a separate stage to run in parallel with buildkit
15+
FROM jupyter/base-notebook:hub-1.5.0 as downloads
16+
USER root
17+
RUN wget --no-check-certificate -O /nyhead.mat https://www.parralab.org/nyhead/sa_nyhead.mat
1618

1719
###
1820
FROM jupyter/base-notebook:hub-1.5.0
1921
ENV NB_UID=jovyan
2022
ENV FOLDER=netpyne
21-
ARG BUILD_ARGS=""
22-
ARG WORKSPACE_VERSION=master
23-
# ARG GEPPETTO_VERSION=development
24-
# ARG NETPYNE_VERSION=master
25-
26-
ENV FOLDER=/home/jovyan/work/NetPyNE-UI
23+
ENV NP_LFPYKIT_HEAD_FILE=/home/jovyan/nyhead.mat
2724

2825
USER root
2926

3027
RUN rm -rf /var/lib/apt/lists
3128
RUN apt-get update -qq &&\
32-
apt-get install python3-tk vim nano unzip git make libtool g++ -qq pkg-config libfreetype6-dev libpng-dev libopenmpi-dev openjdk-11-jre-headless -y -y
29+
apt-get install python3-tk vim nano unzip git make libtool g++ -qq pkg-config libfreetype6-dev libpng-dev libopenmpi-dev -y
30+
RUN apt-get install openjdk-11-jre-headless -y
3331
RUN conda install python=3.7 -y
3432

33+
3534
WORKDIR $FOLDER
36-
COPY --chown=1000:1000 requirements.txt requirements.txt
37-
RUN --mount=type=cache,target=/root/.cache python -m pip install --upgrade pip && pip install -r requirements.txt --prefer-binary
35+
COPY --chown=1000:1000 requirements.txt requirements.txt
36+
RUN --mount=type=cache,target=/root/.cache python -m pip install --upgrade pip &&\
37+
pip install -r requirements.txt --prefer-binary
38+
39+
40+
# ToDo: fixme, for now remove the jupyter hub config json file because it overrides the default
41+
# and thus removes the frame ancestor cors settings
42+
RUN rm -f ~/.jupyter/*.json
43+
RUN chown $NB_UID .
44+
RUN chown $NB_UID /opt
45+
RUN rm -Rf workspace
46+
# sym link workspace pvc to $FOLDER
47+
RUN mkdir -p /opt/workspace
48+
RUN mkdir -p /opt/user
49+
50+
COPY netpyne_ui netpyne_ui
51+
COPY utilities utilities
52+
COPY setup.py .
53+
COPY tests tests
54+
COPY NetPyNE-UI .
55+
COPY README.rst .
56+
COPY requirements-test.txt .
57+
58+
59+
USER $NB_UID
3860

39-
COPY --chown=jovyan:1000 . .
40-
COPY --from=jsbuild --chown=jovyan:1000 /app webapp
4161

4262

63+
64+
ENV NEURON_HOME=/opt/conda
65+
66+
67+
USER root
68+
4369
RUN jupyter nbextension install --py --symlink --sys-prefix jupyter_geppetto
4470
RUN jupyter nbextension enable --py --sys-prefix jupyter_geppetto
4571
RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension
4672
RUN jupyter serverextension enable --py --sys-prefix jupyter_geppetto
4773

48-
RUN python utilities/install.py ${BUILD_ARGS} --workspace $WORKSPACE_VERSION
74+
ARG BUILD_ARGS=""
75+
ARG WORKSPACE_VERSION=master
4976

50-
RUN jupyter labextension disable @jupyterlab/hub-extension
77+
RUN --mount=type=cache,target=/root/.cache python -m pip install --upgrade pip &&\
78+
python utilities/install.py ${BUILD_ARGS} --workspace $WORKSPACE_VERSION --npm-skip
5179

52-
RUN chown $NB_UID .
53-
RUN chown -R $NB_UID workspace
5480

55-
# Temp fixes for eeg plots
56-
ENV NEURON_HOME=/opt/conda
57-
# For lfpykit 0.4
58-
# RUN wget -P $(pip show LFPykit | grep "Location:" | awk '{print $2"/lfpykit"}') https://www.parralab.org/nyhead/sa_nyhead.mat
59-
# For lpfykit 0.5
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
81+
RUN mv workspace /opt/workspace/tutorials
82+
RUN chown -R $NB_UID /opt/workspace
83+
RUN ln -s /opt/workspace workspace
84+
85+
RUN jupyter labextension disable @jupyterlab/hub-extension
86+
87+
COPY --from=downloads --chown=1000:1000 /nyhead.mat $NP_LFPYKIT_HEAD_FILE
88+
COPY --from=jsbuild --chown=1000:1000 $FOLDER/webapp/build webapp/build
6289

90+
RUN chown -R $NB_UID /home/jovyan/.jupyter
91+
RUN touch app.log && chown $NB_UID app.log
6392
USER $NB_UID
6493

94+
6595
EXPOSE 8888
6696

97+
ENTRYPOINT ["tini", "-g", "--"]
98+
99+
67100

101+
CMD ./NetPyNE-UI

README.md

+47-5
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,59 @@ your system and you have had troubles installing it you can opt for the Virtual
3030

3131
### Python Dependencies
3232

33-
We recommend the use of a new python 3 virtual environment:
33+
We recommend the use of a new python 3.7 virtual environment.
34+
Currently, NetPyNE-UI only supports Python 3.7, but that can change in the future.
35+
36+
For NetPyNE-UI, the preferred way of creating a virtual env is to pass by conda/miniconda or mamba/micromamba.
37+
The pyenv tool can be also used, but it requires to be compiled with some special options to have NEURON running properly the simulation using `nrniv`.
38+
The reason behind this is that NEURON is distributed as a Python wheel with a specific option which force NEURON to look for the CPython dynamic lib.
39+
However, pyenv by default installs the static version of the CPython lib, resulting in `nrniv -python` not being able to run.
40+
41+
The way of creating the virtualenv using (mini)conda is the following
42+
43+
```bash
44+
conda create -n netpyne python=3.7
45+
conda activate netpyne
46+
```
47+
48+
Here is how to create the virtualenv using (micro)mamba
49+
50+
```bash
51+
mamba create -n netpyne python=3.7 -c conda-forge
52+
mamba activate netpyne
53+
```
54+
55+
You can also directly create a virtualenv using your `python3` executable, obviously if it's the 3.7 version.
3456

3557
```bash
3658
python3 -m venv npenv
3759
source npenv/bin/activate
3860
```
3961

40-
Or, with conda
62+
If you want to use anyway pyenv, here is how to properly create the virtualenv and activate it.
4163

4264
```bash
43-
conda create -n netpyne python=3.7
44-
conda activate netpyne
65+
env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install --verbose 3.7.17
66+
pyenv virtualenv 3.7.17 netpyne
67+
pyenv shell netpyne
4568
```
4669

4770
### Run install script
4871

72+
When you are in your virtualenv, here is how you can install the "basic" version of NetPyNE-UI:
73+
4974
```bash
5075
python utilities/install.py
5176
```
5277

78+
If you want to have a different version of NetPyNE or geppetto meta, you can pass the version you want to the installer:
79+
80+
```bash
81+
python utilities/install.py --dev --netpyne development --geppetto development --no-test
82+
```
83+
84+
This command will install the `development` version of netpyne and geppetto and disable the tests during the installation.
85+
5386
### Start application
5487

5588
```bash
@@ -62,6 +95,15 @@ For debugging you can use `run.py` instead
6295
python run.py
6396
```
6497

98+
To run the UI in dev mode, you need to run `python run.py` in one terminal, and use `yarn` from the `webapp` folder, using node v14 (use `nvm` if you need to have a different version of node than the one installed on your system):
99+
100+
```bash
101+
cd webapp
102+
yarn start
103+
```
104+
105+
You can then navigate to `http://127.0.0.1:8081/` to access the dev version of the UI.
106+
65107
## Run NetPyNE User Interface in Docker
66108

67109
Ensure that you have Docker installed on your system.
@@ -75,7 +117,7 @@ docker build -t netpyne-ui .
75117
Run the image
76118

77119
```bash
78-
docker run -p 8888:8888 netpyne-ui
120+
docker run -p 8888:8888 netpyne-ui
79121
```
80122

81123
## End-to-end tests

jupyter_hub/Dockerfile_spawner

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ RUN /bin/bash -c "INCUBATOR_VER=${INCUBATOR_VER} source activate snakes && pip i
1616
# Clone NetPyNE-UI and install the development version
1717
RUN wget https://github.com/MetaCell/NetPyNE-UI/archive/$netpyneuiBranch.zip -q
1818
RUN unzip $netpyneuiBranch.zip
19-
WORKDIR /home/jovyan/work/NetPyNE-UI-$netpyneuiBranch/utilities
19+
WORKDIR /opt/workspace-$netpyneuiBranch/utilities
2020
RUN /bin/bash -c "source activate snakes && python --version"
2121
RUN /bin/bash -c "source activate snakes && exec python install.py branch $netpyneuiBranch"
2222
WORKDIR /home/jovyan
2323
RUN git clone https://github.com/Neurosim-lab/netpyne_workspace
2424
WORKDIR /home/jovyan/workspace
25-
RUN ln -sfn /home/jovyan/work/NetPyNE-UI-$netpyneuiBranch/netpyne_ui/tests tests
25+
RUN ln -sfn /opt/workspace-$netpyneuiBranch/netpyne_ui/tests tests
2626

2727
# Copy jupyterhub_config
28-
# RUN cp /home/jovyan/work/NetPyNE-UI-$netpyneuiBranch/jupyterhub_config.py .
28+
# RUN cp /opt/workspace-$netpyneuiBranch/jupyterhub_config.py .
2929

3030
CMD /bin/bash -c "source activate snakes && exec jupyterhub-singleuser --debug --NotebookApp.default_url=/geppetto --NotebookApp.token='' --library=netpyne_ui"

k8s/cf_values.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ hub:
1111
shutdownOnLogout: true
1212
extraConfig:
1313
timing: |
14-
c.Spawner.notebook_dir = '/home/jovyan/work/NetPyNE-UI'
14+
c.Spawner.notebook_dir = '/opt/workspace'
1515
c.Spawner.default_url = '/geppetto'
1616
spawner: >-
17-
c.Spawner.args = ["--library=netpyne_ui"]
17+
c.Spawner.args = ["--library=netpyne_ui", "--NotebookApp.default_url=/geppetto"]
1818
singleuser:
1919
storage:
2020
type: none

k8s/minikube_values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ hub:
2020
c.Spawner.port = 8000
2121
c.Spawner.http_timeout = 300
2222
c.Spawner.start_timeout = 300
23-
c.Spawner.notebook_dir = '/home/jovyan/work/NetPyNE-UI'
23+
c.Spawner.notebook_dir = '/opt/workspace'
2424
c.Spawner.default_url = '/geppetto'
2525
c.Spawner.debug = True
2626
c.Spawner.disable_check_xsrf=True

netpyne_ui/helpers/neuroml.py

+28-16
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
import sys
33
import logging
44
from netpyne.specs import simConfig
5+
from packaging import version
56

7+
import pyneuroml
68
from pyneuroml import pynml
79
from pyneuroml.lems import generate_lems_file_for_neuroml
810
from pyneuroml.pynml import read_neuroml2_file
@@ -13,57 +15,67 @@
1315
def convertLEMSSimulation(lemsFileName, compileMod=True):
1416
"""Converts a LEMS Simulation file
1517
16-
Converts a LEMS Simulation file (https://docs.neuroml.org/Userdocs/LEMSSimulation.html)
17-
pointing to a NeuroML 2 file into the equivalent in NetPyNE
18+
Converts a LEMS Simulation file
19+
(https://docs.neuroml.org/Userdocs/LEMSSimulation.html) pointing to a
20+
NeuroML 2 file into the equivalent in NetPyNE
21+
1822
Returns:
1923
simConfig, netParams for the model in NetPyNE
2024
"""
2125
current_path = os.getcwd()
2226
try:
23-
27+
2428
fullLemsFileName = os.path.abspath(lemsFileName)
25-
tmp_path = os.path.dirname(fullLemsFileName)
29+
tmp_path = os.path.dirname(fullLemsFileName)
2630
if tmp_path:
2731
os.chdir(tmp_path)
2832
logging.info(
2933
"Importing LEMSSimulation with NeuroML 2 network from: %s"
3034
% fullLemsFileName
3135
)
3236

33-
result = pynml.run_lems_with_jneuroml_netpyne(
34-
lemsFileName, only_generate_json=True, exit_on_fail=False)
35-
36-
if result == False:
37-
raise Exception("Error loading lems file")
37+
# feature to return output added in 1.0.9
38+
if version.parse(pyneuroml.__version__) >= version.parse("1.0.9"):
39+
result, output_msg = pynml.run_lems_with_jneuroml_netpyne(
40+
lemsFileName, only_generate_json=True, exit_on_fail=False,
41+
return_string=True, max_memory="1G")
42+
43+
if result is False:
44+
raise Exception(f"Error loading lems file: {output_msg}")
45+
else:
46+
result = pynml.run_lems_with_jneuroml_netpyne(
47+
lemsFileName, only_generate_json=True, exit_on_fail=False,
48+
max_memory="1G")
49+
50+
if result is False:
51+
raise Exception("Error loading lems file")
52+
3853
lems = pynml.read_lems_file(lemsFileName)
3954

4055
np_json_fname = fullLemsFileName.replace('.xml','_netpyne_data.json')
41-
56+
4257
return np_json_fname
4358
finally:
4459
os.chdir(current_path)
4560

4661

47-
48-
4962
def convertNeuroML2(nml2FileName, compileMod=True):
5063
"""Loads a NeuroML 2 file into NetPyNE
5164
Loads a NeuroML 2 file into NetPyNE by creating a new LEMS Simulation
52-
file (https://docs.neuroml.org/Userdocs/LEMSSimulation.html) and using jNeuroML
53-
to convert it.
65+
file (https://docs.neuroml.org/Userdocs/LEMSSimulation.html) and using
66+
jNeuroML to convert it.
5467
5568
Returns:
5669
simConfig, netParams for the model in NetPyNE
5770
"""
5871
current_path = os.getcwd()
5972
try:
6073
fullNmlFileName = os.path.abspath(nml2FileName)
61-
work_path = os.path.dirname(fullNmlFileName)
74+
work_path = os.path.dirname(fullNmlFileName)
6275
if not os.path.exists(work_path):
6376
os.makedirs(work_path)
6477
os.chdir(work_path)
6578
sys.path.append(work_path)
66-
6779

6880
logging.info(
6981
"Importing NeuroML 2 network from: %s"

0 commit comments

Comments
 (0)