Skip to content

Commit 99fb610

Browse files
committed
ENH: enable gh-actions workflows and setup as jupyter-book project
1 parent b6fe701 commit 99fb610

File tree

93 files changed

+30072
-15
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+30072
-15
lines changed

.github/dependabot.yml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: github-actions
9+
directory: /
10+
commit-message:
11+
prefix: ⬆️
12+
schedule:
13+
interval: weekly

.github/workflows/cache.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build Cache [using jupyter-book]
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
cache:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: Setup Anaconda
12+
uses: conda-incubator/setup-miniconda@v3
13+
with:
14+
auto-update-conda: true
15+
auto-activate-base: true
16+
miniconda-version: 'latest'
17+
python-version: "3.12"
18+
environment-file: environment.yml
19+
activate-environment: quantecon
20+
- name: Build HTML
21+
shell: bash -l {0}
22+
run: |
23+
jb build lectures --path-output ./ -W --keep-going
24+
- name: Upload Execution Reports
25+
uses: actions/upload-artifact@v4
26+
if: failure()
27+
with:
28+
name: execution-reports
29+
path: _build/html/reports
30+
- name: Upload "_build" folder (cache)
31+
uses: actions/upload-artifact@v4
32+
with:
33+
name: build-cache
34+
path: _build
35+
include-hidden-files: true

.github/workflows/ci.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build Project [using jupyter-book]
2+
on: [pull_request]
3+
jobs:
4+
preview:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- name: Setup Anaconda
9+
uses: conda-incubator/setup-miniconda@v3
10+
with:
11+
auto-update-conda: true
12+
auto-activate-base: true
13+
miniconda-version: 'latest'
14+
python-version: "3.12"
15+
environment-file: environment.yml
16+
activate-environment: quantecon
17+
- name: Install latex dependencies
18+
run: |
19+
sudo apt-get -qq update
20+
sudo apt-get install -y \
21+
texlive-latex-recommended \
22+
texlive-latex-extra \
23+
texlive-fonts-recommended \
24+
texlive-fonts-extra \
25+
texlive-xetex \
26+
latexmk \
27+
xindy \
28+
dvipng \
29+
cm-super
30+
- name: Display Conda Environment Versions
31+
shell: bash -l {0}
32+
run: conda list
33+
- name: Display Pip Versions
34+
shell: bash -l {0}
35+
run: pip list
36+
- name: Download "build" folder (cache)
37+
uses: dawidd6/action-download-artifact@v9
38+
with:
39+
workflow: cache.yml
40+
branch: main
41+
name: build-cache
42+
path: _build
43+
# TODO: enable pdf and download notebooks
44+
# # Build Assets (Download Notebooks and PDF via LaTeX)
45+
# - name: Build Download Notebooks (sphinx-tojupyter)
46+
# shell: bash -l {0}
47+
# run: |
48+
# jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going
49+
# mkdir -p _build/html/_notebooks
50+
# cp -u _build/jupyter/*.ipynb _build/html/_notebooks
51+
# - name: Build PDF from LaTeX
52+
# shell: bash -l {0}
53+
# run: |
54+
# jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going
55+
# mkdir _build/html/_pdf
56+
# cp -u _build/latex/*.pdf _build/html/_pdf
57+
# Final Build of HTML
58+
- name: Build HTML
59+
shell: bash -l {0}
60+
run: |
61+
jb build lectures --path-output ./ -n -W --keep-going
62+
- name: Upload Execution Reports
63+
uses: actions/upload-artifact@v4
64+
if: failure()
65+
with:
66+
name: execution-reports
67+
path: _build/html/reports
68+
- name: Preview Deploy to Netlify
69+
uses: nwtgck/actions-netlify@v3
70+
with:
71+
publish-dir: '_build/html/'
72+
production-branch: main
73+
github-token: ${{ secrets.GITHUB_TOKEN }}
74+
deploy-message: "Preview Deploy from GitHub Actions"
75+
env:
76+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
77+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

