forked from pybop-team/PyBOP
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pybop-team#123 add custom script to dynamically generate matrix
- Loading branch information
1 parent
695170f
commit bff90d6
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 . |