Skip to content

Commit fc5cb52

Browse files
kp992mmcky
andauthored
ENH: Test Execution for Google Collab (#441)
* Add collab testing * fix * Update .github/workflows/collab.yml enabled larger runner for ubuntu * add sphinx-proof * enable build cache * FIX: fix import * FIX: pandas relaod * Revert "FIX: pandas relaod" This reverts commit b6c5bef. * FIX: update syntax * pin pandas in CI * Revert "pin pandas in CI" This reverts commit ef7b354. * fetch latest tag * check docker env * use some tag * remove tag * try different approach to check version * hide cell and add comment --------- Co-authored-by: Matt McKay <[email protected]> Co-authored-by: mmcky <[email protected]>
1 parent 1d2633d commit fc5cb52

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed

.github/workflows/collab.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build Project on Google Collab (Execution)
2+
on: [pull_request]
3+
4+
jobs:
5+
test:
6+
runs-on: ubuntu-latest-m
7+
container:
8+
image: us-docker.pkg.dev/colab-images/public/runtime:latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
with:
12+
ref: ${{ github.event.pull_request.head.sha }}
13+
- name: Check for dockerenv file
14+
run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv)
15+
- name: Check python version
16+
shell: bash -l {0}
17+
run: |
18+
python --version
19+
- name: Display Pip Versions
20+
shell: bash -l {0}
21+
run: pip list
22+
- name: Download "build" folder (cache)
23+
uses: dawidd6/action-download-artifact@v3
24+
with:
25+
workflow: cache.yml
26+
branch: main
27+
name: build-cache
28+
path: _build
29+
# Install build software
30+
- name: Install Build Software
31+
shell: bash -l {0}
32+
run: |
33+
pip install jupyter-book==0.15.1 docutils==0.17.1 quantecon-book-theme==0.7.1 sphinx-tojupyter==0.3.0 sphinxext-rediraffe==0.2.7 sphinx-exercise==0.4.1 sphinxcontrib-youtube==1.1.0 sphinx-togglebutton==0.3.1 arviz==0.13.0 sphinx_proof==0.1.3
34+
# Build of HTML (Execution Testing)
35+
- name: Build HTML
36+
shell: bash -l {0}
37+
run: |
38+
jb build lectures --path-output ./ -n -W --keep-going
39+
- name: Upload Execution Reports
40+
uses: actions/upload-artifact@v4
41+
if: failure()
42+
with:
43+
name: execution-reports
44+
path: _build/html/reports
45+
- name: Preview Deploy to Netlify
46+
uses: nwtgck/actions-netlify@v2
47+
with:
48+
publish-dir: '_build/html/'
49+
production-branch: main
50+
github-token: ${{ secrets.GITHUB_TOKEN }}
51+
deploy-message: "Preview Deploy from GitHub Actions"
52+
env:
53+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
54+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

lectures/inflation_history.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ The `xlrd` package is used by `pandas` to perform operations on Excel files.
2424
!pip install xlrd
2525
```
2626

27-
This lecture also requires `pandas >= 2.1.4`
27+
<!-- Check for pandas>=2.1.4 for Google Collab Compat -->
2828

2929
```{code-cell} ipython3
30-
:tags: [hide-output]
30+
:tags: [hide-cell]
31+
from importlib.metadata import version
3132
from packaging.version import Version
32-
import pandas as pd
33-
if Version(pd.__version__) < Version('2.1.4'):
34-
!pip install pandas==2.1.4
35-
reload(pandas)
33+
34+
if Version(version("pandas")) < Version('2.1.4'):
35+
!pip install "pandas>=2.1.4"
3636
```
3737

3838
We can then import the Python modules we will use.

0 commit comments

Comments
 (0)