From fc5cb52272d26e7efb7c7f365699a87cb5d278e6 Mon Sep 17 00:00:00 2001 From: kp992 <145801876+kp992@users.noreply.github.com> Date: Tue, 21 May 2024 06:21:50 +0530 Subject: [PATCH] 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 b6c5bef6974052404496bafbf9786cbcf3784839. * FIX: update syntax * pin pandas in CI * Revert "pin pandas in CI" This reverts commit ef7b3541592bee6b17c5b8fb1643ca4f91480deb. * 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 Co-authored-by: mmcky --- .github/workflows/collab.yml | 54 +++++++++++++++++++++++++++++++++++ lectures/inflation_history.md | 12 ++++---- 2 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/collab.yml diff --git a/.github/workflows/collab.yml b/.github/workflows/collab.yml new file mode 100644 index 00000000..a785504f --- /dev/null +++ b/.github/workflows/collab.yml @@ -0,0 +1,54 @@ +name: Build Project on Google Collab (Execution) +on: [pull_request] + +jobs: + test: + runs-on: ubuntu-latest-m + container: + image: us-docker.pkg.dev/colab-images/public/runtime:latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: Check for dockerenv file + run: (ls /.dockerenv && echo Found dockerenv) || (echo No dockerenv) + - name: Check python version + shell: bash -l {0} + run: | + python --version + - name: Display Pip Versions + shell: bash -l {0} + run: pip list + - name: Download "build" folder (cache) + uses: dawidd6/action-download-artifact@v3 + with: + workflow: cache.yml + branch: main + name: build-cache + path: _build + # Install build software + - name: Install Build Software + shell: bash -l {0} + run: | + 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 + # Build of HTML (Execution Testing) + - 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() + with: + name: execution-reports + path: _build/html/reports + - name: Preview Deploy to Netlify + uses: nwtgck/actions-netlify@v2 + with: + publish-dir: '_build/html/' + production-branch: main + github-token: ${{ secrets.GITHUB_TOKEN }} + deploy-message: "Preview Deploy from GitHub Actions" + env: + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} diff --git a/lectures/inflation_history.md b/lectures/inflation_history.md index 2f57c0d3..afb36a85 100644 --- a/lectures/inflation_history.md +++ b/lectures/inflation_history.md @@ -24,15 +24,15 @@ The `xlrd` package is used by `pandas` to perform operations on Excel files. !pip install xlrd ``` -This lecture also requires `pandas >= 2.1.4` + ```{code-cell} ipython3 -:tags: [hide-output] +:tags: [hide-cell] +from importlib.metadata import version from packaging.version import Version -import pandas as pd -if Version(pd.__version__) < Version('2.1.4'): - !pip install pandas==2.1.4 - reload(pandas) + +if Version(version("pandas")) < Version('2.1.4'): + !pip install "pandas>=2.1.4" ``` We can then import the Python modules we will use.