Skip to content

Commit f96a800

Browse files
authored
Merge pull request #11 from uwescience/lesson_content
Lesson content in Jupyter Book format
2 parents 6759df0 + 225dcd7 commit f96a800

File tree

8 files changed

+212
-2
lines changed

8 files changed

+212
-2
lines changed

.github/workflows/deploy-book.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: deploy-book
2+
3+
# Run this when the master or main branch changes
4+
on:
5+
push:
6+
branches:
7+
- main
8+
- lesson_content
9+
# If your git repository has the Jupyter Book within some-subfolder next to
10+
# unrelated files, you can make this run only if a file within that specific
11+
# folder has been modified.
12+
#
13+
# paths:
14+
# - some-subfolder/**
15+
16+
# This job installs dependencies, builds the book, and pushes it to `gh-pages`
17+
jobs:
18+
deploy-book:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
pages: write
22+
id-token: write
23+
steps:
24+
- uses: actions/checkout@v3
25+
26+
# Install dependencies
27+
- name: Set up Python 3.11
28+
uses: actions/setup-python@v4
29+
with:
30+
python-version: 3.11
31+
32+
- name: Install dependencies
33+
run: |
34+
pip install jupyter-book
35+
36+
# (optional) Cache your executed notebooks between runs
37+
# if you have config:
38+
# execute:
39+
# execute_notebooks: cache
40+
# - name: cache executed notebooks
41+
# uses: actions/cache@v3
42+
# with:
43+
# path: _build/.jupyter_cache
44+
# key: jupyter-book-cache-${{ hashFiles('requirements.txt') }}
45+
46+
# Build the book
47+
- name: Build the book
48+
run: |
49+
jupyter-book build docs/.
50+
51+
# Upload the book's HTML as an artifact
52+
- name: Upload artifact
53+
uses: actions/upload-pages-artifact@v2
54+
with:
55+
path: "docs/_build/html"
56+
57+
# Deploy the book's HTML to GitHub Pages
58+
- name: Deploy to GitHub Pages
59+
id: deployment
60+
uses: actions/deploy-pages@v2

docs/_config.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Book settings
2+
# Learn more at https://jupyterbook.org/customize/config.html
3+
4+
title: My sample book
5+
author: The Jupyter Book Community
6+
logo: logo.png
7+
8+
# Force re-execution of notebooks on each build.
9+
# See https://jupyterbook.org/content/execute.html
10+
execute:
11+
execute_notebooks: force
12+
13+
# Information about where the book exists on the web
14+
repository:
15+
url: https://github.com/executablebooks/jupyter-book # Online location of your book
16+
path_to_book: docs # Optional path to your book, relative to the repository root
17+
branch: lesson_content # Which branch of the repository should be used when creating links (optional)
18+
19+
# Add GitHub buttons to your book
20+
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository
21+
html:
22+
use_issues_button: true
23+
use_repository_button: true

docs/_toc.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Table of contents
2+
# Learn more at https://jupyterbook.org/customize/toc.html
3+
4+
format: jb-book
5+
root: intro
6+
chapters:
7+
- file: lesson

docs/intro.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Welcome to SciPy 2024 GitHub Actions for Scientific Workflows Tutorial
2+
3+
```{tableofcontents}
4+
```

