Skip to content

[Experimental] Use jupyter-book 2.0 for building the lectures #363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 36 additions & 56 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,69 +5,49 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Anaconda
uses: conda-incubator/setup-miniconda@v3

- name: Setup GitHub Pages
uses: actions/configure-pages@v3

- name: Cache Notebook Execution
uses: actions/cache@v3
id: cache-execution
with:
auto-update-conda: true
auto-activate-base: true
miniconda-version: 'latest'
python-version: "3.12"
environment-file: environment.yml
activate-environment: quantecon
- name: Install latex dependencies
run: |
sudo apt-get -qq update
sudo apt-get install -y \
texlive-latex-recommended \
texlive-latex-extra \
texlive-fonts-recommended \
texlive-fonts-extra \
texlive-xetex \
latexmk \
xindy \
dvipng \
cm-super
- name: Display Conda Environment Versions
shell: bash -l {0}
run: conda list
- name: Display Pip Versions
shell: bash -l {0}
run: pip list
- name: Download "build" folder (cache)
uses: dawidd6/action-download-artifact@v11
path: ./lectures/_build/execute
key: ${{ runner.os }}-execute-cache-${{ hashFiles('lectures/**/*.md') }}

- uses: actions/setup-node@v4
with:
workflow: cache.yml
branch: main
name: build-cache
path: _build
# Build Assets (Download Notebooks and PDF via LaTeX)
- name: Build Download Notebooks (sphinx-tojupyter)
shell: bash -l {0}
run: |
jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going
mkdir -p _build/html/_notebooks
cp -u _build/jupyter/*.ipynb _build/html/_notebooks
- name: Build PDF from LaTeX
shell: bash -l {0}
run: |
jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going
mkdir _build/html/_pdf
cp -u _build/latex/*.pdf _build/html/_pdf
# Final Build of HTML
node-version: 18.x

- name: Install Python
if: steps.cache-execution.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
cache-dependency-path: 'myst_requirements.txt'

- name: Install execution requirements
if: steps.cache-execution.outputs.cache-hit != 'true'
run: python -m pip install -r myst_requirements.txt

- name: Install jupyter book 2.0
run: pip install "jupyter-book>=2.0.0a0"

- name: Build HTML
shell: bash -l {0}
run: |
jb build lectures --path-output ./ -n -W --keep-going
- name: Upload Execution Reports
uses: actions/upload-artifact@v4
if: failure()
working-directory: ./lectures
run: jupyter book build --html --execute

- name: Upload build output
uses: actions/upload-pages-artifact@v3
with:
name: execution-reports
path: _build/html/reports
path: './lectures/_build/html'

- name: Preview Deploy to Netlify
uses: nwtgck/actions-netlify@v3
with:
publish-dir: '_build/html/'
publish-dir: './lectures/_build/html'
production-branch: main
github-token: ${{ secrets.GITHUB_TOKEN }}
deploy-message: "Preview Deploy from GitHub Actions"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ dask-worker-space

lectures/mathfoo.py
lectures/mod.py
lectures/test.py
lectures/test.py
lectures/exports/
Binary file added lectures/_static/ccbysa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 11 additions & 25 deletions lectures/about_py.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@ kernelspec:
display_name: Python 3
language: python
name: python3
exports:
- format: ipynb
output: exports/about_py.ipynb
downloads:
- file: ./about_py.md
title: Markdown (md)
- file: exports/about_py.ipynb
title: IPython (.ipynb)
---

(about_py)=
```{raw} jupyter
<div id="qe-notebook-header" align="right" style="text-align:right;">
<a href="https://quantecon.org/" title="quantecon.org">
<img style="width:250px;display:inline;" width="250px" src="https://assets.quantecon.org/img/qe-menubar-logo.svg" alt="QuantEcon">
</a>
</div>
```

```{index} single: python
```

# About These Lectures

Expand Down Expand Up @@ -95,7 +92,7 @@ This is important because it

### Common Uses

{index}`Python <single: Python; common uses>` is a general-purpose language used in almost all application domains, including
Python is a general-purpose language used in almost all application domains, including

* AI
* scientific computing
Expand Down Expand Up @@ -164,8 +161,6 @@ Other features of Python:

### Syntax and Design

```{index} single: Python; syntax and design
```

One reason for Python's popularity is its simple and elegant design --- we'll see many examples later on.

Expand Down Expand Up @@ -283,8 +278,6 @@ These lectures will explain how.

## Scientific Programming with Python

```{index} single: scientific programming
```

We have already discussed the importance of Python for AI, machine learning and data science

Expand All @@ -308,9 +301,6 @@ This section briefly showcases some examples of Python for general scientific pr

### NumPy

```{index} single: scientific programming; numeric
```

One of the most important parts of scientific computing is working with data.

Data is often stored in matrices, vectors and arrays.
Expand Down Expand Up @@ -411,8 +401,6 @@ Later we'll discuss SciPy in more detail.

### Graphics

```{index} single: Matplotlib
```

A major strength of Python is data visualization.

Expand All @@ -425,13 +413,13 @@ The most popular and comprehensive Python library for creating figures and graph
Example 2D plot with embedded LaTeX annotations

```{figure} /_static/lecture_specific/about_py/qs.png
:scale: 75
:width: 75%
```

Example contour plot

```{figure} /_static/lecture_specific/about_py/bn_density1.png
:scale: 70
:width: 70%
```

Example 3D plot
Expand Down Expand Up @@ -467,8 +455,6 @@ For example, we are interesting in studying

Python has many libraries for studying networks and graphs.

```{index} single: NetworkX
```

One well-known example is [NetworkX](http://networkx.github.io/).

Expand Down
Loading