From 9b8e64c48b351b56b9119528099484c54212f881 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Thu, 11 Jan 2024 13:56:27 -0800 Subject: [PATCH 01/10] Add a draft for an environment.yml file --- environment.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 environment.yml diff --git a/environment.yml b/environment.yml new file mode 100644 index 00000000..971942a3 --- /dev/null +++ b/environment.yml @@ -0,0 +1,8 @@ +name: user-tutorials +channels: + - conda-forge +dependencies: + - python=3.10.* + - pip + - nodejs>=20,<21 + - mystmd From e23ecdec6fc6b491794a4ef1cc56022f0c043ef0 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 15 Apr 2024 15:51:26 -0700 Subject: [PATCH 02/10] Add requirements to run the notebooks Also rename the environment --- environment.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 971942a3..866be0bb 100644 --- a/environment.yml +++ b/environment.yml @@ -1,8 +1,13 @@ -name: user-tutorials +name: simpeg-user-tutorials channels: - conda-forge dependencies: - python=3.10.* - - pip + # Myst requirements - nodejs>=20,<21 - mystmd + # Notebook requirements + - jupyter + - SimPEG==0.20.* + - discretize==0.10.* + - pymatsolver From 6ffe6065d2efa735b9078cebe0e72a5b12757884 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 15 Apr 2024 16:00:28 -0700 Subject: [PATCH 03/10] Draft workflow to run notebooks in GH Actions --- .github/workflows/run.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/run.yml diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml new file mode 100644 index 00000000..3c9e0272 --- /dev/null +++ b/.github/workflows/run.yml @@ -0,0 +1,32 @@ +name: Rerun the notebooks + +on: + # Run this action manually + workflow_dispatch: + +jobs: + run-notebooks: + runs-on: ubuntu-latest + env: + PYTHON: "3.10" + + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Setup Miniconda + uses: conda-incubator/setup-miniconda@v3 + with: + auto-update-conda: true + python-version: ${{ env.PYTHON }} + + - name: Create environment + run: + conda env create -f environment.yml + + - name: List installed packages + run: conda list + + - name: Run notebook + run: + jupyter-nbconvert --execute --to notebook --inplace --allow-errors --ExecutePreprocessor.kernel_name=python3 notebooks/03-gravity/*.ipynb From 3960206b4bc14866196af6066c875a291b2b620a Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 15 Apr 2024 16:05:43 -0700 Subject: [PATCH 04/10] Remove trailing colon --- .github/workflows/run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 3c9e0272..c03f0727 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -2,7 +2,7 @@ name: Rerun the notebooks on: # Run this action manually - workflow_dispatch: + workflow_dispatch jobs: run-notebooks: From f4df9e9cea72d24189c8ba63a488879b4cded264 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 15 Apr 2024 16:08:26 -0700 Subject: [PATCH 05/10] Run action on pull request and on pushes to main Enable this event triggers to check the action runs well. --- .github/workflows/run.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index c03f0727..c7bdcfcd 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -1,7 +1,11 @@ name: Rerun the notebooks on: - # Run this action manually + pull_request: + push: + branches: + - main + # Run this action manually (this file needs to be in the default branch) workflow_dispatch jobs: From 89e9d91140d009ba850225b3323fb4d8affb4b48 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 15 Apr 2024 16:13:24 -0700 Subject: [PATCH 06/10] Restore the colon --- .github/workflows/run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index c7bdcfcd..0f2aa099 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -6,7 +6,7 @@ on: branches: - main # Run this action manually (this file needs to be in the default branch) - workflow_dispatch + workflow_dispatch: jobs: run-notebooks: From f677edee3c54af5cdc0a2a5e8a9c281d86e90ad2 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 15 Apr 2024 16:20:46 -0700 Subject: [PATCH 07/10] Use jupyter execute instead of nbconvert --- .github/workflows/run.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 0f2aa099..f6f4cc8e 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -33,4 +33,4 @@ jobs: - name: Run notebook run: - jupyter-nbconvert --execute --to notebook --inplace --allow-errors --ExecutePreprocessor.kernel_name=python3 notebooks/03-gravity/*.ipynb + jupyter execute --inplace notebooks/03-gravity/*.ipynb From 04f4b8af55ee6665737fe9184b33f582f4625d30 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 15 Apr 2024 16:32:18 -0700 Subject: [PATCH 08/10] Use bash for the whole run --- .github/workflows/run.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index f6f4cc8e..5f47b61a 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -14,6 +14,11 @@ jobs: env: PYTHON: "3.10" + # Use bash by default in all jobs + defaults: + run: + shell: bash -el {0} + steps: - name: Checkout repo uses: actions/checkout@v3 From a36d4ebccbebdc6a9d843b27472edc30d0939bfc Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 15 Apr 2024 16:35:44 -0700 Subject: [PATCH 09/10] Let setup-miniconda handle environment creation --- .github/workflows/run.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index 5f47b61a..b763178b 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -28,13 +28,14 @@ jobs: with: auto-update-conda: true python-version: ${{ env.PYTHON }} - - - name: Create environment - run: - conda env create -f environment.yml + activate-environment: simpeg-user-tutorial + environment-file: environment.yml + auto-activate-base: false - name: List installed packages - run: conda list + run: | + conda info + conda list - name: Run notebook run: From 370cf3aad45feb88a87c8607d80ff7cc15eddc32 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Mon, 15 Apr 2024 16:40:18 -0700 Subject: [PATCH 10/10] Run all notebooks --- .github/workflows/run.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run.yml b/.github/workflows/run.yml index b763178b..00b979a2 100644 --- a/.github/workflows/run.yml +++ b/.github/workflows/run.yml @@ -38,5 +38,8 @@ jobs: conda list - name: Run notebook - run: - jupyter execute --inplace notebooks/03-gravity/*.ipynb + run: | + for notebook in notebooks/**/*.ipynb; do + echo "Running '$notebook'" + jupyter execute --inplace $notebook + done