Skip to content
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
73 changes: 51 additions & 22 deletions .github/workflows/quantecon-env-linux.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
name: Test QuantEcon Environment (Linux)
on:
schedule:
# UTC 22:00 is early morning in Australia (Daily)
- cron: '0 22 * * *'
# UTC 22:00 is early morning in Australia on Sunday
- cron: '0 22 * * 0'
push:
branches:
- main
paths:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot what does this do? Why is it needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The paths: configuration is a GitHub Actions trigger filter that makes the workflow more efficient. It ensures the workflow only runs when the environment.yml file is modified on pushes to main, rather than running on every push.

Without this filter, the environment testing workflows would run on every commit to main (even for documentation changes or other files), which wastes CI resources. With paths: ['environment.yml'], the workflow only executes when there are actual changes to the environment file that need testing.

This pattern is applied consistently across all three platform workflows (Linux, macOS, Windows) for efficiency while maintaining the scheduled runs for regular validation.

- 'environment.yml'
jobs:
execution-tests-linux:
name: Execution Tests (${{ matrix.python-version }}, ${{ matrix.os }})
Expand All @@ -14,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: ["ubuntu-latest"]
python-version: ["3.9"]
python-version: ["3.13"]
steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -29,7 +31,7 @@ jobs:
- name: Build lecture-python-programming
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/lecture-python-programming.myst
git clone https://github.com/QuantEcon/lecture-python-programming.myst
cd lecture-python-programming.myst
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python-programming)
Expand All @@ -40,24 +42,26 @@ jobs:
path: lecture-python-programming.myst/lectures/_build/html/reports
- name: Clean (lecture-python-programming)
run: rm -rf lecture-python-programming.myst
- name: Build lecture-python

- name: Build lecture-python-intro
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/lecture-python.myst
cd lecture-python.myst
git clone https://github.com/QuantEcon/lecture-python-intro
cd lecture-python-intro
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python)
- name: Upload Execution Reports (lecture-python-intro)
uses: actions/upload-artifact@v4
if: failure()
with:
name: reports-lecture-python-${{ matrix.os }}
path: lecture-python.myst/lectures/_build/html/reports
- name: Clean (lecture-python)
run: rm -rf lecture-python.myst
name: reports-lecture-python-intro-${{ matrix.os }}
path: lecture-python-intro/lectures/_build/html/reports
- name: Clean (lecture-python-intro)
run: rm -rf lecture-python-intro

- name: Build lecture-python-advanced
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/lecture-python-advanced.myst
git clone https://github.com/QuantEcon/lecture-python-advanced.myst
cd lecture-python-advanced.myst
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python-advanced)
Expand All @@ -68,18 +72,43 @@ jobs:
path: lecture-python-advanced.myst/lectures/_build/html/reports
- name: Clean (lecture-python-advanced)
run: rm -rf lecture-python-advanced.myst
- name: Build python-lecture-sandpit.myst

- name: Install JAX, PyTorch (CPU mode)
shell: bash -l {0}
run: |
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install pyro-ppl
pip install "jax[cpu]"
pip install numpyro pyro-ppl
python scripts/test-jax-install.py

- name: Build lecture-python
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/python-lecture-sandpit.myst
cd python-lecture-sandpit.myst
jb build lectures
- name: Upload Execution Reports (python-lecture-sandpit.myst)
git clone https://github.com/QuantEcon/lecture-python.myst
cd lecture-python.myst
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python)
uses: actions/upload-artifact@v4
if: failure()
with:
name: reports-lecture-python-${{ matrix.os }}
path: lecture-python.myst/lectures/_build/html/reports
- name: Clean (lecture-python)
run: rm -rf lecture-python.myst

- name: Build lecture-jax
shell: bash -l {0}
run: |
git clone https://github.com/QuantEcon/lecture-jax
cd lecture-jax
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-jax)
uses: actions/upload-artifact@v4
if: failure()
with:
name: reports-python-lecture-sandpit.myst-${{ matrix.os }}
path: python-lecture-sandpit.myst/lectures/_build/html/reports
- name: Clean (python-lecture-sandpit.myst)
run: rm -rf python-lecture-sandpit.myst
name: reports-lecture-jax-${{ matrix.os }}
path: lecture-jax/lectures/_build/html/reports
- name: Clean (lecture-jax)
run: rm -rf lecture-jax