lesson.md renamed to docs/lesson.md

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@
44
2. [GitHub Actions Python Environment](#github-actions-python-environment-workflow)
55
3. [Orcasound Spectrogram Visualization Workflow](#orcasound-spectrogram-visualization-workflow)
66
4. [Exporting Results](#exporting-results)
7-
5. [Scaling Workflows](#scaling-workflows)
7+
5. [Visualizing Results on a Webpage](#visualizing-results-on-a-webpage)
8+
6. [Scaling Workflows](#scaling-workflows)
9+
10+
All workflow configurations are stored in the [`.github/workflows`](https://github.com/uwescience/SciPy2024-GitHubActionsTutorial/tree/main/.github/workflows) and will go through them in the following order:
11+
12+
1. [`python_env.yml`](https://github.com/uwescience/SciPy2024-GitHubActionsTutorial/blob/main/.github/workflows/python_env.yml)
13+
2. [`conda_env.yml`](https://github.com/uwescience/SciPy2024-GitHubActionsTutorial/blob/main/.github/workflows/conda_env.yml)
14+
3. [`noise_processing.yml`](https://github.com/uwescience/SciPy2024-GitHubActionsTutorial/blob/main/.github/workflows/noise_processing.yml)
15+
4. [`create_website_spectrogram.yml`](https://github.com/uwescience/SciPy2024-GitHubActionsTutorial/blob/main/.github/workflows/create_website_spectrogram.yml)
16+
5. [`create_website.yml`](https://github.com/uwescience/SciPy2024-GitHubActionsTutorial/blob/main/.github/workflows/create_website.yml)
17+
6. ...
18+
19+
20+
821

922
# Setup
1023
* Fork this repo
@@ -58,6 +71,51 @@ After the workflow is executed `psd.png` and `broadband.png`files are updated in
5871

5972
![alt text](https://raw.githubusercontent.com/uwescience/SciPy2024-GitHubActionsTutorial/main/ambient_sound_analysis/img/broadband.png)
6073

74+
# Caching
75+
76+
Dependency reinstalls between consecutive workflow runs are time consuming, and usually unnecessary. The process can be sped up by caching the builds of the packages. Caches are removed automatically if not accessed for 7 days, and their size can be up to 10GB. One can also manually remove a cache, if they want to reset the installation.
77+
78+
## Caching `pip` installs
79+
80+
`pip` packages can be cached by adding the `cache: 'pip'` setting to the Python setup action. If one is not using the default `requirements.txt` file for installation, they should also provide a `dependency-path`.
81+
82+
![alt text](https://raw.githubusercontent.com/uwescience/SciPy2024-GitHubActionsTutorial/main/img/pip-caching.png)
83+
84+
## Caching `conda` installs
85+
86+
Conda packages can be similarly cached withing the conda setup action.
87+
88+
![alt text](https://raw.githubusercontent.com/uwescience/SciPy2024-GitHubActionsTutorial/main/img/conda-caching.png)
89+
90+
## Caching `apt-get` installs
91+
92+
Packages such as `ffmpeg` can take long time to install. There is no official action to cache apt-get packages but they can be cached with the [walsh128/cache-apt-pkgs-action](https://github.com/marketplace/actions/cache-apt-packages).
93+
94+
```yaml
95+
- uses: walsh128/cache-apt-pkgs-action@latest
96+
with:
97+
packages: ffmpeg
98+
```
99+
100+
## Caching any data
101+
102+
The general [`cache`](https://github.com/marketplace/actions/cache) action allows to cache data at any path. Apart from builds of packages, one can use this option to not regenerate results while testing.
103+
104+
```yaml
105+
- uses: actions/cache@v4
106+
id: cache
107+
with:
108+
path: img/
109+
key: img
110+
111+
- name: Get all files
112+
if: steps.cache.outputs.cache-hit != 'true'
113+
run: …
114+
```
115+
116+
[Caching Documentation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows)
117+
118+
61119

62120
# Exporting Results
63121

@@ -67,7 +125,7 @@ We will discuss several different ways to export results.
67125

68126
One of the easiest ways to display results is to store them in the GitHub repository. This can be a quick solution, for example, to display a small plot or a table within the `Readme.md` of the repository and update it as the workflow is rerun. This is not a practical solution for big outputs as the GitHub repositories are recommended to not exceed more than 1GB, and all versions of the files will be preserved in the repository's history (thus slowing down cloning).
69127

70-
It is possible to execute all steps to add, commit, and push a file to GitHub, but there is already an [GitHub Auto Commit Action]https://github.com/marketplace/actions/git-auto-commit) to achieve that.
128+
It is possible to execute all steps to add, commit, and push a file to GitHub, but there is already an [GitHub Auto Commit Action](https://github.com/marketplace/actions/git-auto-commit) to achieve that.
71129

72130
![alt text](https://raw.githubusercontent.com/uwescience/SciPy2024-GitHubActionsTutorial/main/img/auto-commit-action.png)
73131

docs/logo.png

9.62 KB
Loading

docs/markdown.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Markdown Files
2+
3+
Whether you write your book's content in Jupyter Notebooks (`.ipynb`) or
4+
in regular markdown files (`.md`), you'll write in the same flavor of markdown
5+
called **MyST Markdown**.
6+
This is a simple file to help you get started and show off some syntax.
7+
8+
## What is MyST?
9+
10+
MyST stands for "Markedly Structured Text". It
11+
is a slight variation on a flavor of markdown called "CommonMark" markdown,
12+
with small syntax extensions to allow you to write **roles** and **directives**
13+
in the Sphinx ecosystem.
14+
15+
For more about MyST, see [the MyST Markdown Overview](https://jupyterbook.org/content/myst.html).
16+
17+
## Sample Roles and Directives
18+
19+
Roles and directives are two of the most powerful tools in Jupyter Book. They
20+
are like functions, but written in a markup language. They both
21+
serve a similar purpose, but **roles are written in one line**, whereas
22+
**directives span many lines**. They both accept different kinds of inputs,
23+
and what they do with those inputs depends on the specific role or directive
24+
that is being called.
25+
26+
Here is a "note" directive:
27+
28+
```{note}
29+
Here is a note
30+
```
31+
32+
It will be rendered in a special box when you build your book.
33+
34+
Here is an inline directive to refer to a document: {doc}`markdown-notebooks`.
35+
36+
37+
## Citations
38+
39+
You can also cite references that are stored in a `bibtex` file. For example,
40+
the following syntax: `` {cite}`holdgraf_evidence_2014` `` will render like
41+
this: {cite}`holdgraf_evidence_2014`.
42+
43+
Moreover, you can insert a bibliography into your page with this syntax:
44+
The `{bibliography}` directive must be used for all the `{cite}` roles to
45+
render properly.
46+
For example, if the references for your book are stored in `references.bib`,
47+
then the bibliography is inserted with:
48+
49+
```{bibliography}
50+
```
51+
52+
## Learn more
53+
54+
This is just a simple starter to get you started.
55+
You can learn a lot more at [jupyterbook.org](https://jupyterbook.org).

docs/requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
jupyter-book
2+
matplotlib
3+
numpy

0 commit comments

Comments
 (0)