forked from EBI-Metagenomics/notebooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Static (preview) rendering (EBI-Metagenomics#19)
* adds Quarto static-rendering of notebooks (e.g. for github pages) * revert some temporary content changes * run GHA Preview action on feature branch * adds test retries for more resilience to random failures * fix docker run command on GHA Preview job
- Loading branch information
1 parent
9c9c1b6
commit 4ddef76
Showing
25 changed files
with
443 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Preview | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
push: | ||
branches: | ||
- main | ||
- 'feature/static-preview' | ||
|
||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Pages | ||
uses: actions/configure-pages@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Build Dockerfile | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: ./docker/docs.Dockerfile | ||
load: true | ||
tags: notebooks-static | ||
|
||
- name: Quarto render | ||
run: | | ||
docker run -v $PWD:/opt/repo -w /opt/repo notebooks-static render --execute | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v1 | ||
with: | ||
path: '_site' | ||
|
||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,8 @@ shinyproxy.log* | |
.DS_Store | ||
node_modules | ||
tests/*.png | ||
.idea | ||
.idea | ||
_site | ||
_freeze | ||
/.quarto/ | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
version: '3' | ||
|
||
tasks: | ||
add-py-notebook: | ||
summary: | | ||
Creates a new Python-language notebook stub from a template. | ||
Set the TITLE and AUTHOR variables, which are used to name | ||
the notebook file and set them in the notebook front matter. | ||
Usage: TITLE='Notebook Name' AUTHOR='Your Name' task add-py-notebook | ||
cmds: | ||
- cp src/templates/python.ipynb "src/notebooks/Python Examples/{{.TITLE}}.ipynb" | ||
- sed -i '' 's/::NBTITLE::/{{.TITLE}}/g' "src/notebooks/Python Examples/{{.TITLE}}.ipynb" | ||
- sed -i '' 's/::NBAUTHOR::/{{.AUTHOR}}/g' "src/notebooks/Python Examples/{{.TITLE}}.ipynb" | ||
preconditions: | ||
- sh: test -n "{{.TITLE}}" | ||
msg: "TITLE parameter missing. Set: TITLE='Notebook Name' AUTHOR='Your Name' task add-py-notebook" | ||
- sh: test -n "{{.AUTHOR}}" | ||
msg: "AUTHOR parameter missing. Set: TITLE='Notebook Name' AUTHOR='Your Name' task add-py-notebook" | ||
|
||
edit-notebooks: | ||
summary: | | ||
Opens Jupyter Lab (via Docker) in edit mode – with the notebooks source bound to this repository | ||
The files in src/notebooks are mounted as editable, and served on port 8888. | ||
cmds: | ||
- docker run -it -v $PWD/src/notebooks:/home/jovyan/mgnify-examples -p 8888:8888 quay.io/microbiome-informatics/emg-notebooks.dev:latest | ||
|
||
build-static-docker: | ||
summary: | | ||
Builds a docker image with Quarto included, for statically rendering the notebook outputs. | ||
The built image is tagged as `notebooks-static`. | ||
cmds: | ||
- docker build -f docker/docs.Dockerfile -t notebooks-static . | ||
status: | ||
- docker image inspect notebooks-static | ||
|
||
render-static: | ||
summary: | | ||
Runs and renders the notebooks as a static website | ||
The site is built to ./_site | ||
cmds: | ||
- docker run -it -v $PWD:/opt/repo -w /opt/repo notebooks-static render --execute | ||
deps: [build-static-docker] | ||
|
||
preview-static: | ||
summary: | | ||
Runs, renders, and serveces the notebooks as a static website, watching for changes | ||
cmds: | ||
- echo 'When the rendering is finished, the static preview of notebooks will be at http://127.0.0.1:4444 ...' | ||
- docker run -it -v $PWD:/opt/repo -w /opt/repo -p 4444:4444 notebooks-static preview --no-browser --port 4444 --host 0.0.0.0 | ||
deps: [build-static-docker] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
API_ENDPOINT="super-studies" | ||
MGYS="MGYS00005292" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
project: | ||
type: website | ||
render: | ||
- src/notebooks_list.qmd | ||
- src/notebooks/Python Examples/*.ipynb | ||
# - src/notebooks/R Examples/*.ipynb | ||
|
||
execute: | ||
freeze: auto | ||
|
||
website: | ||
title: MGnify Notebooks | ||
favicon: src/static-resources/mgnify_logo.png | ||
page-navigation: true | ||
|
||
body-header: | | ||
:::{.callout-note} | ||
## This is a static preview | ||
You can run and edit these examples interactively on [Galaxy](https://usegalaxy.eu/root?tool_id=interactive_tool_mgnify_notebook) | ||
::: | ||
repo-url: https://github.com/ebi-metagenomics/notebooks | ||
repo-subdir: src | ||
repo-actions: [edit, issue] | ||
|
||
navbar: | ||
right: | ||
- href: https://usegalaxy.eu/root?tool_id=interactive_tool_mgnify_notebook | ||
text: Run on Galaxy | ||
|
||
sidebar: | ||
style: docked | ||
search: true | ||
|
||
contents: | ||
- href: src/notebooks_list.qmd | ||
|
||
tools: | ||
- icon: github | ||
menu: | ||
- text: Notebooks source | ||
url: https://github.com/ebi-metagenomics/notebooks | ||
- text: MGnify repositories | ||
url: https://github.com/ebi-metagenomics | ||
- icon: question-circle-fill | ||
text: Help | ||
href: mailto:[email protected] | ||
format: | ||
html: | ||
theme: | ||
- cosmo | ||
- src/static-resources/styles.scss | ||
toc: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM quay.io/microbiome-informatics/emg-notebooks.dev | ||
|
||
ARG QUARTO_VERSION="1.2.269" | ||
WORKDIR /tmp | ||
RUN wget https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb | ||
RUN dpkg -i quarto-${QUARTO_VERSION}-linux-amd64.deb | ||
ENTRYPOINT ["quarto"] |
Binary file removed
BIN
-918 Bytes
notebooks-src/notebooks/Python Examples/lib/__pycache__/variable_utils.cpython-39.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.