diff --git a/Makefile b/Makefile deleted file mode 100644 index 6fb7b8b..0000000 --- a/Makefile +++ /dev/null @@ -1,37 +0,0 @@ -.PHONY: serve serve_iframe build build_nocache - -VOILA=./example-notebooks/voila.json - -serve: voila - sed -i "s|TEMPLATE_NAME|materialscloud|g" ${VOILA} - docker-compose -f docker/docker-compose.yml up voila - -serve_iframe: voila - sed -i "s|TEMPLATE_NAME|materialscloud-iframe|g" ${VOILA} - docker-compose -f docker/docker-compose.yml up voila - -build: - docker-compose -f docker/docker-compose.yml build voila - -build_nocache: - docker-compose -f docker/docker-compose.yml build --no-cache voila - -voila: - @echo "{" > ${VOILA} - @echo " \"VoilaConfiguration\": {" >> ${VOILA} - @echo " \"enable_nbextensions\": true," >> ${VOILA} - @echo " \"theme\": \"light\"," >> ${VOILA} - @echo " \"template\": \"TEMPLATE_NAME\"" >> ${VOILA} - @echo " }," >> ${VOILA} - @echo " \"MappingKernelManager\": {" >> ${VOILA} - @echo " \"cull_idle_timeout\": 120," >> ${VOILA} - @echo " \"cull_interval\": 60" >> ${VOILA} - @echo " }," >> ${VOILA} - @echo " \"Voila\": {" >> ${VOILA} - @echo " \"tornado_settings\": {" >> ${VOILA} - @echo " \"headers\": {" >> ${VOILA} - @echo " \"Content-Security-Policy\": \"frame-ancestors *; report-uri /api/security/csp-report\"" >> ${VOILA} - @echo " }" >> ${VOILA} - @echo " }" >> ${VOILA} - @echo " }" >> ${VOILA} - @echo "}" >> ${VOILA} diff --git a/README.md b/README.md index cacf313..c872dda 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,12 @@ -# Voilà template for Materials Cloud - -This is the Voilà template for the Materials Cloud project. - -It implements the standard Materials Cloud header and CSS. - -The template is called `materialscloud` and can be invoked either by using the `--template=materialscloud` `voila` CLI option, setting it explicitly in a Notebook's metadata or in a Jupyter config file. -See [the Voilà documentation](https://voila.readthedocs.io/en/stable/customize.html#controlling-the-nbconvert-template) on how to invoke templates for more information. +# Voilà template for Materials Cloud +[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/materialscloud-org/voila-materialscloud-template/develop?urlpath=%2Fvoila%2Frender%2Fexample-notebooks%2Fexample.ipynb) -## Try it with Binder! +This is the Voilà template for Materials Cloud, implements the standard header and CSS. -[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/materialscloud-org/voila-materialscloud-template/develop?urlpath=%2Fvoila%2Frender%2Fexample-notebooks%2Fexample.ipynb) +Three templates are provided: +* `materialscloud-tool` - highlights the [WORK](https://www.materialscloud.org/work)/Tools section in the header/breadcrumbs. +* `materialscloud-discover` - highlights the [DISCOVER](https://www.materialscloud.org/discover) section in the header/breadcrumbs. +* `materialscloud-iframe` - just adds a simple "Hosted on Materials Cloud" note at the bottom. ## Installation @@ -17,23 +14,57 @@ See [the Voilà documentation](https://voila.readthedocs.io/en/stable/customize. pip install voila-materialscloud-template ``` -## Usage +This installs the templates in the correct Jupyter path (using `copy_voila_template.py`). -There are two different templates for deploying Voilà at Materials Cloud website, which are "materialscloud-tool" and "materialscloud-discover". +## Usage -At [Materials Cloud](https://materialscloud.org), the [WORK](https://www.materialscloud.org/work) section have a collection of simulation tools and services. To deploy such applications, one need use the "materialscloud-tool" template as: +The main way is to use the `voila --template` option, e.g.: ```bash voila --template=materialscloud-tool example.ipynb ``` +Alternatively, you can write a `voila.json` file containing + +```json +{ + "VoilaConfiguration": { + "template": "materialscloud-tool" + }, + ... +} +``` -In the [DISCOVER](https://www.materialscloud.org/discover) section, it shows curated research data with tailored visualizations. One need to use the "materialscloud-discover" template -to deploy the apps. +and passing its path with ```bash -voila --template=materialscloud-discover example.ipynb +voila --Voila.config_file_paths=<...> example.ipynb ``` +There are also other options, see [the Voilà documentation](https://voila.readthedocs.io/en/stable/customize.html#controlling-the-nbconvert-template) for more information. + +## Development + +Option 1: + +```bash +pip install -e .[dev] +``` + +Note: this will copy the templates to the jupyter folder, and they need to be modified directly there or re-copied if new tests are required. + +Option 2: + +It's more convenient to use a docker container and rebuild after modification: + +```bash +cd docker +docker compose up --build +``` + +and access via `http://localhost:8866/`. The template and other voila configuration is specified in `voila.json`. + +Note: maybe there is an easier setup, e.g. with live-reload or similar. + ## License This repository and all files in it are licensed under the [BSD license](LICENSE), copyright (c) by Voilà contributors. diff --git a/docker/Dockerfile b/docker/Dockerfile index 941405a..1d639dc 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,11 @@ -FROM python:3.8 +FROM python:3.9 WORKDIR /home/voila COPY requirements.txt . RUN pip install -r requirements.txt + +COPY requirements_dev.txt . +RUN pip install -r requirements_dev.txt + +EXPOSE 8866 \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 1c39168..bff0255 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -13,5 +13,5 @@ services: - ../share/jupyter/nbconvert/templates:/root/.local/share/jupyter/nbconvert/templates - ../example-notebooks:/home/voila/example-notebooks ports: - - 8866:8866 - command: "voila --Voila.config_file_paths=/home/voila/example-notebooks/ --debug example-notebooks" + - "8866:8866" + command: "voila --Voila.ip='0.0.0.0' --Voila.config_file_paths=/home/voila/example-notebooks/ --debug example-notebooks" diff --git a/example-notebooks/example.ipynb b/example-notebooks/example.ipynb index 022a8bb..18cc04c 100644 --- a/example-notebooks/example.ipynb +++ b/example-notebooks/example.ipynb @@ -189,15 +189,6 @@ "button_noble" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "This work has been done with the support of the EPFL Open Science Fund [OSSCAR](http://www.osscar.org).\n", - "\n", - "" - ] - }, { "cell_type": "code", "execution_count": null, diff --git a/jupyter_config.json b/jupyter_config.json deleted file mode 100644 index 1d048a5..0000000 --- a/jupyter_config.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "VoilaConfiguration": { - "enable_nbextensions": true, - "theme": "light", - "template": "materialscloud" - } -} diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 26c82e8..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,3 +0,0 @@ -[build-system] -requires = ["setuptools>=42.0.0", "jupyter_core>=5.3.1,<6"] -build-backend = "setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt index 09cf51f..64a0e1b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,2 @@ -invoke==2.2.0 -ipywidgets==8.1.0 -voila==0.5.2 -jupyter-core==5.3.1 -widget-periodictable==3.1.1 +voila~=0.4.4 +jupyter-core~=5.3.1 \ No newline at end of file diff --git a/requirements_base.txt b/requirements_base.txt deleted file mode 100644 index eef2f3a..0000000 --- a/requirements_base.txt +++ /dev/null @@ -1,2 +0,0 @@ -voila~=0.5.2 -jupyter-core~=5.3.1 \ No newline at end of file diff --git a/requirements_dev.txt b/requirements_dev.txt index fc530c6..a6d1714 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,4 +1,5 @@ invoke~=2.2 ipywidgets~=8.1 pylint~=2.17 -widget-periodictable~=3.1 +jupyterlab~=4.0 +widget-periodictable~=4.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 9c8820a..f2c988b 100644 --- a/setup.py +++ b/setup.py @@ -33,7 +33,7 @@ def run(self): with open(TOP_DIR.joinpath("README.md")) as handle: README = handle.read() -with open(TOP_DIR.joinpath("requirements_base.txt")) as handle: +with open(TOP_DIR.joinpath("requirements.txt")) as handle: REQUIREMENTS_BASE = [f"{_.strip()}" for _ in handle.readlines() if " " not in _] with open(TOP_DIR.joinpath("requirements_dev.txt")) as handle: diff --git a/share/jupyter/voila/templates/materialscloud-discover/base.html b/share/jupyter/voila/templates/materialscloud-discover/base.html deleted file mode 100644 index 7982787..0000000 --- a/share/jupyter/voila/templates/materialscloud-discover/base.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - {% block head %} - {% endblock %} - - - - - - {% block body %} - {% endblock %} - - - - diff --git a/share/jupyter/voila/templates/materialscloud-discover/tree.html b/share/jupyter/voila/templates/materialscloud-discover/tree.html deleted file mode 100644 index 19531a4..0000000 --- a/share/jupyter/voila/templates/materialscloud-discover/tree.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "base.html" %} - -{% block head %} - -{% endblock %} - -{% block body %} -{% for content in contents.content %} -{% if content.name == 'index.ipynb' %} - -{% endif %} -{% endfor %} -{% endblock %} \ No newline at end of file diff --git a/share/jupyter/voila/templates/materialscloud-tool/base.html b/share/jupyter/voila/templates/materialscloud-tool/base.html deleted file mode 100644 index 7982787..0000000 --- a/share/jupyter/voila/templates/materialscloud-tool/base.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - {% block head %} - {% endblock %} - - - - - - {% block body %} - {% endblock %} - - - - diff --git a/share/jupyter/voila/templates/materialscloud-tool/tree.html b/share/jupyter/voila/templates/materialscloud-tool/tree.html deleted file mode 100644 index 19531a4..0000000 --- a/share/jupyter/voila/templates/materialscloud-tool/tree.html +++ /dev/null @@ -1,19 +0,0 @@ -{% extends "base.html" %} - -{% block head %} - -{% endblock %} - -{% block body %} -{% for content in contents.content %} -{% if content.name == 'index.ipynb' %} - -{% endif %} -{% endfor %} -{% endblock %} \ No newline at end of file