-
Notifications
You must be signed in to change notification settings - Fork 10
/
Taskfile.yml
111 lines (88 loc) · 4.54 KB
/
Taskfile.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
version: '3'
env:
NB_DOCKER_EXE: "docker"
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"
add-r-notebook:
summary: |
Creates a new R-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-r-notebook
cmds:
- cp src/templates/r.ipynb "src/notebooks/R Examples/{{.TITLE}}.ipynb"
- sed -i '' 's/::NBTITLE::/{{.TITLE}}/g' "src/notebooks/R Examples/{{.TITLE}}.ipynb"
- sed -i '' 's/::NBAUTHOR::/{{.AUTHOR}}/g' "src/notebooks/R Examples/{{.TITLE}}.ipynb"
preconditions:
- sh: test -n "{{.TITLE}}"
msg: "TITLE parameter missing. Set: TITLE='Notebook Name' AUTHOR='Your Name' task add-r-notebook"
- sh: test -n "{{.AUTHOR}}"
msg: "AUTHOR parameter missing. Set: TITLE='Notebook Name' AUTHOR='Your Name' task add-r-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:
- $NB_DOCKER_EXE run -it -v $PWD/src/notebooks:/home/jovyan/mgnify-examples -p 8888:8888 quay.io/microbiome-informatics/emg-notebooks.dev:latest
build-notebook-docker:
summary: |
Builds a docker image with the Notebooks Server, locally.
Useful if you're developing the Jupyter extensions, installing new R/Python packages to the conda envs etc.
NOT needed if you're just editing/adding notebooks with no additional dependencies.
cmds:
- $NB_DOCKER_EXE build --load -f docker/Dockerfile -t 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:
- $NB_DOCKER_EXE build --load -f docker/docs.Dockerfile -t notebooks-static .
sources:
- docker/docs.Dockerfile
- docker/Dockerfile
render-static:
summary: |
Runs and renders the notebooks as a static website
The site is built to ./_site
cmds:
- $NB_DOCKER_EXE run -it -v $PWD:/opt/repo -w /opt/repo notebooks-static render --execute
deps: [build-static-docker]
sources:
- src/**/*
serve-static:
summary: |
Serves the rendered notebooks and documentation as a static website
This serves the contents of ./_site
cmds:
- echo "Browse to http://127.0.0.1:4444"
- $NB_DOCKER_EXE run -it -v $PWD:/opt/repo -w /opt/repo/_site -p 4444:4444 --entrypoint python notebooks-static -m http.server 4444
deps: [render-static]
preview-static:
summary: |
Runs, renders, and serves 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 ...'
- $NB_DOCKER_EXE 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]
update-mgnifyr-cache:
summary: |
Copies the MgnifyR Cache directory from the docker image into the host repository.
Run this if you change the populate-mgnifyr-cache.R file.
This cache zip is just used to speed up subsequent docker builds by not calling the MGnify API so much.
It writes a zip of the cache to dependencies/mgnify-cache.tgz
cmds:
- $NB_DOCKER_EXE run -it -v $PWD/dependencies:/opt/dependencies -w /opt/dependencies quay.io/microbiome-informatics/emg-notebooks.dev:latest /bin/bash zip-mgnifyr-cache.sh