Skip to content

Commit 2d65667

Browse files
Migration to Jupyterlab (#4830)
Description of changes: - migrate to JupyterLab (fixes #4789) - bump Sphinx version requirements - use `python3 -m pip` in place of the deprecated `pip3` command - use `requirements.txt` as a constraint file to avoid version number inconsistencies with the user guide
2 parents 2c14952 + f632143 commit 2d65667

33 files changed

+1836
-1344
lines changed

.github/workflows/push_pull.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
debian:
3636
runs-on: ubuntu-latest
3737
container:
38-
image: ghcr.io/espressomd/docker/debian:fbdf2f2f9d76b761c0aa1308f17fb17e38501850-base-layer
38+
image: ghcr.io/espressomd/docker/debian:339903979196fd7e72127f2cb5bfb27759d129f9-base-layer
3939
credentials:
4040
username: ${{ github.actor }}
4141
password: ${{ secrets.github_token }}
@@ -74,7 +74,7 @@ jobs:
7474
runs-on: ubuntu-latest
7575
if: ${{ github.repository == 'espressomd/espresso' }}
7676
container:
77-
image: ghcr.io/espressomd/docker/ubuntu-wo-dependencies:fbdf2f2f9d76b761c0aa1308f17fb17e38501850-base-layer
77+
image: ghcr.io/espressomd/docker/ubuntu-wo-dependencies:339903979196fd7e72127f2cb5bfb27759d129f9-base-layer
7878
credentials:
7979
username: ${{ github.actor }}
8080
password: ${{ secrets.github_token }}

.gitlab-ci.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
image: ghcr.io/espressomd/docker/ubuntu-22.04:fbdf2f2f9d76b761c0aa1308f17fb17e38501850
1+
image: ghcr.io/espressomd/docker/ubuntu-22.04:339903979196fd7e72127f2cb5bfb27759d129f9
22

33
stages:
44
- prepare
@@ -144,7 +144,7 @@ no_rotation:
144144
fedora:36:
145145
<<: *global_job_definition
146146
stage: build
147-
image: ghcr.io/espressomd/docker/fedora:fbdf2f2f9d76b761c0aa1308f17fb17e38501850
147+
image: ghcr.io/espressomd/docker/fedora:339903979196fd7e72127f2cb5bfb27759d129f9
148148
variables:
149149
with_cuda: 'false'
150150
with_gsl: 'false'
@@ -390,6 +390,7 @@ installation:
390390
- bash maintainer/CI/build_cmake.sh
391391
- cd build
392392
- make install
393+
- cmake . -D ESPRESSO_BUILD_TESTS=ON
393394
# get path of installed files
394395
- CI_INSTALL_DIR="/tmp/espresso-unit-tests"
395396
- CI_INSTALL_PYTHON_PATH=$(dirname $(find "${CI_INSTALL_DIR}/lib" -name espressomd))
@@ -398,9 +399,9 @@ installation:
398399
- cp -r "src/python/object_in_fluid" "${CI_INSTALL_PYTHON_PATH}/object_in_fluid"
399400
# run all tests with the installed files
400401
- sed -i "s|$(pwd)/pypresso|${CI_INSTALL_DIR}/bin/pypresso|" testsuite/{python,scripts/samples,scripts/tutorials}/CTestTestfile.cmake
401-
- make -j ${CI_CORES} check_python_skip_long
402-
- make -j ${CI_CORES} check_samples
403-
- make -j 2 check_tutorials
402+
- make check_python_skip_long
403+
- make check_samples
404+
- make check_tutorials
404405
tags:
405406
- espresso
406407
- cuda

doc/sphinx/conf.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ sys.path.insert(0, '@CMAKE_BINARY_DIR@/src/python')
2424
# -- General configuration ------------------------------------------------
2525

2626
# If your documentation needs a minimal Sphinx version, state it here.
27-
needs_sphinx = '2.3'
27+
needs_sphinx = '3.5'
2828

2929
# Add any Sphinx extension module names here, as strings. They can be
3030
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom

doc/sphinx/installation.rst

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ To generate the Sphinx documentation, install the following packages:
175175

176176
.. code-block:: bash
177177
178-
pip3 install --user -c requirements.txt \
178+
python3 -m pip install --user -c requirements.txt \
179179
sphinx sphinxcontrib-bibtex sphinx-toggleprompt
180180
181181
To generate the Doxygen documentation, install the following packages:
@@ -197,40 +197,36 @@ To run the samples and tutorials, start by installing the following packages:
197197
198198
The tutorials are written in the
199199
`Notebook Format <https://nbformat.readthedocs.io/en/latest/>`__
200-
:cite:`kluyver16a` version <= 4.4 and can be executed by any of these tools:
200+
:cite:`kluyver16a` version 4.5 and can be executed by any of these tools:
201201

202-
* `Jupyter Notebook <https://jupyter-notebook.readthedocs.io/en/stable/notebook.html>`__
203202
* `JupyterLab <https://jupyterlab.readthedocs.io/en/stable/>`__
204-
* `IPython <https://ipython.org/>`__ (not recommended)
205203
* `VS Code Jupyter <https://github.com/microsoft/vscode-jupyter>`__
204+
* `Jupyter Notebook <https://jupyter-notebook.readthedocs.io/en/stable/notebook.html>`__
205+
* `IPython <https://ipython.org/>`__ (not recommended)
206206

207207
To check whether one of them is installed, run these commands:
208208

209209
.. code-block:: bash
210210
211-
jupyter notebook --version
212211
jupyter lab --version
212+
jupyter notebook --version
213213
ipython --version
214214
code --version
215215
216216
If you don't have any of these tools installed and aren't sure which one
217-
to use, we recommend installing the historic Jupyter Notebook, since the
218-
|es| tutorials have been designed with the ``exercise2`` plugin in mind.
219-
220-
To use Jupyter Notebook, install the following packages:
217+
to use, we recommend installing JupyterLab:
221218

222219
.. code-block:: bash
223220
224-
pip3 install --user 'nbformat==5.1.3' 'nbconvert==6.4.5' 'notebook==6.4.8' 'jupyter_contrib_nbextensions==0.5.1'
225-
jupyter contrib nbextension install --user
226-
jupyter nbextension enable rubberband/main
227-
jupyter nbextension enable exercise2/main
221+
python3 -m pip install --user -c requirements.txt \
222+
nbformat nbconvert jupyterlab
228223
229-
Alternatively, to use JupyterLab, install the following packages:
224+
If you prefer the look and feel of Jupyter Classic, install the following:
230225

231226
.. code-block:: bash
232227
233-
pip3 install --user nbformat notebook jupyterlab
228+
python3 -m pip install --user -c requirements.txt \
229+
nbformat nbconvert jupyterlab nbclassic
234230
235231
Alternatively, to use VS Code Jupyter, install the following extensions:
236232

@@ -316,7 +312,7 @@ Run the following commands:
316312
doxygen gsl numpy scipy ipython jupyter freeglut
317313
brew install hdf5-mpi
318314
brew link --force cython
319-
pip install -c requirements.txt PyOpenGL matplotlib
315+
python -m pip install -c requirements.txt PyOpenGL matplotlib
320316
321317
.. _Quick installation:
322318

doc/sphinx/running.rst

Lines changed: 24 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,19 @@ Running a simulation
66
|es| is implemented as a Python module. This means that you need to write a
77
python script for any task you want to perform with |es|. In this chapter,
88
the basic structure of the interface will be explained. For a practical
9-
introduction, see the tutorials, which are also part of the
10-
distribution.
9+
introduction, see the tutorials, which are also part of the distribution.
10+
11+
Most users should consider building and then installing |es| locally.
12+
In this way, |es| behaves like any regular Python package and will
13+
be recognized by the Python interpreter and Jupyter notebooks.
14+
15+
Most developers prefer the ``pypresso`` resp. ``ipypresso`` wrapper scripts,
16+
which export the build folder into the ``$PYTHONPATH`` environment variable
17+
and then call ``python`` resp. ``jupyter``. They also introduce extra command
18+
line options to help developers run simulations inside a debugger.
19+
Command line examples in this chapter use the wrapper scripts instead of the
20+
Python and Jupyter programs, although they are perfectly interchangeable
21+
when not using a debugger.
1122

1223
.. _Running es:
1324

@@ -71,40 +82,25 @@ in the build folder, do:
7182
7283
make tutorials
7384
74-
The tutorials contain solutions hidden with the ``exercise2`` NB extension.
75-
Since this extension is only available for Jupyter Notebook, JupyterLab
76-
users need to convert the tutorials:
77-
78-
.. code-block:: bash
79-
80-
for f in doc/tutorials/*/*.ipynb; do
81-
./pypresso doc/tutorials/convert.py exercise2 --to-jupyterlab ${f}
82-
done
83-
84-
Likewise, VS Code Jupyter users need to convert the tutorials:
85-
86-
.. code-block:: bash
87-
88-
for f in doc/tutorials/*/*.ipynb; do
89-
./pypresso doc/tutorials/convert.py exercise2 --to-vscode-jupyter ${f}
90-
done
85+
The tutorials contain solutions hidden inside disclosure boxes.
86+
Click on "Show solution" to reveal them.
9187

9288
To interact with notebooks, move to the directory containing the tutorials
9389
and call the ``ipypresso`` script to start a local Jupyter session.
9490

95-
For Jupyter Notebook and IPython users:
91+
For JupyterLab users:
9692

9793
.. code-block:: bash
9894
9995
cd doc/tutorials
100-
../../ipypresso notebook
96+
../../ipypresso lab
10197
102-
For JupyterLab users:
98+
For Jupyter Classic users:
10399

104100
.. code-block:: bash
105101
106102
cd doc/tutorials
107-
../../ipypresso lab
103+
../../ipypresso nbclassic
108104
109105
For VS Code Jupyter users, no action is needed if ``pypresso`` was set as
110106
the interpreter path (see details in :ref:`Running inside an IDE`).
@@ -129,29 +125,15 @@ will exit the Python interpreter and Jupyter will notify you that the current
129125
Python kernel stopped. If a cell takes too long to execute, you may interrupt
130126
it with the stop button.
131127

132-
Solutions cells are created using the ``exercise2`` plugin from nbextensions.
133-
To prevent solution code cells from running when clicking on "Run All", these
134-
code cells need to be converted to Markdown cells and fenced with `````python``
135-
and ```````.
128+
Solutions cells are marked up with the code comment ``# SOLUTION CELL``
129+
(must be on the first line). In the build folder, these solution cells
130+
will be automatically converted to Markdown cells.
136131

137132
To close the Jupyter session, go to the terminal where it was started and use
138133
the keyboard shortcut Ctrl+C twice.
139134

140-
When starting a Jupyter session, you may see the following warning in the
141-
terminal:
142-
143-
.. code-block:: none
144-
145-
[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
146-
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future
147-
148-
This only means |es| was compiled with IPython instead of Jupyter. If Jupyter
149-
is installed on your system, the notebook will automatically close IPython and
150-
start Jupyter. To recompile |es| with Jupyter, provide ``cmake`` with the flag
151-
``-D IPYTHON_EXECUTABLE=$(which jupyter)``.
152-
153-
You can find the official Jupyter documentation at
154-
https://jupyter.readthedocs.io/en/latest/running.html
135+
You can find the official JupyterLab documentation at
136+
https://jupyterlab.readthedocs.io/en/latest/user/interface.html
155137

156138
.. _Running inside an IDE:
157139

doc/tutorials/CMakeLists.txt

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,31 +62,23 @@ function(NB_EXPORT)
6262
"${NB_FILE};${NB_EXPORT_ADD_SCRIPTS};${CMAKE_BINARY_DIR}/doc/tutorials/convert.py;${CMAKE_BINARY_DIR}/testsuite/scripts/importlib_wrapper.py"
6363
COMMAND
6464
${CMAKE_BINARY_DIR}/pypresso
65-
${CMAKE_BINARY_DIR}/doc/tutorials/convert.py ci --execute --exercise2
66-
--remove-empty-cells --input ${NB_FILE} --output ${NB_FILE_RUN}
65+
${CMAKE_BINARY_DIR}/doc/tutorials/convert.py ci --execute
66+
--prepare-for-html --input ${NB_FILE} --output ${NB_FILE_RUN}
6767
--substitutions ${NB_EXPORT_VAR_SUBST} --scripts
6868
${NB_EXPORT_ADD_SCRIPTS})
6969
else()
7070
set(NB_FILE_RUN ${NB_FILE})
7171
endif()
7272

7373
add_custom_command(
74-
OUTPUT ${HTML_FILE}
75-
DEPENDS ${NB_FILE_RUN};${NB_EXPORT_ADD_SCRIPTS}
76-
COMMAND
77-
${CMAKE_BINARY_DIR}/pypresso ${CMAKE_BINARY_DIR}/doc/tutorials/convert.py
78-
ci --exercise2 --input ${NB_FILE_RUN} --output ${NB_FILE_RUN}~
74+
OUTPUT ${HTML_FILE} DEPENDS ${NB_FILE_RUN};${NB_EXPORT_ADD_SCRIPTS}
7975
COMMAND ${IPYTHON_EXECUTABLE} nbconvert --to "html" --output ${HTML_FILE}
80-
${NB_FILE_RUN}~)
76+
${NB_FILE_RUN})
8177

8278
add_custom_command(
83-
OUTPUT ${PY_FILE}
84-
DEPENDS ${NB_FILE}
85-
COMMAND
86-
${CMAKE_BINARY_DIR}/pypresso ${CMAKE_BINARY_DIR}/doc/tutorials/convert.py
87-
ci --exercise2 --input ${NB_FILE} --output ${NB_FILE}~
79+
OUTPUT ${PY_FILE} DEPENDS ${NB_FILE}
8880
COMMAND ${IPYTHON_EXECUTABLE} nbconvert --to "python" --output ${PY_FILE}
89-
${NB_FILE}~)
81+
${NB_FILE})
9082

