Skip to content

Commit c562402

Browse files
authored
Merge pull request #710 from MetaCell/feature/netpyne-132
refactoring installation and spinner for plots that requires more time to visualise
2 parents 3ebf7e4 + 7978f8c commit c562402

4 files changed

Lines changed: 241 additions & 234 deletions

File tree

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:13.14 as jsbuild
1+
FROM node:14.21.3-bullseye as jsbuild
22

33
WORKDIR /app
44

@@ -18,10 +18,10 @@ RUN rm -Rf node_modules/*
1818
FROM jupyter/base-notebook:hub-1.5.0
1919
ENV NB_UID=jovyan
2020
ENV FOLDER=netpyne
21-
ARG GEPPETTO_VERSION=development
2221
ARG BUILD_ARGS=""
23-
ARG NETPYNE_VERSION=master
2422
ARG WORKSPACE_VERSION=master
23+
# ARG GEPPETTO_VERSION=development
24+
# ARG NETPYNE_VERSION=master
2525

2626
ENV FOLDER=/home/jovyan/work/NetPyNE-UI
2727

@@ -32,10 +32,9 @@ RUN apt-get update -qq &&\
3232
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
3333
RUN conda install python=3.7 -y
3434

35-
3635
WORKDIR $FOLDER
3736
COPY --chown=1000:1000 requirements.txt requirements.txt
38-
RUN pip install -r requirements.txt --no-cache-dir --prefer-binary
37+
RUN --mount=type=cache,target=/root/.cache python -m pip install --upgrade pip && pip install -r requirements.txt --prefer-binary
3938

4039
COPY --chown=$NB_UID:1000 . .
4140
COPY --from=jsbuild --chown=$NB_UID:1000 /app webapp
@@ -46,7 +45,7 @@ RUN jupyter nbextension enable --py --sys-prefix jupyter_geppetto
4645
RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension
4746
RUN jupyter serverextension enable --py --sys-prefix jupyter_geppetto
4847

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

5150
RUN jupyter labextension disable @jupyterlab/hub-extension
5251

utilities/install.py

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ def checkout(folder, branch_or_tag, cwdp):
7575

7676
print(f'Checking out {branch_or_tag}')
7777
try:
78+
subprocess.call(['git', 'fetch'], cwd=newPath)
7879
subprocess.call(['git', 'checkout', branch_or_tag], cwd=newPath)
80+
subprocess.call(['git', 'pull', 'origin', branch_or_tag], cwd=newPath)
7981
except Exception as e:
8082
logging.error('Cannot checkout branch or tag %s on %s', branch_or_tag, folder, exc_info=True)
8183

@@ -85,30 +87,21 @@ def compile_mod():
8587

8688

8789
def main(netpyne_branch, workspace_branch, geppetto_branch=None, skipNpm=False,
88-
skipTest=False, development=False):
90+
skipTest=False, development=False):
8991
cprint("Installing requirements")
90-
print(workspace_branch)
9192
execute(cmd=['pip', 'install', '-r', 'requirements.txt'], cwd=ROOT_DIR)
93+
cprint("Installing UI python package...")
94+
execute(cmd=['pip', 'install', '-e', '.', '--no-deps'], cwd=ROOT_DIR)
9295

9396
if not os.path.exists(DEPS_DIR):
9497
os.mkdir(DEPS_DIR)
9598

96-
97-
if development:
99+
if geppetto_branch:
100+
if geppetto_branch.replace(" ", "") is '':
101+
geppetto_branch = 'development'
98102
os.chdir(DEPS_DIR)
99-
100-
# cloning geppetto meta
101103
cprint("Installing geppetto-meta")
102-
clone(repository=META,
103-
folder=META_DIR,
104-
branch_or_tag=geppetto_branch
105-
)
106-
107-
# clone and install netpyne
108-
cprint("Installing netpyne")
109-
clone(repository=NETPYNE, branch_or_tag=netpyne_branch)
110-
execute(cmd=['pip', 'install', '-e', '.'], cwd=os.path.join(DEPS_DIR, NETPYNE_DIR))
111-
104+
clone(repository=META, folder=META_DIR, branch_or_tag=geppetto_branch)
112105
# installing pygeppetto
113106
cprint("Installing pygeppetto")
114107
execute(cmd=['pip', 'install', '-e', '.'], cwd=os.path.join(DEPS_DIR, META_DIR, PYGEPPETTO_DIR))
@@ -117,14 +110,15 @@ def main(netpyne_branch, workspace_branch, geppetto_branch=None, skipNpm=False,
117110
execute(cmd=['pip', 'install', '-e', '.'], cwd=os.path.join(DEPS_DIR, META_DIR, JUPYTER_DIR))
118111
# installing core dependencies
119112
execute(cmd=['pip', 'install', '-e', '.'], cwd=ROOT_DIR)
120-
if netpyne_branch and netpyne_branch != 'master':
121-
cprint("Installing netpyne")
122-
clone(repository=NETPYNE, branch_or_tag=netpyne_branch)
123-
execute(cmd=['pip', 'install', '-e', '.'], cwd=os.path.join(DEPS_DIR, NETPYNE_DIR))
124-
else:
125-
# install requirements
126-
cprint("Installing UI python package...")
127-
execute(cmd=['pip', 'install', '-e', '.', '--no-deps'], cwd=ROOT_DIR)
113+
if netpyne_branch:
114+
if netpyne_branch.replace(" ", "") is '':
115+
netpyne_branch = 'development'
116+
os.chdir(DEPS_DIR)
117+
cprint("Installing netpyne")
118+
clone(repository=NETPYNE, branch_or_tag=netpyne_branch)
119+
execute(cmd=['pip', 'install', '-e', '.'], cwd=os.path.join(DEPS_DIR, NETPYNE_DIR))
120+
121+
128122

129123
os.chdir(ROOT_DIR)
130124
if workspace_branch:
@@ -194,7 +188,7 @@ def main(netpyne_branch, workspace_branch, geppetto_branch=None, skipNpm=False,
194188

195189
cprint("Installing client packages")
196190
if not skipNpm:
197-
if development:
191+
if geppetto_branch:
198192
# install geppetto meta
199193
if os.path.exists(os.path.join(WEBAPP_DIR, '.yalc')):
200194
execute(cmd=['rm', '-rf', '.yalc'], cwd=WEBAPP_DIR)
@@ -209,7 +203,7 @@ def main(netpyne_branch, workspace_branch, geppetto_branch=None, skipNpm=False,
209203
else:
210204
# install jupyter geppetto
211205
cprint("Installing geppetto ui, client and core dependecies")
212-
execute(cmd=['yarn', 'install', '--frozen-lockfile'], cwd=WEBAPP_DIR)
206+
execute(cmd=['yarn', 'install', '--immutable'], cwd=WEBAPP_DIR)
213207
execute(cmd=['yarn', 'run', 'build'], cwd=WEBAPP_DIR)
214208

215209

@@ -228,22 +222,22 @@ def main(netpyne_branch, workspace_branch, geppetto_branch=None, skipNpm=False,
228222
help='Install for development.')
229223

230224
parser.add_argument('--netpyne', '-vn', dest='netpyne_version', action="store",
231-
default=os.getenv('NETPYNE_VERSION', 'development'),
225+
default=os.getenv('NETPYNE_VERSION', None),
232226
help='Specify NetPyNE library branch or tag.')
233227

234228
parser.add_argument('--workspace', '-vw', dest='workspace_version', action="store",
235229
default=os.getenv('WORKSPACE_VERSION', 'master'),
236230
help='Specify workspace branch or tag.')
237231

238232
parser.add_argument('--geppetto', '-vp', dest='geppetto_version', action="store",
239-
default=os.getenv('GEPPETTO_VERSION', 'development'),
233+
default=os.getenv('GEPPETTO_VERSION', None),
240234
help='Specify Pygeppetto library branch or tag (only for dev build).')
241235

242236
args = parser.parse_args(sys.argv[1:])
243237
print('Install arguments:\n', args)
244238

245239
main(skipNpm=args.skipNpm, skipTest=args.skipTest, development=args.development,
246-
netpyne_branch=args.netpyne_version,
247-
workspace_branch=args.workspace_version,
248-
geppetto_branch=args.geppetto_version,
249-
)
240+
netpyne_branch=args.netpyne_version,
241+
workspace_branch=args.workspace_version,
242+
geppetto_branch=args.geppetto_version,
243+
)

webapp/components/general/HTMLViewer.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import React, { Component, createRef } from 'react';
33
import HTMLViewer from '@metacell/geppetto-meta-ui/html-viewer/HTMLViewer';
44

55
import { withStyles } from '@material-ui/core/styles';
6+
import { CircularProgress } from '@material-ui/core';
7+
import { primaryColor } from '../../theme';
68

79
const style = ({ palette }) => ({
810
container: {
@@ -44,7 +46,7 @@ class CustomHTMLViewer extends Component {
4446

4547
getSvgComponent () {
4648
// svg element
47-
return this.containerRef.current.children[0].children[0].children[0];
49+
return this.containerRef?.current?.children[0]?.children[0]?.children[0];
4850
}
4951

5052
wasParentResized (dimensions) {
@@ -77,7 +79,20 @@ class CustomHTMLViewer extends Component {
7779
}
7880

7981
render () {
80-
const { classes } = this.props;
82+
const { classes, content } = this.props;
83+
if (content === undefined) {
84+
return (
85+
<CircularProgress
86+
color={primaryColor}
87+
style={{
88+
position: 'absolute',
89+
margin: 'auto',
90+
top: '50%',
91+
left: '50%',
92+
}}
93+
/>
94+
);
95+
}
8196
return (
8297
<div id="plot" className={classes.container} ref={this.containerRef}>
8398
<HTMLViewer {...this.props} style={{ backgroundColor: 'inherit' }} />

0 commit comments

Comments
 (0)