.github/workflows/publish.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Build & Publish to GH Pages
2+
on:
3+
push:
4+
tags:
5+
- 'publish*'
6+
jobs:
7+
publish:
8+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
- name: Setup Anaconda
14+
uses: conda-incubator/setup-miniconda@v3
15+
with:
16+
auto-update-conda: true
17+
auto-activate-base: true
18+
miniconda-version: 'latest'
19+
python-version: "3.12"
20+
environment-file: environment.yml
21+
activate-environment: quantecon
22+
- name: Install latex dependencies
23+
run: |
24+
sudo apt-get -qq update
25+
sudo apt-get install -y \
26+
texlive-latex-recommended \
27+
texlive-latex-extra \
28+
texlive-fonts-recommended \
29+
texlive-fonts-extra \
30+
texlive-xetex \
31+
latexmk \
32+
xindy \
33+
dvipng \
34+
cm-super
35+
- name: Display Conda Environment Versions
36+
shell: bash -l {0}
37+
run: conda list
38+
- name: Display Pip Versions
39+
shell: bash -l {0}
40+
run: pip list
41+
# Download Build Cache from cache.yml
42+
- name: Download "build" folder (cache)
43+
uses: dawidd6/action-download-artifact@v9
44+
with:
45+
workflow: cache.yml
46+
branch: main
47+
name: build-cache
48+
path: _build
49+
# TODO: pdf support
50+
# # Build Assets (Download Notebooks, PDF via LaTeX)
51+
# - name: Build PDF from LaTeX
52+
# shell: bash -l {0}
53+
# run: |
54+
# jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going
55+
# - name: Copy LaTeX PDF for GH-PAGES
56+
# shell: bash -l {0}
57+
# run: |
58+
# mkdir -p _build/html/_pdf
59+
# cp -u _build/latex/*.pdf _build/html/_pdf
60+
# TODO: download notebook support
61+
# - name: Build Download Notebooks (sphinx-tojupyter)
62+
# shell: bash -l {0}
63+
# run: |
64+
# jb build lectures --path-output ./ --builder=custom --custom-builder=jupyter -n -W --keep-going
65+
# zip -r download-notebooks.zip _build/jupyter
66+
# - uses: actions/upload-artifact@v4
67+
# with:
68+
# name: download-notebooks
69+
# path: download-notebooks.zip
70+
# - name: Copy Download Notebooks for GH-PAGES
71+
# shell: bash -l {0}
72+
# run: |
73+
# mkdir -p _build/html/_notebooks
74+
# cp -u _build/jupyter/*.ipynb _build/html/_notebooks
75+
# Final Build of HTML (with assets)
76+
- name: Build HTML
77+
shell: bash -l {0}
78+
run: |
79+
jb build lectures --path-output ./ -n -W --keep-going
80+
- name: Deploy website to gh-pages
81+
uses: peaceiris/actions-gh-pages@v4
82+
with:
83+
github_token: ${{ secrets.GITHUB_TOKEN }}
84+
publish_dir: _build/html/
85+
# cname: python-programming-fa.quantecon.org
86+
# TODO: download notebook support
87+
# - name: Prepare lecture-python-programming.notebooks sync
88+
# shell: bash -l {0}
89+
# run: |
90+
# mkdir -p _build/lecture-python-programming.notebooks
91+
# cp -a _notebook_repo/. _build/lecture-python-programming.notebooks
92+
# cp _build/jupyter/*.ipynb _build/lecture-python-programming.notebooks
93+
# ls -a _build/lecture-python-programming.notebooks
94+
# - name: Commit notebooks to lecture-python-programming.notebooks
95+
# shell: bash -l {0}
96+
# env:
97+
# QE_SERVICES_PAT: ${{ secrets.QUANTECON_SERVICES_PAT }}
98+
# run: |
99+
# git clone https://quantecon-services:[email protected]/quantecon/lecture-python-programming.notebooks
100+
101+
# cp _build/lecture-python-programming.notebooks/*.ipynb lecture-python-programming.notebooks
102+
103+
# cd lecture-python-programming.notebooks
104+
# git config user.name "QuantEcon Services"
105+
# git config user.email "[email protected]"
106+
# git add *.ipynb
107+
# git commit -m "auto publishing updates to notebooks"
108+
# git push origin main

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
_build/
2+
__pycache__/
3+
.DS_Store
4+
dask-worker-space
5+
6+
.vscode/
7+
.ipynb_checkpoints/
8+
.virtual_documents/
9+
10+
lectures/mathfoo.py
11+
lectures/mod.py
12+
lectures/test.py

environment.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: quantecon
2+
channels:
3+
- default
4+
dependencies:
5+
- python=3.12
6+
- anaconda=2024.10
7+
- pip
8+
- pip:
9+
- jupyter-book==1.0.3
10+
- quantecon-book-theme==0.8.2
11+
- sphinx-tojupyter==0.3.0
12+
- sphinxext-rediraffe==0.2.7
13+
- sphinx-reredirects==0.1.4
14+
- sphinx-exercise==1.0.1
15+
- sphinx-proof==0.2.1
16+
- ghp-import==1.1.0
17+
- sphinxcontrib-youtube==1.3.0 #Version 1.3.0 is required as quantecon-book-theme is only compatible with sphinx<=5
18+
- sphinx-togglebutton==0.3.2
19+
# Author Requirements
20+
- jupyterlab-myst
21+
- jupytext
22+

