From 695170f7aa0bad75a25925f2b2ed105fa2f39e96 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 21:33:35 +0530 Subject: [PATCH 01/21] #123 rename: `release-action` to `release_action` --- .github/workflows/{release-action.yaml => release_action.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{release-action.yaml => release_action.yaml} (100%) diff --git a/.github/workflows/release-action.yaml b/.github/workflows/release_action.yaml similarity index 100% rename from .github/workflows/release-action.yaml rename to .github/workflows/release_action.yaml From bff90d64a3e8719e2e40d5b7b0a255cd99bc2570 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 22:56:49 +0530 Subject: [PATCH 02/21] #123 add custom script to dynamically generate matrix --- .github/workflows/build_matrix.sh | 41 +++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/build_matrix.sh diff --git a/.github/workflows/build_matrix.sh b/.github/workflows/build_matrix.sh new file mode 100644 index 000000000..4c01650d4 --- /dev/null +++ b/.github/workflows/build_matrix.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +# This helper script generates a matrix for further use in the +# scheduled/nightly builds for PyBOP, i.e., in scheduled_tests.yaml +# It generates a matrix of all combinations of the following variables: +# - python_version: 3.8, 3.9, 3.10, 3.11 +# - os: ubuntu-latest, windows-latest, macos-latest +# - pybamm_version: the last four versions of PyBaMM from PyPI + +python_version=("3.8" "3.9" "3.10" "3.11") +os=("ubuntu-latest" "windows-latest" "macos-latest") +# This command fetches the last four PyBaMM versions excluding release candidates from PyPI +pybamm_version=$(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 4 | tr '\n' ' ') + +json='{ + "include": [ +' + +# loop through each combination of variables to generate matrix components +for py_ver in "${python_version[@]}"; do + for os_type in "${os[@]}"; do + for pybamm_ver in "${pybamm_version[@]}"; do + json+='{ + "os": "'$os_type'", + "python_version": "'$py_ver'", + "pybamm_version": "'$pybamm_ver'" + },' + done + done +done + +# fix structure, removing trailing comma +json=${json%,} + +# close dict +json+=' + ] +}' + + +echo "$json" | jq . From 4f64bd44c40813c98b389120e1ad9cd2060042d8 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 22:57:29 +0530 Subject: [PATCH 03/21] #123 run script, pass generated matrix to next job --- .github/workflows/scheduled_tests.yaml | 38 ++++++++++++++++++-------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/scheduled_tests.yaml b/.github/workflows/scheduled_tests.yaml index 83a0d986b..b7aae94ee 100644 --- a/.github/workflows/scheduled_tests.yaml +++ b/.github/workflows/scheduled_tests.yaml @@ -11,20 +11,36 @@ on: - cron: '0 9 * * *' jobs: + # Dynamically create a matrix of OS, Python, and PyBaMM versions + create_pybamm_matrix: + runs-on: ubuntu-latest + outputs: + pybop_matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - name: Check out PyBOP repository + uses: actions/checkout@v4 + with: + path: .github/workflows/build_matrix.sh + + - name: Dynamically create GitHub Actions matrix + id: set-matrix + run: | + bash .github/workflows/build_matrix.sh >> matrix_json + echo "matrix=$(cat matrix_json)" >> "$GITHUB_OUTPUT" + build: + needs: [create_pybamm_matrix] runs-on: ${{ matrix.os }} strategy: fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.8", "3.9", "3.10", "3.11"] + matrix: ${{fromJson(needs.create_pybamm_matrix.outputs.pybop_matrix)}} steps: - uses: actions/checkout@v4 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python ${{ matrix.python_version }} uses: actions/setup-python@v4 with: - python-version: ${{ matrix.python-version }} + python-version: ${{ matrix.python_version }} - name: Install dependencies run: | python -m pip install --upgrade pip nox @@ -33,7 +49,7 @@ jobs: python -m nox -s unit python -m nox -s notebooks - #M-series Mac Mini + # M-series Mac Mini build-apple-mseries: runs-on: [self-hosted, macOS, ARM64] env: @@ -41,7 +57,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10"] + python_version: ["3.10"] steps: - uses: actions/checkout@v4 @@ -49,14 +65,14 @@ jobs: shell: bash run: | eval "$(pyenv init -)" - pyenv install ${{ matrix.python-version }} -s - pyenv virtualenv ${{ matrix.python-version }} pybop-${{ matrix.python-version }} + pyenv install ${{ matrix.python_version }} -s + pyenv virtualenv ${{ matrix.python_version }} pybop-${{ matrix.python_version }} - name: Install dependencies & run unit tests shell: bash run: | eval "$(pyenv init -)" - pyenv activate pybop-${{ matrix.python-version }} + pyenv activate pybop-${{ matrix.python_version }} python -m pip install --upgrade pip wheel setuptools nox python -m nox -s unit python -m nox -s notebooks @@ -66,5 +82,5 @@ jobs: shell: bash run: | eval "$(pyenv init -)" - pyenv activate pybop-${{ matrix.python-version }} + pyenv activate pybop-${{ matrix.python_version }} pyenv uninstall -f $( python --version ) From 48a3e12dca512a520b66d9ad362ab2788b18c193 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:01:38 +0530 Subject: [PATCH 04/21] #123 make script executable prior to running it --- .github/workflows/scheduled_tests.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/scheduled_tests.yaml b/.github/workflows/scheduled_tests.yaml index b7aae94ee..e244bf0bc 100644 --- a/.github/workflows/scheduled_tests.yaml +++ b/.github/workflows/scheduled_tests.yaml @@ -13,6 +13,7 @@ on: jobs: # Dynamically create a matrix of OS, Python, and PyBaMM versions create_pybamm_matrix: + name: Dynamically create GitHub Actions matrix runs-on: ubuntu-latest outputs: pybop_matrix: ${{ steps.set-matrix.outputs.matrix }} @@ -22,9 +23,11 @@ jobs: with: path: .github/workflows/build_matrix.sh - - name: Dynamically create GitHub Actions matrix + - name: Run script to create matrix id: set-matrix run: | + chmod +x .github/workflows/build_matrix.sh + git update-index --chmod=+x ./.github/workflows/build_matrix.sh bash .github/workflows/build_matrix.sh >> matrix_json echo "matrix=$(cat matrix_json)" >> "$GITHUB_OUTPUT" From c32436529b517e62aec01874a50467192e414ab5 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:03:09 +0530 Subject: [PATCH 05/21] #123 don't allow running M-series builds on forks --- .github/workflows/scheduled_tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/scheduled_tests.yaml b/.github/workflows/scheduled_tests.yaml index e244bf0bc..447877aa0 100644 --- a/.github/workflows/scheduled_tests.yaml +++ b/.github/workflows/scheduled_tests.yaml @@ -55,6 +55,7 @@ jobs: # M-series Mac Mini build-apple-mseries: runs-on: [self-hosted, macOS, ARM64] + if: github.repository == 'pybop-team/PyBOP' env: GITHUB_PATH: ${PYENV_ROOT/bin:$PATH} strategy: From e56eb36ba744bb2be79bb0e049e71d29daa53f9f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:04:14 +0530 Subject: [PATCH 06/21] #123 don't use `git update-index` for file permissions --- .github/workflows/scheduled_tests.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/scheduled_tests.yaml b/.github/workflows/scheduled_tests.yaml index 447877aa0..08694cd6f 100644 --- a/.github/workflows/scheduled_tests.yaml +++ b/.github/workflows/scheduled_tests.yaml @@ -27,7 +27,6 @@ jobs: id: set-matrix run: | chmod +x .github/workflows/build_matrix.sh - git update-index --chmod=+x ./.github/workflows/build_matrix.sh bash .github/workflows/build_matrix.sh >> matrix_json echo "matrix=$(cat matrix_json)" >> "$GITHUB_OUTPUT" From 8c06d233c1323926e76717f4272d349e45f5ef2d Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:08:54 +0530 Subject: [PATCH 07/21] #123 move script to a dedicated `scripts/ci/` folder --- {.github/workflows => scripts/ci}/build_matrix.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {.github/workflows => scripts/ci}/build_matrix.sh (100%) diff --git a/.github/workflows/build_matrix.sh b/scripts/ci/build_matrix.sh similarity index 100% rename from .github/workflows/build_matrix.sh rename to scripts/ci/build_matrix.sh From bfe8474ddbe841554f9fd7df0fd854fecfcd04bd Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:09:13 +0530 Subject: [PATCH 08/21] #123 correctly sparse checkout the matrix script --- .github/workflows/scheduled_tests.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scheduled_tests.yaml b/.github/workflows/scheduled_tests.yaml index 08694cd6f..ba2bd4ecc 100644 --- a/.github/workflows/scheduled_tests.yaml +++ b/.github/workflows/scheduled_tests.yaml @@ -21,13 +21,14 @@ jobs: - name: Check out PyBOP repository uses: actions/checkout@v4 with: - path: .github/workflows/build_matrix.sh + sparse-checkout-cone-mode: false + sparse-checkout: | + scripts/ci/build_matrix.sh - name: Run script to create matrix id: set-matrix run: | - chmod +x .github/workflows/build_matrix.sh - bash .github/workflows/build_matrix.sh >> matrix_json + bash scripts/ci/build_matrix.sh >> matrix_json echo "matrix=$(cat matrix_json)" >> "$GITHUB_OUTPUT" build: From 77e233d8641824cd2f794f172199801360241480 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:46:32 +0530 Subject: [PATCH 09/21] #123 fix up script to return valid JSON --- scripts/ci/build_matrix.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ci/build_matrix.sh b/scripts/ci/build_matrix.sh index 4c01650d4..90bcacf88 100644 --- a/scripts/ci/build_matrix.sh +++ b/scripts/ci/build_matrix.sh @@ -10,7 +10,7 @@ python_version=("3.8" "3.9" "3.10" "3.11") os=("ubuntu-latest" "windows-latest" "macos-latest") # This command fetches the last four PyBaMM versions excluding release candidates from PyPI -pybamm_version=$(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 4 | tr '\n' ' ') +pybamm_version=($(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 4 | awk '{print "\"" $1 "\"" }' | paste -sd " " -)) json='{ "include": [ @@ -23,7 +23,7 @@ for py_ver in "${python_version[@]}"; do json+='{ "os": "'$os_type'", "python_version": "'$py_ver'", - "pybamm_version": "'$pybamm_ver'" + "pybamm_version": '$pybamm_ver' },' done done @@ -37,5 +37,5 @@ json+=' ] }' - -echo "$json" | jq . +# escape "" quotes with \ and print the JSON output in one line +echo "$json" | jq -c . | sed 's/"/\\"/g' From d26a48fa331cbcb0f5fa9cd105dc095a06adb1f0 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Sun, 11 Feb 2024 23:46:49 +0530 Subject: [PATCH 10/21] #123 simplify GitHub Actions output processing --- .github/workflows/scheduled_tests.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/scheduled_tests.yaml b/.github/workflows/scheduled_tests.yaml index ba2bd4ecc..a0eb23809 100644 --- a/.github/workflows/scheduled_tests.yaml +++ b/.github/workflows/scheduled_tests.yaml @@ -28,8 +28,7 @@ jobs: - name: Run script to create matrix id: set-matrix run: | - bash scripts/ci/build_matrix.sh >> matrix_json - echo "matrix=$(cat matrix_json)" >> "$GITHUB_OUTPUT" + echo "matrix=$(bash scripts/ci/build_matrix.sh)" >> "$GITHUB_OUTPUT" build: needs: [create_pybamm_matrix] From a4e0979f0ddb4dbe38fe7b0291d42d580479e081 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 12 Feb 2024 00:07:00 +0530 Subject: [PATCH 11/21] #123 convert JSON to string before parsing --- scripts/ci/build_matrix.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/build_matrix.sh b/scripts/ci/build_matrix.sh index 90bcacf88..7850c2c70 100644 --- a/scripts/ci/build_matrix.sh +++ b/scripts/ci/build_matrix.sh @@ -38,4 +38,4 @@ json+=' }' # escape "" quotes with \ and print the JSON output in one line -echo "$json" | jq -c . | sed 's/"/\\"/g' +echo "$json" | jq -r 'tostring' | sed 's/"/\\"/g' From 4679821dbd538a90ee09491b16dcc2124b2ea424 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 12 Feb 2024 00:11:14 +0530 Subject: [PATCH 12/21] #123 move output before all jobs and test --- .github/workflows/scheduled_tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scheduled_tests.yaml b/.github/workflows/scheduled_tests.yaml index a0eb23809..b7401a897 100644 --- a/.github/workflows/scheduled_tests.yaml +++ b/.github/workflows/scheduled_tests.yaml @@ -15,8 +15,6 @@ jobs: create_pybamm_matrix: name: Dynamically create GitHub Actions matrix runs-on: ubuntu-latest - outputs: - pybop_matrix: ${{ steps.set-matrix.outputs.matrix }} steps: - name: Check out PyBOP repository uses: actions/checkout@v4 @@ -29,6 +27,8 @@ jobs: id: set-matrix run: | echo "matrix=$(bash scripts/ci/build_matrix.sh)" >> "$GITHUB_OUTPUT" + outputs: + pybop_matrix: ${{ steps.set-matrix.outputs.matrix }} build: needs: [create_pybamm_matrix] From d09b5371c1c98d3dfa589b1e75320d566cab3063 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 12 Feb 2024 00:11:33 +0530 Subject: [PATCH 13/21] #123 don't convert JSON output to raw strings --- scripts/ci/build_matrix.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/build_matrix.sh b/scripts/ci/build_matrix.sh index 7850c2c70..12432c64e 100644 --- a/scripts/ci/build_matrix.sh +++ b/scripts/ci/build_matrix.sh @@ -38,4 +38,4 @@ json+=' }' # escape "" quotes with \ and print the JSON output in one line -echo "$json" | jq -r 'tostring' | sed 's/"/\\"/g' +echo "$json" | jq -c . From 4d9d73267b919548b8fee8c6a53c5d3a2d38f4fe Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 12 Feb 2024 00:14:02 +0530 Subject: [PATCH 14/21] #123 matrix script is working now, clean it up --- scripts/ci/build_matrix.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/ci/build_matrix.sh b/scripts/ci/build_matrix.sh index 12432c64e..c0132b43f 100644 --- a/scripts/ci/build_matrix.sh +++ b/scripts/ci/build_matrix.sh @@ -3,15 +3,18 @@ # This helper script generates a matrix for further use in the # scheduled/nightly builds for PyBOP, i.e., in scheduled_tests.yaml # It generates a matrix of all combinations of the following variables: -# - python_version: 3.8, 3.9, 3.10, 3.11 +# - python_version: 3.X # - os: ubuntu-latest, windows-latest, macos-latest -# - pybamm_version: the last four versions of PyBaMM from PyPI +# - pybamm_version: the last four versions of PyBaMM from PyPI, excluding release candidates + +# To update the matrix, the variables below can be modified as needed. python_version=("3.8" "3.9" "3.10" "3.11") os=("ubuntu-latest" "windows-latest" "macos-latest") # This command fetches the last four PyBaMM versions excluding release candidates from PyPI pybamm_version=($(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 4 | awk '{print "\"" $1 "\"" }' | paste -sd " " -)) +# open dict json='{ "include": [ ' @@ -37,5 +40,4 @@ json+=' ] }' -# escape "" quotes with \ and print the JSON output in one line echo "$json" | jq -c . From 03bf40c705b92d59cef9f4d31984c2a125bb5ccc Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 12 Feb 2024 00:16:16 +0530 Subject: [PATCH 15/21] #123 specify a prettified job name via matrix variables --- .github/workflows/scheduled_tests.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/scheduled_tests.yaml b/.github/workflows/scheduled_tests.yaml index b7401a897..169a28fc7 100644 --- a/.github/workflows/scheduled_tests.yaml +++ b/.github/workflows/scheduled_tests.yaml @@ -32,6 +32,7 @@ jobs: build: needs: [create_pybamm_matrix] + name: Build (${{ matrix.os }}, Python ${{ matrix.python_version }}, PyBaMM ${{ matrix.pybamm_version }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false From b77d93234f9469b24b6fa3e1df4a3b2113e24770 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:03:08 +0530 Subject: [PATCH 16/21] #123 temporarily fetch last three versions, not four --- scripts/ci/build_matrix.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/ci/build_matrix.sh b/scripts/ci/build_matrix.sh index c0132b43f..49b13d54e 100644 --- a/scripts/ci/build_matrix.sh +++ b/scripts/ci/build_matrix.sh @@ -5,14 +5,14 @@ # It generates a matrix of all combinations of the following variables: # - python_version: 3.X # - os: ubuntu-latest, windows-latest, macos-latest -# - pybamm_version: the last four versions of PyBaMM from PyPI, excluding release candidates +# - pybamm_version: the last X versions of PyBaMM from PyPI, excluding release candidates # To update the matrix, the variables below can be modified as needed. python_version=("3.8" "3.9" "3.10" "3.11") os=("ubuntu-latest" "windows-latest" "macos-latest") -# This command fetches the last four PyBaMM versions excluding release candidates from PyPI -pybamm_version=($(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 4 | awk '{print "\"" $1 "\"" }' | paste -sd " " -)) +# This command fetches the last three PyBaMM versions excluding release candidates from PyPI +pybamm_version=($(curl -s https://pypi.org/pypi/pybamm/json | jq -r '.releases | keys[]' | grep -v rc | tail -n 3 | awk '{print "\"" $1 "\"" }' | paste -sd " " -)) # open dict json='{ From bcc7983382ffb823f74b033b9b65234bc07b7b8c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:07:14 +0530 Subject: [PATCH 17/21] #123 add `PYBOP_SCHEDULED` and `PYBAMM_VERSION` --- noxfile.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/noxfile.py b/noxfile.py index ddb7bd191..c14e5b880 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,20 +1,31 @@ +import os import nox + # nox options nox.options.reuse_existing_virtualenvs = True +nox.options.venv_backend = "virtualenv" + +# Environment variables to control CI behaviour for nox sessions +PYBOP_SCHEDULED = int(os.environ.get("PYBOP_SCHEDULED", 0)) +PYBAMM_VERSION = os.environ.get("PYBAMM_VERSION", None) @nox.session def unit(session): - session.run_always("pip", "install", "-e", ".[all]") - session.install("pytest", "pytest-mock") + session.install("-e", ".[all]", silent=False) + if PYBOP_SCHEDULED: + session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False) + session.install("pytest", "pytest-mock", silent=False) session.run("pytest", "--unit") @nox.session def coverage(session): - session.run_always("pip", "install", "-e", ".[all]") - session.install("pytest", "pytest-cov", "pytest-mock") + session.install("-e", ".[all]", silent=False) + if PYBOP_SCHEDULED: + session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False) + session.install("pytest", "pytest-cov", "pytest-mock", silent=False) session.run( "pytest", "--unit", @@ -27,8 +38,10 @@ def coverage(session): @nox.session def notebooks(session): """Run the examples tests for Jupyter notebooks.""" - session.run_always("pip", "install", "-e", ".[all]") - session.install("pytest", "nbmake") + session.install("-e", ".[all]", silent=False) + if PYBOP_SCHEDULED: + session.run("pip", "install", f"pybamm=={PYBAMM_VERSION}", silent=False) + session.install("pytest", "nbmake", silent=False) session.run("pytest", "--nbmake", "--examples", "examples/", external=True) @@ -39,7 +52,7 @@ def docs(session): Credit: PyBaMM Team """ envbindir = session.bin - session.install("-e", ".[all,docs]") + session.install("-e", ".[all,docs]", silent=False) session.chdir("docs") # Local development if session.interactive: From 23b7be23f7adb783a4571a367e4d28ed596a6fea Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Mon, 12 Feb 2024 21:07:42 +0530 Subject: [PATCH 18/21] #123 configure `PYBAMM_VERSION` env var --- .github/workflows/scheduled_tests.yaml | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/scheduled_tests.yaml b/.github/workflows/scheduled_tests.yaml index 169a28fc7..e281fe6c1 100644 --- a/.github/workflows/scheduled_tests.yaml +++ b/.github/workflows/scheduled_tests.yaml @@ -10,6 +10,10 @@ on: schedule: - cron: '0 9 * * *' +# Check noxfile.py for associated environment variables +env: + PYBOP_SCHEDULED: 1 + jobs: # Dynamically create a matrix of OS, Python, and PyBaMM versions create_pybamm_matrix: @@ -37,6 +41,8 @@ jobs: strategy: fail-fast: false matrix: ${{fromJson(needs.create_pybamm_matrix.outputs.pybop_matrix)}} + env: + PYBAMM_VERSION: ${{ matrix.pybamm_version }} steps: - uses: actions/checkout@v4 @@ -44,13 +50,16 @@ jobs: uses: actions/setup-python@v4 with: python-version: ${{ matrix.python_version }} + - name: Install dependencies run: | python -m pip install --upgrade pip nox + - name: Unit tests with nox - run: | - python -m nox -s unit - python -m nox -s notebooks + run: python -m nox -s unit + + - name: Run notebooks with nox + run: python -m nox -s notebooks # M-series Mac Mini build-apple-mseries: From 08c72b13db5e7f06a7ae4d16711ee6189f2b5a2b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Tue, 13 Feb 2024 21:50:41 +0530 Subject: [PATCH 19/21] #123 add feature note to CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0077ef9f4..9ef471275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Features +- [#123](https://github.com/pybop-team/PyBOP/issues/187) - Configures scheduled tests to run against the last three PyPI releases of PyBaMM via dynamic GitHub Actions matrix generation. - [#187](https://github.com/pybop-team/PyBOP/issues/187) - Adds M1 Github runner to `test_on_push` workflow, updt. self-hosted supported python versions in scheduled tests. - [#118](https://github.com/pybop-team/PyBOP/issues/118) - Adds example jupyter notebooks. - [#151](https://github.com/pybop-team/PyBOP/issues/151) - Adds a standalone version of the Problem class. @@ -15,6 +16,7 @@ - [#164](https://github.com/pybop-team/PyBOP/issues/164) - Fixes convergence issues with gradient-based optimisers, changes default `model.check_params()` to allow infeasible solutions during optimisation iterations. Adds a feasibility check on the optimal parameters. # [v23.12](https://github.com/pybop-team/PyBOP/tree/v23.12) - 2023-12-19 + ## Features - [#141](https://github.com/pybop-team/PyBOP/pull/141) - Adds documentation with Sphinx and PyData Sphinx Theme. Updates docstrings across package, relocates `costs` and `dataset` to top-level of package. Adds noxfile session and deployment workflow for docs. From 937aea4874a9bca3cb10ed915165300a7db0da3f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:40:07 +0530 Subject: [PATCH 20/21] #123 moving forward with PyBaMM parameter set check Coverage is already up for this, this is just for PyBaMM 23.5 --- pybop/parameters/parameter_set.py | 6 ++++++ tests/unit/test_parameter_sets.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pybop/parameters/parameter_set.py b/pybop/parameters/parameter_set.py index 946d05baa..8a99b8b2f 100644 --- a/pybop/parameters/parameter_set.py +++ b/pybop/parameters/parameter_set.py @@ -152,4 +152,10 @@ def pybamm(cls, name): pybamm.ParameterValues A PyBaMM parameter set corresponding to the provided name. """ + + msg = f"Parameter set '{name}' is not a valid PyBaMM parameter set. Available parameter sets are: {list(pybamm.parameter_sets)}" + + if name not in list(pybamm.parameter_sets): + raise ValueError(msg) + return pybamm.ParameterValues(name).copy() diff --git a/tests/unit/test_parameter_sets.py b/tests/unit/test_parameter_sets.py index fc9356d2f..39d29d415 100644 --- a/tests/unit/test_parameter_sets.py +++ b/tests/unit/test_parameter_sets.py @@ -10,7 +10,7 @@ class TestParameterSets: @pytest.mark.unit def test_parameter_set(self): - # Tests parameter set creation + # Tests parameter set creation and validation with pytest.raises(ValueError): pybop.ParameterSet.pybamm("sChen2010s") From 9572d8f28e600fd0f5c08e0d2c242fcc034f02e9 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 14 Feb 2024 18:40:53 +0530 Subject: [PATCH 21/21] #123 update CHANGELOG under bug fixes --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ef471275..d089db95f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Features -- [#123](https://github.com/pybop-team/PyBOP/issues/187) - Configures scheduled tests to run against the last three PyPI releases of PyBaMM via dynamic GitHub Actions matrix generation. +- [#123](https://github.com/pybop-team/PyBOP/issues/123) - Configures scheduled tests to run against the last three PyPI releases of PyBaMM via dynamic GitHub Actions matrix generation. - [#187](https://github.com/pybop-team/PyBOP/issues/187) - Adds M1 Github runner to `test_on_push` workflow, updt. self-hosted supported python versions in scheduled tests. - [#118](https://github.com/pybop-team/PyBOP/issues/118) - Adds example jupyter notebooks. - [#151](https://github.com/pybop-team/PyBOP/issues/151) - Adds a standalone version of the Problem class. @@ -11,6 +11,7 @@ ## Bug Fixes +- [#123](https://github.com/pybop-team/PyBOP/issues/123) - Reinstates check for availability of parameter sets via PyBaMM upon retrieval by `pybop.ParameterSet.pybamm()`. - [#196](https://github.com/pybop-team/PyBOP/issues/196) - Fixes failing observer cost tests. - [#63](https://github.com/pybop-team/PyBOP/issues/63) - Removes NLOpt Optimiser from future releases. This is to support deployment to the Apple M-Series platform. - [#164](https://github.com/pybop-team/PyBOP/issues/164) - Fixes convergence issues with gradient-based optimisers, changes default `model.check_params()` to allow infeasible solutions during optimisation iterations. Adds a feasibility check on the optimal parameters.