9183
add_custom_target("${NB_EXPORT_TARGET}_html" DEPENDS ${HTML_FILE}
9284
${DEPENDENCY_OF_TARGET})

doc/tutorials/Readme.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ physical systems.
6262
* **Electrodes**
6363
Modelling electrodes and measuring differential capacitance with the ELC method.
6464
[Part 1](electrodes/electrodes_part1.ipynb) |
65-
Part 2 (work in progress)
65+
[Part 2](electrodes/electrodes_part2.ipynb)
6666
* **Constant pH method**
6767
Modelling an acid dissociation curve using the constant pH method.
6868
[Guide](constant_pH/constant_pH.ipynb)
@@ -91,32 +91,12 @@ in the build folder, do:
9191
make tutorials
9292
```
9393

94-
The tutorials contain solutions hidden with the ``exercise2`` extension.
95-
Since this extension is only available for Jupyter Notebook, JupyterLab
96-
users need to convert the tutorials:
97-
98-
```sh
99-
for f in doc/tutorials/*/*.ipynb; do
100-
./pypresso doc/tutorials/convert.py exercise2 --to-jupyterlab ${f};
101-
done
102-
```
103-
10494
All tutorials can be viewed with their solutions
10595
[online](https://espressomd.github.io/doc/tutorials.html).
10696

10797
### Running the tutorials interactively
10898

109-
To view the tutorials, first change to the tutorials directory and then run
110-
the `ipypresso` script from the directory into which espresso was compiled.
111-
112-
For Jupyter Notebook and IPython users:
113-
114-
```sh
115-
cd doc/tutorials
116-
../../ipypresso notebook
117-
```
118-
119-
For JupyterLab users:
99+
To view the tutorials in the build folder, run the following commands:
120100

121101
```sh
122102
cd doc/tutorials

0 commit comments

Comments
 (0)