lectures/_config.yml

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
title: Python Programming for Economics and Finance
2+
author: Thomas J. Sargent & John Stachurski (Translation by Zahra Khanzadeh)
3+
logo: _static/qe-logo.png
4+
description: This website presents a set of lectures on python programming for economics, designed and written by Thomas J. Sargent and John Stachurski (translated by Zahra Khanzadeh).
5+
6+
execute:
7+
execute_notebooks: "cache"
8+
timeout: 600 # 10 minutes
9+
10+
html:
11+
baseurl: https://python-programming-fa.quantecon.org/
12+
13+
latex:
14+
latex_documents:
15+
targetname: quantecon-python-programming-fa.tex
16+
17+
sphinx:
18+
extra_extensions: [sphinx_multitoc_numbering, sphinxext.rediraffe, sphinx_tojupyter, sphinx_exercise, sphinx_togglebutton]
19+
config:
20+
# bibtex_reference_style: author_year #TODO: enable if bibtex bibliography is used in series
21+
# false-positive links
22+
linkcheck_ignore: ['https://github.com/matplotlib/matplotlib/blob/v3.6.2/lib/matplotlib/axes/_axes.py#L1417-L1669',
23+
'https://ieeexplore.ieee.org/document/8757088',
24+
'https://www.sciencedirect.com/science/article/pii/S1477388021000177',
25+
'https://keras.io/',
26+
'https://data.oecd.org/',
27+
'https://www.reddit.com/',
28+
'https://openai.com',
29+
'https://chatgpt.com/']
30+
html_favicon: _static/lectures-favicon.ico
31+
html_theme: quantecon_book_theme
32+
html_static_path: ['_static']
33+
html_theme_options:
34+
authors:
35+
- name: Thomas J. Sargent
36+
url: http://www.tomsargent.com/
37+
- name: John Stachurski
38+
url: https://johnstachurski.net/
39+
dark_logo: quantecon-logo-transparent.png
40+
header_organisation_url: https://quantecon.org
41+
header_organisation: QuantEcon
42+
repository_url: https://github.com/QuantEcon/lecture-python-programming.fa
43+
nb_repository_url: https://github.com/QuantEcon/lecture-python-programming.fa.notebooks
44+
twitter: quantecon
45+
twitter_logo_url: https://assets.quantecon.org/img/qe-twitter-logo.png
46+
og_logo_url: https://assets.quantecon.org/img/qe-og-logo.png
47+
description: This website presents a set of lectures on python programming for economics, designed and written by Thomas J. Sargent and John Stachurski.
48+
keywords: Python, QuantEcon, Quantitative Economics, Economics, Sloan, Alfred P. Sloan Foundation, Tom J. Sargent, John Stachurski
49+
analytics:
50+
google_analytics_id: G-X7DH1M2DPY
51+
launch_buttons:
52+
notebook_interface : classic # The interface interactive links will activate ["classic", "jupyterlab"]
53+
colab_url : https://colab.research.google.com
54+
thebe : false # Add a thebe button to pages (requires the repository to run on Binder)
55+
mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
56+
rediraffe_redirects:
57+
index_toc.md: intro.md
58+
tojupyter_static_file_path: ["source/_static", "_static"]
59+
tojupyter_target_html: true
60+
tojupyter_urlpath: "https://python-programming-fa.quantecon.org/"
61+
tojupyter_image_urlpath: "https://python-programming-fa.quantecon.org/_static/"
62+
tojupyter_lang_synonyms: ["ipython", "ipython3", "python"]
63+
tojupyter_kernels:
64+
python3:
65+
kernelspec:
66+
display_name: "Python"
67+
language: python3
68+
name: python3
69+
file_extension: ".py"
70+
tojupyter_images_markdown: true

lectures/_static/includes/header.raw

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. raw:: html
2+
3+
<div id="qe-notebook-header" align="right" style="text-align:right;">
4+
<a href="https://quantecon.org/" title="quantecon.org">
5+
<img style="width:250px;display:inline;" width="250px" src="https://assets.quantecon.org/img/qe-menubar-logo.svg" alt="QuantEcon">
6+
</a>
7+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. raw:: html
2+
3+
<div id="qe-notebook-header" style="text-align:right;">
4+
<a href="https://quantecon.org/" title="quantecon.org">
5+
<img style="width:250px;display:inline;" src="https://assets.quantecon.org/img/qe-menubar-logo.svg" alt="QuantEcon">
6+
</a>
7+
</div>
Loading
Loading
File renamed without changes.

0 commit comments

Comments
 (0)