69 changes: 49 additions & 20 deletions .github/workflows/quantecon-env-osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
push:
branches:
- main
paths:
- 'environment.yml'
jobs:
execution-tests-osx:
name: Execution Tests (${{ matrix.python-version }}, ${{ matrix.os }})
Expand All @@ -14,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: ["macos-latest"]
python-version: ["3.9"]
python-version: ["3.13"]
steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -29,7 +31,7 @@ jobs:
- name: Build lecture-python-programming
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/lecture-python-programming.myst
git clone https://github.com/QuantEcon/lecture-python-programming.myst
cd lecture-python-programming.myst
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python-programming)
Expand All @@ -40,24 +42,26 @@ jobs:
path: lecture-python-programming.myst/lectures/_build/html/reports
- name: Clean (lecture-python-programming)
run: rm -rf lecture-python-programming.myst
- name: Build lecture-python

- name: Build lecture-python-intro
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/lecture-python.myst
cd lecture-python.myst
git clone https://github.com/QuantEcon/lecture-python-intro
cd lecture-python-intro
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python)
- name: Upload Execution Reports (lecture-python-intro)
uses: actions/upload-artifact@v4
if: failure()
with:
name: reports-lecture-python-${{ matrix.os }}
path: lecture-python.myst/lectures/_build/html/reports
- name: Clean (lecture-python)
run: rm -rf lecture-python.myst
name: reports-lecture-python-intro-${{ matrix.os }}
path: lecture-python-intro/lectures/_build/html/reports
- name: Clean (lecture-python-intro)
run: rm -rf lecture-python-intro

- name: Build lecture-python-advanced
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/lecture-python-advanced.myst
git clone https://github.com/QuantEcon/lecture-python-advanced.myst
cd lecture-python-advanced.myst
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python-advanced)
Expand All @@ -68,17 +72,42 @@ jobs:
path: lecture-python-advanced.myst/lectures/_build/html/reports
- name: Clean (lecture-python-advanced)
run: rm -rf lecture-python-advanced.myst
- name: Build python-lecture-sandpit.myst

- name: Install JAX, PyTorch (CPU mode)
shell: bash -l {0}
run: |
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install pyro-ppl
pip install "jax[cpu]"
pip install numpyro pyro-ppl
python scripts/test-jax-install.py

- name: Build lecture-python
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/python-lecture-sandpit.myst
cd python-lecture-sandpit.myst
jb build lectures
- name: Upload Execution Reports (python-lecture-sandpit.myst)
git clone https://github.com/QuantEcon/lecture-python.myst
cd lecture-python.myst
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python)
uses: actions/upload-artifact@v4
if: failure()
with:
name: reports-lecture-python-${{ matrix.os }}
path: lecture-python.myst/lectures/_build/html/reports
- name: Clean (lecture-python)
run: rm -rf lecture-python.myst

- name: Build lecture-jax
shell: bash -l {0}
run: |
git clone https://github.com/QuantEcon/lecture-jax
cd lecture-jax
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-jax)
uses: actions/upload-artifact@v4
if: failure()
with:
name: reports-python-lecture-sandpit.myst-${{ matrix.os }}
path: python-lecture-sandpit.myst/lectures/_build/html/reports
- name: Clean (python-lecture-sandpit.myst)
run: rm -rf python-lecture-sandpit.myst
name: reports-lecture-jax-${{ matrix.os }}
path: lecture-jax/lectures/_build/html/reports
- name: Clean (lecture-jax)
run: rm -rf lecture-jax
90 changes: 60 additions & 30 deletions .github/workflows/quantecon-env-win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
push:
branches:
- main
paths:
- 'environment.yml'
jobs:
execution-tests-win:
name: Execution Tests (${{ matrix.python-version }}, ${{ matrix.os }})
Expand All @@ -14,7 +16,7 @@ jobs:
fail-fast: false
matrix:
os: ["windows-latest"]
python-version: ["3.9"]
python-version: ["3.13"]
steps:
- name: Checkout
uses: actions/checkout@v5
Expand All @@ -27,9 +29,9 @@ jobs:
environment-file: environment.yml
activate-environment: quantecon
- name: Build lecture-python-programming
shell: powershell
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/lecture-python-programming.myst
git clone https://github.com/QuantEcon/lecture-python-programming.myst
cd lecture-python-programming.myst
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python-programming)
Expand All @@ -39,27 +41,29 @@ jobs:
name: reports-lecture-python-programming-${{ matrix.os }}
path: lecture-python-programming.myst/lectures/_build/html/reports
- name: Clean (lecture-python-programming)
shell: powershell
run: Remove-Item -Recurse -Force lecture-python-programming.myst
- name: Build lecture-python
shell: powershell
shell: bash -l {0}
run: rm -rf lecture-python-programming.myst

