Skip to content

Commit

Permalink
Fix Binder (release/4/dev) (#235)
Browse files Browse the repository at this point in the history
* Update requirements.txt (add simphony-osp-simlammps)

* Use .binder directory

* Use custom docker image for Binder

* Fix minor issues in some notebooks
  • Loading branch information
kysrpex authored Sep 21, 2022
1 parent f2b9adc commit 31afc05
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 18 deletions.
63 changes: 63 additions & 0 deletions .binder/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
FROM debian:bullseye-slim


ENV DEBIAN_FRONTEND=noninteractive


# Install required packages: Jupyter and packages required to run notebooks.
RUN apt-get -qq update && \
apt-get install --yes --no-install-recommends \
wget \
python3 python3-pip \
ipython3 python3-ipykernel \
jupyter jupyter-notebook jupyter-nbconvert \
python3-jupyterlab-server \
python3-lammps \
graphviz ffmpeg && \
apt-get -qq purge && \
apt-get -qq clean && \
rm -rf /var/lib/apt/lists/*

# Hardlink liblammps
RUN ln /usr/lib/x86_64-linux-gnu/liblammps.so.0 /usr/lib/python3/dist-packages/lammps/liblammps.so

# create user with a home directory
ARG NB_USER
ARG NB_UID
ENV USER ${NB_USER}
ENV HOME /home/${NB_USER}

RUN adduser --disabled-password \
--gecos "Default user" \
--uid ${NB_UID} \
${NB_USER}
WORKDIR ${HOME}

# Make sure the contents of our repo are in ${HOME}
COPY . ${HOME}
RUN chown -R ${NB_UID} ${HOME}
USER ${NB_USER}

# Add ~/.local/bin to PATH
ENV PATH="${HOME}/.local/bin:${PATH}"


# Update nbconvert
RUN pip install --no-cache-dir nbconvert==6.4.3

# Install requirements
RUN pip install --no-cache-dir -r requirements.txt

# Install multiprocess
RUN pip install multiprocess

# Install simlammps ontology
RUN wget https://raw.githubusercontent.com/simphony/simlammps/main/simphony_osp_simlammps/simlammps.ttl
RUN wget https://raw.githubusercontent.com/simphony/simlammps/main/simphony_osp_simlammps/simlammps.yml
RUN pico install simlammps.yml

# Install city and emmo ontologies
RUN pico install city emmo

# Fix problem with lammps not priting output to Python variables
ENV PYTHONUNBUFFERED=1
20 changes: 14 additions & 6 deletions docs/introduction/quickstart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,14 @@
"metadata": {},
"outputs": [],
"source": [
"#!pico install /path/to/simlammps"
"# if you are running the tutorial online using Binder, then the simlammps\n",
"# ontology is already pre-installed\n",
"\n",
"# otherwise, download `simlammps.ttl` and `simlammps.yml` from \n",
"# https://github.com/simphony/simlammps/tree/v4.0.0/simphony_osp_simlammps\n",
"# and run\n",
"\n",
"#!pico install simlammps.yml"
]
},
{
Expand Down Expand Up @@ -425,15 +432,16 @@
}
],
"source": [
"from simphony_osp.wrappers import SimLammps\n",
"from simphony_osp.wrappers import SimLAMMPS\n",
"\n",
"# open the SQLite database and create a new SimLAMMPS session\n",
"sqlite_session = SQLite('atoms.db', create=False)\n",
"simlammps_session = SimLammps()\n",
"simlammps_session = SimLAMMPS()\n",
"\n",
"# prevent closing the sessions when leaving the contexts after \n",
"# using the `with` statement\n",
"sqlite_session.locked = True, simlammps_session.locked = True\n",
"sqlite_session.locked = True\n",
"simlammps_session.locked = True\n",
"\n",
"# copy the individuals from the SQLite session to the SimLAMMPS session\n",
"ontology_individuals_from_database = list(sqlite_session)\n",
Expand Down Expand Up @@ -582,7 +590,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -596,7 +604,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.10.7"
}
},
"nbformat": 4,
Expand Down
8 changes: 5 additions & 3 deletions docs/usage/sessions/introduction.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@
"source": [
"session_B = Session()\n",
"\n",
"session_A.locked = True, session_B.locked = True # this will be explained later\n",
"# this will be explained later\n",
"session_A.locked = True\n",
"session_B.locked = True\n",
"\n",
"with session_B:\n",
" london = city.City(name=\"London\", coordinates=[51.50737, -0.12767])\n",
Expand Down Expand Up @@ -190,7 +192,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -204,7 +206,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.10.7"
},
"toc-showcode": false,
"toc-showtags": true
Expand Down
11 changes: 2 additions & 9 deletions docs/usage/sessions/sparql.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,11 @@
" \n",
"</div>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -274,7 +267,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.12"
"version": "3.10.7"
},
"toc-showcode": false,
"toc-showtags": true
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
simphony-osp == 4.0.0rc3
simphony-osp-simlammps >= 4.0.0, < 5.0.0rc0
jinja2 >= 3.0.3, < 4
jupyter >= 1.0.0, < 2
markupsafe >= 2.1.1, < 3
Expand Down

0 comments on commit 31afc05

Please sign in to comment.