Repository: MetaCell/NetPyNE-UI (language: python)

Issue:
NETPYNE-184 fix dev deployment



Discussion / hints:

Fix patch:
diff --git a/Dockerfile b/Dockerfile
index 26e69b30..bb4b2b5f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,67 +1,88 @@
-FROM node:14.21.3-bullseye as jsbuild
+FROM node:14 as jsbuild
 
-WORKDIR /app
-
-COPY --chown=1000:1000 webapp/package.json .
-COPY --chown=1000:1000 webapp/yarn.lock .
+ENV FOLDER=netpyne
+RUN echo "no-cache 2023-7-14"
 
+WORKDIR $FOLDER/webapp
+COPY webapp/package.json .
+COPY webapp/yarn.lock .
 
 RUN yarn install  --network-timeout 1000000000
 
-COPY webapp/ .
+COPY webapp .
 RUN yarn build-dev
 
-
 RUN rm -Rf node_modules/*
 
+
+
 ###
 FROM jupyter/base-notebook:hub-1.5.0
 ENV NB_UID=jovyan
 ENV FOLDER=netpyne
-ARG BUILD_ARGS=""
-ARG WORKSPACE_VERSION=master
-# ARG GEPPETTO_VERSION=development
-# ARG NETPYNE_VERSION=master
-
-ENV FOLDER=/home/jovyan/work/NetPyNE-UI
+ENV NP_LFPYKIT_HEAD_FILE=/home/jovyan/nyhead.mat
 
 USER root
 
 RUN rm -rf /var/lib/apt/lists
 RUN apt-get update -qq &&\
-    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
+    apt-get install python3-tk vim nano unzip git make libtool g++ -qq pkg-config libfreetype6-dev libpng-dev libopenmpi-dev -y
+RUN apt-get install openjdk-11-jre-headless -y
 RUN conda install python=3.7 -y
 
+
 WORKDIR $FOLDER
-COPY --chown=1000:1000 requirements.txt requirements.txt
-RUN --mount=type=cache,target=/root/.cache python -m pip install --upgrade pip && pip install -r requirements.txt --prefer-binary
+COPY  --chown=1000:1000 requirements.txt requirements.txt
+RUN --mount=type=cache,target=/root/.cache python -m pip install --upgrade pip &&\
+    pip install -r requirements.txt --prefer-binary
+
+COPY . .
+COPY --from=jsbuild --chown=1000:1000 $FOLDER/webapp/build webapp/build
+
+# ToDo: fixme, for now remove the jupyter hub config json file because it overrides the default
+# and thus removes the frame ancestor cors settings
+RUN rm -f ~/.jupyter/*.json
+RUN chown $NB_UID .
+RUN chown $NB_UID /opt
+RUN rm -Rf workspace
+
+USER $NB_UID
+
+# sym link workspace pvc to $FOLDER
+RUN mkdir -p /opt/workspace
+RUN mkdir -p /opt/user
 
-COPY --chown=jovyan:1000 . .
-COPY --from=jsbuild --chown=jovyan:1000 /app webapp
 
 
+
+ENV NEURON_HOME=/opt/conda
+
+
+USER root
+
 RUN jupyter nbextension install --py --symlink --sys-prefix jupyter_geppetto
 RUN jupyter nbextension enable --py --sys-prefix jupyter_geppetto
 RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension
 RUN jupyter serverextension enable --py --sys-prefix jupyter_geppetto
 
-RUN python utilities/install.py ${BUILD_ARGS} --workspace $WORKSPACE_VERSION
+RUN --mount=type=cache,target=/root/.cache python -m pip install --upgrade pip &&\ 
+  python utilities/install.py --npm-skip --no-test
 
-RUN jupyter labextension disable @jupyterlab/hub-extension
 
-RUN chown  $NB_UID .
-RUN chown -R $NB_UID workspace
+RUN mv workspace /opt/workspace/tutorials
+RUN chown -R $NB_UID /opt/workspace/tutorials
+RUN ln -s /opt/workspace workspace
 
-# Temp fixes for eeg plots
-ENV NEURON_HOME=/opt/conda
-# For lfpykit 0.4
-# RUN wget -P $(pip show LFPykit | grep "Location:" | awk '{print $2"/lfpykit"}') https://www.parralab.org/nyhead/sa_nyhead.mat
-# For lpfykit 0.5
-ENV NP_LFPYKIT_HEAD_FILE=/home/jovyan/nyhead.mat
+RUN jupyter labextension disable @jupyterlab/hub-extension
 RUN wget --no-check-certificate -O $NP_LFPYKIT_HEAD_FILE https://www.parralab.org/nyhead/sa_nyhead.mat
 
 USER $NB_UID
 
+
 EXPOSE 8888
 
+ENTRYPOINT ["tini", "-g", "--"]
+
+
 
+CMD ./NetPyNE-UI
diff --git a/jupyter_hub/Dockerfile_spawner b/jupyter_hub/Dockerfile_spawner
index 6c919e57..6a1b503a 100644
--- a/jupyter_hub/Dockerfile_spawner
+++ b/jupyter_hub/Dockerfile_spawner
@@ -16,15 +16,15 @@ RUN /bin/bash -c "INCUBATOR_VER=${INCUBATOR_VER} source activate snakes && pip i
 # Clone NetPyNE-UI and install the development version
 RUN wget https://github.com/MetaCell/NetPyNE-UI/archive/$netpyneuiBranch.zip -q
 RUN unzip $netpyneuiBranch.zip
-WORKDIR /home/jovyan/work/NetPyNE-UI-$netpyneuiBranch/utilities
+WORKDIR /opt/workspace-$netpyneuiBranch/utilities
 RUN /bin/bash -c "source activate snakes && python --version"
 RUN /bin/bash -c "source activate snakes && exec python install.py branch $netpyneuiBranch"
 WORKDIR /home/jovyan
 RUN git clone https://github.com/Neurosim-lab/netpyne_workspace
 WORKDIR /home/jovyan/workspace
-RUN ln -sfn /home/jovyan/work/NetPyNE-UI-$netpyneuiBranch/netpyne_ui/tests tests
+RUN ln -sfn /opt/workspace-$netpyneuiBranch/netpyne_ui/tests tests
 
 # Copy jupyterhub_config
-# RUN cp /home/jovyan/work/NetPyNE-UI-$netpyneuiBranch/jupyterhub_config.py .
+# RUN cp /opt/workspace-$netpyneuiBranch/jupyterhub_config.py .
 
 CMD /bin/bash -c "source activate snakes && exec jupyterhub-singleuser --debug --NotebookApp.default_url=/geppetto --NotebookApp.token='' --library=netpyne_ui"
diff --git a/k8s/cf_values.yaml b/k8s/cf_values.yaml
index 8f8039b4..a20f554e 100644
--- a/k8s/cf_values.yaml
+++ b/k8s/cf_values.yaml
@@ -11,7 +11,7 @@ hub:
   shutdownOnLogout: true
   extraConfig:
     timing: |
-      c.Spawner.notebook_dir = '/home/jovyan/work/NetPyNE-UI'
+      c.Spawner.notebook_dir = '/opt/workspace'
       c.Spawner.default_url = '/geppetto'
     spawner: >-
       c.Spawner.args = ["--library=netpyne_ui"]
diff --git a/k8s/minikube_values.yaml b/k8s/minikube_values.yaml
index 79d1b855..a70ed44d 100644
--- a/k8s/minikube_values.yaml
+++ b/k8s/minikube_values.yaml
@@ -20,7 +20,7 @@ hub:
       c.Spawner.port = 8000
       c.Spawner.http_timeout = 300
       c.Spawner.start_timeout = 300
-      c.Spawner.notebook_dir = '/home/jovyan/work/NetPyNE-UI'
+      c.Spawner.notebook_dir = '/opt/workspace'
       c.Spawner.default_url = '/geppetto'
       c.Spawner.debug = True
       c.Spawner.disable_check_xsrf=True
diff --git a/webapp/GeppettoConfiguration.json b/webapp/GeppettoConfiguration.json
index 5a88d708..f5b97848 100644
--- a/webapp/GeppettoConfiguration.json
+++ b/webapp/GeppettoConfiguration.json
@@ -1,8 +1,8 @@
 {
     "_README" : "http://docs.geppetto.org/en/latest/build.html",
     "contextPath": "org.geppetto.frontend",
-    "useSsl": false,
-    "embedded": false,
+    "useSsl": true,
+    "embedded": true,
     "embedderURL": ["/"],
     "rootRedirect":"",
     "noTest": false,
diff --git a/webapp/components/general/NetPyNEField.js b/webapp/components/general/NetPyNEField.js
index 65f4cd2e..c5b67380 100644
--- a/webapp/components/general/NetPyNEField.js
+++ b/webapp/components/general/NetPyNEField.js
@@ -46,7 +46,11 @@ export default class NetPyNEField extends Component {
         !this.model.split('.')[0].startsWith('simConfig')
         || this.model.split('.')[1].startsWith('analysis')
       ) {
-        Utils.execPythonMessage(`del netpyne_geppetto.${this.model}`);
+        Utils.execPythonMessage(`
+        try:
+          del netpyne_geppetto.${this.model}
+        except KeyError:
+          ...`);
       }
     }
     return value;


Test patch:
diff --git a/tests/frontend/e2e/tests/RxD.test.js b/tests/frontend/e2e/tests/RxD.test.js
index aef64f39..82747916 100644
--- a/tests/frontend/e2e/tests/RxD.test.js
+++ b/tests/frontend/e2e/tests/RxD.test.js
@@ -230,11 +230,7 @@ describe('RxD testing', () => {
 
         await page.waitForSelector('button[aria-selected="true"][id = "simple-tab-1"]')
 
-        const no_regions_text = await page.$$eval('#simple-tabpanel-1', no_regions_text => {
-            return no_regions_text.map(no_regions_text => no_regions_text.innerText)
-        })
-
-        expect(no_regions_text).toContain('There are no Species yet.')
+        await page.waitForSelector('#ip3')
         console.log('Species tab opened')
         await page.waitForTimeout(PAGE_WAIT)
         
diff --git a/tests/frontend/e2e/tests/SaveOpenFile.test.js b/tests/frontend/e2e/tests/SaveOpenFile.test.js
index 7dd8c9bd..396a2858 100644
--- a/tests/frontend/e2e/tests/SaveOpenFile.test.js
+++ b/tests/frontend/e2e/tests/SaveOpenFile.test.js
@@ -382,7 +382,7 @@ describe('Save / Open File testing', () => {
             return pwd_code_outputs.map(pwd_code_output => pwd_code_output.innerText)
         })
 
-        expect(first_code_output[0]).toBe("'/home/jovyan/work/NetPyNE-UI/workspace'")
+        expect(first_code_output[0]).toBe("'/opt/workspace/workspace'")
 
         const code_lines = await python_frame.$$(selectors.PYTHON_CELL_SELECTOR)
 
@@ -398,7 +398,7 @@ describe('Save / Open File testing', () => {
             return cd_code_outputs.map(cd_code_output => cd_code_output.innerText)
         })
 
-        expect(second_code_output[0]).toBe("/home/jovyan/work/NetPyNE-UI/workspace/saved_models/aut_test/src\n")
+        expect(second_code_output[0]).toBe("/opt/workspace/workspace/saved_models/aut_test/src\n")
 
         const ls_code_lines = await python_frame.$$(selectors.PYTHON_CELL_SELECTOR)