- name: Build lecture-python-intro
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/lecture-python.myst
cd lecture-python.myst
git clone https://github.com/QuantEcon/lecture-python-intro
cd lecture-python-intro
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python)
- name: Upload Execution Reports (lecture-python-intro)
uses: actions/upload-artifact@v4
if: failure()
with:
name: reports-lecture-python-${{ matrix.os }}
path: lecture-python.myst/lectures/_build/html/reports
- name: Clean (lecture-python)
shell: powershell
run: Remove-Item -Recurse -Force lecture-python.myst
name: reports-lecture-python-intro-${{ matrix.os }}
path: lecture-python-intro/lectures/_build/html/reports
- name: Clean (lecture-python-intro)
shell: bash -l {0}
run: rm -rf lecture-python-intro

- name: Build lecture-python-advanced
shell: powershell
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/lecture-python-advanced.myst
git clone https://github.com/QuantEcon/lecture-python-advanced.myst
cd lecture-python-advanced.myst
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python-advanced)
Expand All @@ -69,20 +73,46 @@ jobs:
name: reports-lecture-python-advanced-${{ matrix.os }}
path: lecture-python-advanced.myst/lectures/_build/html/reports
- name: Clean (lecture-python-advanced)
shell: powershell
run: Remove-Item -Recurse -Force lecture-python-advanced.myst
- name: Build python-lecture-sandpit.myst
shell: powershell
shell: bash -l {0}
run: rm -rf lecture-python-advanced.myst

- name: Install JAX, PyTorch (CPU mode)
shell: bash -l {0}
run: |
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
pip install pyro-ppl
pip install "jax[cpu]"
pip install numpyro pyro-ppl
python scripts/test-jax-install.py

- name: Build lecture-python
shell: bash -l {0}
run: |
git clone https://github.com/quantecon/python-lecture-sandpit.myst
cd python-lecture-sandpit.myst
jb build lectures
- name: Upload Execution Reports (python-lecture-sandpit.myst)
git clone https://github.com/QuantEcon/lecture-python.myst
cd lecture-python.myst
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-python)
uses: actions/upload-artifact@v4
if: failure()
with:
name: reports-lecture-python-${{ matrix.os }}
path: lecture-python.myst/lectures/_build/html/reports
- name: Clean (lecture-python)
shell: bash -l {0}
run: rm -rf lecture-python.myst

- name: Build lecture-jax
shell: bash -l {0}
run: |
git clone https://github.com/QuantEcon/lecture-jax
cd lecture-jax
jb build lectures -W --keep-going
- name: Upload Execution Reports (lecture-jax)
uses: actions/upload-artifact@v4
if: failure()
with:
name: reports-python-lecture-sandpit.myst-${{ matrix.os }}
path: python-lecture-sandpit.myst/lectures/_build/html/reports
- name: Clean (python-lecture-sandpit.myst)
shell: powershell
run: Remove-Item -Recurse -Force python-lecture-sandpit.myst
name: reports-lecture-jax-${{ matrix.os }}
path: lecture-jax/lectures/_build/html/reports
- name: Clean (lecture-jax)
shell: bash -l {0}
run: rm -rf lecture-jax
21 changes: 21 additions & 0 deletions scripts/test-jax-install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import jax
import jax.numpy as jnp

devices = jax.devices()
print(f"The available devices are: {devices}")

@jax.jit
def matrix_multiply(a, b):
return jnp.dot(a, b)

# Example usage:
key = jax.random.PRNGKey(0)
x = jax.random.normal(key, (1000, 1000))
y = jax.random.normal(key, (1000, 1000))
z = matrix_multiply(x, y)

# Now the function is JIT compiled and will likely run on GPU (if available)
print(z)

devices = jax.devices()
print(f"The available devices are: {devices}")