Skip to content

Changed 'latest' job in test and docs workflows to use Python 3.12 #822

Changed 'latest' job in test and docs workflows to use Python 3.12

Changed 'latest' job in test and docs workflows to use Python 3.12 #822

# Build docs
name: Dymos Docs
on:
# Trigger on push, pull request
push:
branches: [ master ]
pull_request:
branches: [ master, develop ]
# Trigger via workflow_dispatch event
workflow_dispatch:
jobs:
test_ubuntu:
runs-on: ubuntu-latest
timeout-minutes: 90
strategy:
fail-fast: false
matrix:
include:
# baseline versions except with pyoptsparse but no SNOPT
# build docs to verify those that use pyoptsparse do not use SNOPT
- NAME: baseline_no_snopt
PY: '3.11'
NUMPY: '1.26'
SCIPY: '1.13'
PETSc: '3.19'
PYOPTSPARSE: 'v2.11.0'
OPENMDAO: 'latest'
OPTIONAL: '[docs]'
JAX: '0.4.28'
PUBLISH_DOCS: 1
# make sure the latest versions of things don't break the docs
# sticking with Python 3.12 for now, 3.13 requires NumPy 2.1 which does not work yet with PETSc/pyoptsparse
- NAME: latest
PY: '3.12'
NUMPY: 1
SCIPY: 1
PETSc: 3
PYOPTSPARSE: 'latest'
SNOPT: 7.7
OPENMDAO: 'dev'
OPTIONAL: '[docs]'
JAX: 'latest'
PUBLISH_DOCS: 0
steps:
- name: Display run details
run: |
echo "============================================================="
echo "Run #${GITHUB_RUN_NUMBER}"
echo "Run ID: ${GITHUB_RUN_ID}"
echo "Testing: ${GITHUB_REPOSITORY}"
echo "Triggered by: ${GITHUB_EVENT_NAME}"
echo "Initiated by: ${GITHUB_ACTOR}"
echo "============================================================="
- name: Create SSH key
shell: bash
env:
SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
SSH_KNOWN_HOSTS: ${{secrets.SSH_KNOWN_HOSTS}}
run: |
mkdir -p ~/.ssh/
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
sudo chmod 600 ~/.ssh/id_rsa
echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- name: Checkout code
uses: actions/checkout@v4
- name: Fetch tags
run: |
git fetch --prune --unshallow --tags
- name: Setup conda
uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.PY }}
channels: conda-forge
- name: Install Numpy/Scipy
shell: bash -l {0}
run: |
echo "Make sure we are not using anaconda packages"
conda config --remove channels defaults
echo "============================================================="
echo "Install Numpy/Scipy"
echo "============================================================="
conda install numpy=${{ matrix.NUMPY }} scipy=${{ matrix.SCIPY }} -q -y
- name: Install jax
if: matrix.JAX
shell: bash -l {0}
run: |
echo "============================================================="
echo "Install jax"
echo "============================================================="
if [[ "${{ matrix.JAX }}" == "latest" ]]; then
python -m pip install jaxlib jax
else
python -m pip install jaxlib==${{ matrix.JAX }} jax==${{ matrix.JAX }}
fi
- name: Install PETSc
if: matrix.PETSc
shell: bash -l {0}
run: |
echo "============================================================="
echo "Install PETSc"
echo "============================================================="
if [[ "${{ matrix.OPENMPI }}" && "${{ matrix.MPI4PY }}" ]]; then
conda install openmpi=${{ matrix.OPENMPI }} mpi4py=${{ matrix.MPI4PY }} petsc4py=${{ matrix.PETSc }} -q -y
elif [[ "${{ matrix.MPI4PY }}" ]]; then
conda install mpi4py=${{ matrix.MPI4PY }} petsc4py=${{ matrix.PETSc }} -q -y
else
conda install mpi4py petsc4py=${{ matrix.PETSc }} -q -y
fi
echo "-----------------------"
echo "Quick test of mpi4py:"
mpirun -n 2 python -c "from mpi4py import MPI; print(f'Rank: {MPI.COMM_WORLD.rank}')"
echo "-----------------------"
echo "Quick test of petsc4py:"
mpirun -n 2 python -c "import numpy; from mpi4py import MPI; comm = MPI.COMM_WORLD; import petsc4py; petsc4py.init(); x = petsc4py.PETSc.Vec().createWithArray(numpy.ones(5)*comm.rank, comm=comm); print(x.getArray())"
echo "-----------------------"
echo "OMPI_MCA_rmaps_base_oversubscribe=1" >> $GITHUB_ENV
- name: Install pyOptSparse
if: matrix.PYOPTSPARSE
shell: bash -l {0}
run: |
echo "============================================================="
echo "Install pyoptsparse"
echo "============================================================="
if [[ "${{ matrix.PYOPTSPARSE }}" == "conda-forge" ]]; then
if [[ "${{ matrix.SNOPT }}" ]]; then
echo "SNOPT ${{ matrix.SNOPT }} was requested but is not available on conda-forge"
fi
conda install -c conda-forge pyoptsparse
else
pip install git+https://github.com/OpenMDAO/build_pyoptsparse
if [[ "${{ matrix.PYOPTSPARSE }}" == "latest" ]]; then
LATEST_URL=`curl -fsSLI -o /dev/null -w %{url_effective} https://github.com/mdolab/pyoptsparse/releases/latest`
LATEST_VER=`echo $LATEST_URL | awk '{split($0,a,"/tag/"); print a[2]}'`
BRANCH="-b $LATEST_VER"
else
BRANCH="-b ${{ matrix.PYOPTSPARSE }}"
fi
if [[ "${{ matrix.PAROPT }}" ]]; then
PAROPT="-a"
fi
if [[ "${{ matrix.SNOPT }}" == "7.7" && "${{ secrets.SNOPT_LOCATION_77 }}" ]]; then
echo " > Secure copying SNOPT 7.7 over SSH"
mkdir SNOPT
scp -qr ${{ secrets.SNOPT_LOCATION_77 }} SNOPT
SNOPT="-s SNOPT/src"
elif [[ "${{ matrix.SNOPT }}" == "7.2" && "${{ secrets.SNOPT_LOCATION_72 }}" ]]; then
echo " > Secure copying SNOPT 7.2 over SSH"
mkdir SNOPT
scp -qr ${{ secrets.SNOPT_LOCATION_72 }} SNOPT
SNOPT="-s SNOPT/source"
elif [[ "${{ matrix.SNOPT }}" ]]; then
echo "SNOPT version ${{ matrix.SNOPT }} was requested but source is not available"
fi
build_pyoptsparse $BRANCH $PAROPT $SNOPT
fi
- name: Install OpenMDAO
if: matrix.OPENMDAO
shell: bash -l {0}
run: |
echo "============================================================="
echo "Install OpenMDAO"
echo "============================================================="
if [[ "${{ matrix.OPENMDAO }}" == "dev" ]]; then
pip install git+https://github.com/OpenMDAO/OpenMDAO
elif [[ "${{ matrix.OPENMDAO }}" == "latest" ]]; then
pip install openmdao
else
pip install openmdao==${{ matrix.OPENMDAO }}
fi
- name: Install bokeh
shell: bash -l {0}
run: |
echo "============================================================="
echo "Install additional packages for testing/coverage"
echo "============================================================="
conda install bokeh
- name: Install Dymos
shell: bash -l {0}
run: |
echo "============================================================="
echo "Install Dymos"
echo "============================================================="
pip install .${{ matrix.OPTIONAL }}
- name: Display environment info
id: env_info
shell: bash -l {0}
run: |
conda info
conda list
echo "============================================================="
echo "Check installed versions of Python, Numpy and Scipy"
echo "============================================================="
python -c "import sys; assert str(sys.version).startswith(str(${{ matrix.PY }})), \
f'Python version {sys.version} is not the requested version (${{ matrix.PY }})'"
python -c "import numpy; assert str(numpy.__version__).startswith(str(${{ matrix.NUMPY }})), \
f'Numpy version {numpy.__version__} is not the requested version (${{ matrix.NUMPY }})'"
python -c "import scipy; assert str(scipy.__version__).startswith(str(${{ matrix.SCIPY }})), \
f'Scipy version {scipy.__version__} is not the requested version (${{ matrix.SCIPY }})'"
- name: Display dependency tree
if: failure() && steps.env_info.outcome == 'failure'
run: |
pip install pipdeptree
pipdeptree
- name: Build docs
id: build_docs
shell: bash -l {0}
run: |
echo "============================================================="
echo "Building Docs"
echo "============================================================="
cd docs
export PYDEVD_DISABLE_FILE_VALIDATION=1
jupyter-book build -W --keep-going dymos_book
- name: Display doc build reports
continue-on-error: True
if: failure() && steps.build_docs.outcome == 'failure'
run: |
echo $PWD
cd docs
find dymos_book/_build/html/reports/ -type f -name '*.log' \
-exec echo "#################################################################" \; \
-exec echo {} \; \
-exec echo "#################################################################" \; \
-exec cat {} \;
- name: Publish docs to github.io
if: |
github.event_name == 'push' && github.ref == 'refs/heads/master' &&
matrix.PUBLISH_DOCS == '1'
shell: bash -l {0}
run: |
echo "============================================================="
echo "Publishing Docs to github.io"
echo "============================================================="
pip install ghp-import
cd $HOME/work/dymos/dymos
ghp-import -n -p -f docs/dymos_book/_build/html
- name: Publish docs to openmdao.org
if: |
github.event_name == 'push' && github.ref == 'refs/heads/master' &&
matrix.PUBLISH_DOCS == '1'
env:
DOCS_LOCATION: ${{ secrets.DOCS_LOCATION }}
shell: bash -l {0}
run: |
if [[ "${#DOCS_LOCATION}" ]]; then
echo "============================================================="
echo "Install version of openssl compatible with hosting service"
echo "============================================================="
conda install -c conda-forge 'openssl=3.0'
echo "============================================================="
echo "Publishing Docs to openmdao.org"
echo "============================================================="
echo "Publish docs"
cd $HOME/work/dymos/dymos
python -m openmdao.docs.upload_doc_version docs/dymos_book/_build/html/ ${{ secrets.DOCS_LOCATION }}
else
echo "Docs destination not available."
fi