Skip to content

Commit

Permalink
fix materialize bug; fix docker; improve readme; cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eimrek committed May 17, 2024
1 parent 46eb367 commit c5b1831
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 326 deletions.
37 changes: 0 additions & 37 deletions Makefile

This file was deleted.

63 changes: 47 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,70 @@
# 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

```bash
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.
7 changes: 6 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 0 additions & 9 deletions example-notebooks/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"<img src=\"https://www.osscar.org/_images/logos.png\" style=\"height:80px\"/>"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
7 changes: 0 additions & 7 deletions jupyter_config.json

This file was deleted.

3 changes: 0 additions & 3 deletions pyproject.toml

This file was deleted.

7 changes: 2 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions requirements_base.txt

This file was deleted.

3 changes: 2 additions & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
invoke~=2.2
ipywidgets~=8.1
pylint~=2.17
widget-periodictable~=3.1
jupyterlab~=4.0
widget-periodictable~=4.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
102 changes: 0 additions & 102 deletions share/jupyter/voila/templates/materialscloud-discover/base.html

This file was deleted.

19 changes: 0 additions & 19 deletions share/jupyter/voila/templates/materialscloud-discover/tree.html

This file was deleted.

Loading

0 comments on commit c5b1831

Please sign in to comment.