Skip to content

Add another debug #1866

Add another debug

Add another debug #1866

Workflow file for this run

name: GitHub Branch CI
on:
push:
branches-ignore:
- main
workflow_dispatch:
inputs:
git-ref:
description: Git Hash (Optional)
required: false
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash -l {0}
env:
PYTHONWARNINGS: ignore::UserWarning
PYTHON_CORE_PKGS: wheel
PYPI_ONLY: z3-solver linear-tree
PYPY_EXCLUDE: scipy numdifftools seaborn statsmodels linear-tree
CACHE_VER: v251017.0
NEOS_EMAIL: [email protected]
SRC_REF: ${{ github.head_ref || github.ref }}
PYOMO_WORKFLOW: branch
jobs:
lint:
name: lint/style-and-typos
if: |
${{ ! ( contains(github.event.pull_request.title, '[WIP]') ||
github.event.pull_request.draft ) }}
runs-on: ubuntu-latest
steps:
- name: Checkout Pyomo source
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Black Formatting Check
run: |
# Note v24.4.1 fails due to a bug in the parser. Project-level
# configuration is inherited from pyproject.toml.
pip install 'black!=24.4.1'
black . --check --diff
- name: Spell Check
uses: crate-ci/typos@master
with:
config: ./.github/workflows/typos.toml
- name: URL Checker
if: env.PYOMO_WORKFLOW == 'branch'
uses: urlstechie/[email protected]
with:
# A comma-separated list of file types to cover in the URL checks
file_types: .md,.rst,.py
# Choose whether to include file with no URLs in the prints.
print_all: false
# More verbose summary at the end of a run
verbose: true
# How many times to retry a failed request (defaults to 1)
retry_count: 3
# Exclude:
# - Jenkins because it's behind a firewall
# - RTD because a magically-generated string triggers failures
exclude_urls: https://pyomo-jenkins.sandia.gov/,https://pyomo.readthedocs.io/en/%s/errors.html
# Exclude:
# - All gnu.org links because they consistently fail the checker
exclude_patterns: https://www.gnu.org
build:
name: ${{ matrix.TARGET }}/${{ matrix.python }}${{ matrix.other }}
runs-on: ${{ matrix.os }}
timeout-minutes: 120
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python: [3.14]
other: [""]
category: [""]
include:
- os: ubuntu-latest
python: 3.14
test_docs: 1
TARGET: linux
PYENV: pip
- os: macos-latest
python: 3.13
test_docs: 1
TARGET: osx
PYENV: pip
- os: windows-latest
python: 3.13
test_docs: 1
TARGET: win
PYENV: conda
PACKAGES: glpk pytest-qt filelock
# Note: verify that pymumps is available when changing conda python version
- os: ubuntu-latest
python: 3.12
other: /conda
TARGET: linux
PYENV: conda
PACKAGES: pytest-qt
- os: ubuntu-latest
python: 3.11
other: /mpi
mpi: 3
TARGET: linux
PYENV: conda
PACKAGES: openmpi mpi4py
- os: ubuntu-latest
python: 3.12
other: /cython
setup_options: --with-cython
TARGET: linux
PYENV: pip
PACKAGES: cython
- os: windows-latest
python: '3.10'
other: /pip
TARGET: win
PYENV: pip
steps:
- name: Checkout Pyomo source
uses: actions/checkout@v4
- name: Configure job parameters
run: |
JOB="${{matrix.TARGET}}/${{matrix.python}}${{matrix.other}}"
echo "GHA_JOBNAME=$JOB" | sed 's|/|_|g' >> $GITHUB_ENV
if test -z "${{matrix.other}}"; then
echo "GHA_JOBGROUP=${{matrix.TARGET}}" >> $GITHUB_ENV
else
echo "GHA_JOBGROUP=other" >> $GITHUB_ENV
fi
EXTRAS=tests
if test -z "${{matrix.slim}}"; then
EXTRAS="$EXTRAS,docs,optional"
fi
echo "EXTRAS=$EXTRAS" >> $GITHUB_ENV
PYTHON_PACKAGES="${{matrix.PACKAGES}}"
echo "PYTHON_PACKAGES=$PYTHON_PACKAGES" \
| tr '\n' ' ' | sed 's/ \+/ /g' >> $GITHUB_ENV
#- name: Pip package cache
# uses: actions/cache@v4
# if: matrix.PYENV == 'pip'
# id: pip-cache
# with:
# path: cache/pip
# key: pip-${{env.CACHE_VER}}.0-${{runner.os}}-${{matrix.python}}
#- name: OS package cache
# uses: actions/cache@v4
# if: matrix.TARGET != 'osx'
# id: os-cache
# with:
# path: cache/os
# key: pkg-${{env.CACHE_VER}}.0-${{runner.os}}
- name: TPL package download cache
uses: actions/cache@v4
if: ${{ ! matrix.slim }}
id: download-cache
with:
path: cache/download
key: download-${{env.CACHE_VER}}-${{runner.os}}
- name: Configure curl
run: |
CURLRC="$(cat <<EOF
retry = 0
max-time = 30
EOF
)"
echo "$CURLRC" > ${GITHUB_WORKSPACE}/.curlrc
echo "$CURLRC" > ${GITHUB_WORKSPACE}/_curlrc
echo "CURL_HOME=$GITHUB_WORKSPACE" >> $GITHUB_ENV
- name: Update OSX
if: matrix.TARGET == 'osx'
run: |
mkdir -p ${GITHUB_WORKSPACE}/cache/os
export HOMEBREW_CACHE=${GITHUB_WORKSPACE}/cache/os
# Be cautious running brew update: it can break
# setup-python on OSX
# brew update
#
# Notes:
# - install glpk
# - pyodbc needs: gcc pkg-config unixodbc freetds
for pkg in bash pkg-config unixodbc freetds glpk ginac; do
brew list $pkg || brew install $pkg
done
- name: Update Linux
if: matrix.TARGET == 'linux'
run: |
mkdir -p ${GITHUB_WORKSPACE}/cache/os
# Notes:
# - install glpk
# - ipopt needs: libopenblas-dev gfortran liblapack-dev
sudo apt-get -o Dir::Cache=${GITHUB_WORKSPACE}/cache/os \
install libopenblas-dev gfortran liblapack-dev glpk-utils \
libginac-dev
sudo chmod -R 777 ${GITHUB_WORKSPACE}/cache/os
- name: Update Windows
if: matrix.TARGET == 'win'
run: |
echo "SETUPTOOLS_USE_DISTUTILS=local" >> $GITHUB_ENV
choco install pkgconfiglite
- name: Set up Python ${{ matrix.python }}
if: matrix.PYENV == 'pip'
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Set up Miniconda Python ${{ matrix.python }}
if: matrix.PYENV == 'conda'
uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: false
python-version: ${{ matrix.python }}
# This is necessary for qt (UI) tests; the package utilized here does not
# have support for OSX.
- name: Set up UI testing infrastructure
if: ${{ matrix.TARGET != 'osx' }}
uses: pyvista/setup-headless-display-action@v3
with:
qt: true
pyvista: false
# GitHub actions is very fragile when it comes to setting up various
# Python interpreters, expecially the setup-miniconda interface.
# Per the setup-miniconda documentation, it is important to always
# invoke bash as a login shell ('shell: bash -l {0}') so that the
# conda environment is properly activated. However, running within
# a login shell appears to foul up the link to python from
# setup-python. Further, we have anecdotal evidence that
# subprocesses invoked through $(python -c ...) and `python -c ...`
# will not pick up the python activated by setup-python on OSX.
#
# Our solution is to define a PYTHON_EXE environment variable that
# can be explicitly called within subprocess calls to reach the
# correct interpreter. Note that we must explicitly run in a *non*
# login shell to set up the environment variable for the
# setup-python environments.
- name: Install Python Packages (pip)
if: matrix.PYENV == 'pip'
shell: bash # DO NOT REMOVE: see note above
run: |
python -c 'import sys;print(sys.executable)'
python -m pip install --cache-dir cache/pip --upgrade pip
python -m pip install --cache-dir cache/pip --upgrade setuptools
PYOMO_DEPENDENCIES=`python setup.py dependencies \
--extras "$EXTRAS" | tail -1`
PACKAGES="${PYTHON_CORE_PKGS} ${PYTHON_PACKAGES} ${PYOMO_DEPENDENCIES} "
if [[ ${{matrix.python}} == pypy* ]]; then
EXCLUDE="$PYPY_EXCLUDE $EXCLUDE"
fi
EXCLUDE=`echo "$EXCLUDE" | xargs`
if test -n "$EXCLUDE"; then
for WORD in $EXCLUDE; do
PACKAGES=${PACKAGES//$WORD / }
done
fi
# For windows, cannot use newer setuptools because of APPSI compilation issues
if test "${{matrix.TARGET}}" == 'win'; then
PACKAGES="$PACKAGES setuptools<74.0.0"
fi
python -m pip install --cache-dir cache/pip ${PACKAGES}
python -m pip install --cache-dir cache/pip pymysql || \
python -m pip install --cache-dir cache/pip pymysql
if test -z "${{matrix.slim}}"; then
python -m pip install --cache-dir cache/pip cplex docplex \
|| echo "WARNING: CPLEX Community Edition is not available"
python -m pip install --cache-dir cache/pip gurobipy \
|| echo "WARNING: Gurobi is not available"
python -m pip install --cache-dir cache/pip xpress \
|| echo "WARNING: Xpress Community Edition is not available"
python -m pip install --cache-dir cache/pip maingopy \
|| echo "WARNING: MAiNGO is not available"
if [[ ${{matrix.python}} == pypy* ]]; then
echo "skipping wntr for pypy"
else
python -m pip install wntr \
|| echo "WARNING: WNTR is not available"
fi
fi
python -c 'import sys; print("PYTHON_EXE=%s" \
% (sys.executable,))' >> $GITHUB_ENV
echo ""
echo "Final pip environment:"
python -m pip list | sed 's/^/ /'
- name: Install Python packages (conda)
if: matrix.PYENV == 'conda'
run: |
# Set up environment
conda config --set always_yes yes
conda config --set auto_update_conda false
conda config --set channel_priority strict
conda config --remove channels defaults
conda config --append channels nodefaults
conda config --append channels conda-forge
# Try to install mamba
CONDA_VER=$(conda --version | cut -d\ -f2)
if test 23.10 = "`echo -e "23.10\n$CONDA_VER" | sort -V | tail -1`"; then
# Note: removed '--update-deps' on 2025-02-28 to work around
# broken libffi(?)
conda install -q -y -n base conda-libmamba-solver \
|| MAMBA_FAILED=1
if test -z "$MAMBA_FAILED"; then
echo "*** Activating the mamba environment solver ***"
conda config --set solver libmamba
fi
fi
# Add the rest of the channels
conda config --append channels gurobi
conda config --append channels ibmdecisionoptimization
conda config --append channels fico-xpress
# Print environment info
echo "*** CONDA environment: ***"
conda info
conda config --show-sources
conda config --show channels
conda list --show-channel-urls
which python
python --version
pip debug
# We need setuptools so we can run Pyomo's setup.py
conda install setuptools
pip debug
# Note: some pypi packages are not available through conda
PYOMO_DEPENDENCIES=`python setup.py dependencies \
--extras "$EXTRAS" | tail -1`
PACKAGES="${PYTHON_CORE_PKGS} ${PYTHON_PACKAGES} ${PYOMO_DEPENDENCIES} "
if [[ ${{matrix.python}} == pypy* ]]; then
EXCLUDE="$PYPY_EXCLUDE $EXCLUDE"
fi
# HACK: Remove problem packages on conda+Linux
if test "${{matrix.TARGET}}" == linux; then
EXCLUDE="casadi numdifftools $EXCLUDE"
fi
EXCLUDE=`echo "$EXCLUDE" | xargs`
if test -n "$EXCLUDE"; then
for WORD in $EXCLUDE; do
PACKAGES=${PACKAGES//$WORD / }
done
fi
for PKG in $PACKAGES; do
if [[ " $PYPI_ONLY " == *" $PKG "* ]]; then
PYPI_DEPENDENCIES="$PYPI_DEPENDENCIES $PKG"
else
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES $PKG"
fi
done
echo ""
echo "*** Install Pyomo dependencies ***"
# For windows, cannot use newer setuptools because of APPSI compilation issues
if test "${{matrix.TARGET}}" == 'win'; then
CONDA_DEPENDENCIES="$CONDA_DEPENDENCIES setuptools<74.0.0"
fi
# Note: this will fail the build if any installation fails (or
# possibly if it outputs messages to stderr)
conda install --update-deps -q -y python="${{matrix.python}}" $CONDA_DEPENDENCIES
if test -z "${{matrix.slim}}"; then
# xpress.init() (xpress 9.5.1 from conda) hangs indefinitely
# on GHA/Windows under Python 3.10 and 3.11. Exclude that
# release on that platform.
if [[ ${{matrix.TARGET}} == win && ${{matrix.python}} =~ 3.1[01] ]]; then
# We would like to just use something like:
# - "!=9.5.1" (conda errors)
# - "<9.5.1|>9.5.1" (conda installs 9.1.2, which also hangs)
# - "<=9.5.0|>9.5.1" (conda seg faults)
XPRESS='xpress>=9.5.2'
else
XPRESS='xpress'
fi
TIMEOUT_MSG="TIMEOUT: killing conda install process"
PYVER=$(echo "py${{matrix.python}}" | sed 's/\.//g')
echo "Installing for $PYVER"
for PKG in 'cplex>=12.10' docplex gurobi "$XPRESS" cyipopt pymumps scip; do
echo "Does pip work? Let's find out..."
pip debug
echo ""
echo "*** Install $PKG ***"
echo ""
# conda can literally take an hour to determine that a
# package is not available. Perform a quick search to see
# if the package is available for this interpreter before
# attempting an install.
# NOTE: conda search will attempt approximate matches.
_PKGLIST=$(conda search -f "$PKG") || echo "Package $PKG not found"
echo "$_PKGLIST"
_BASE=$(echo "$PKG" | sed 's/[=<>].*//')
_BUILDS=$(echo "$_PKGLIST" | grep "^$_BASE " \
| sed -r 's/\s+/ /g' | cut -d\ -f3) || echo ""
if test -n "$_BUILDS"; then
_ISPY=$(echo "$_BUILDS" | grep "^py") \
|| echo "INFO: No python build detected."
_PYOK=$(echo "$_BUILDS" | grep -E "^($PYVER|pyh)") \
|| echo "INFO: No python build matching $PYVER detected."
if test -z "$_ISPY" -o -n "$_PYOK"; then
echo ""
echo "... INSTALLING $PKG"
# Because conda can occasionally hang
# indefinitely (lately while installing SCIP),
# we will run "conda install" in a subshell and
# kill it after 5-minutes.
(conda install -q -y $PKG |& tee conda.log) &
conda_subshell_pid=$!
sleep 1
conda_pid=$(ps | grep conda | sed 's/^ *//' | sed 's/ .*//')
# Only timeout the conda process if it's not to
# the installation phase yet. Signalling conda
# after it has started the installation process
# can irrecoverably corrupt the environment.
(sleep 300 \
&& if test `grep 'Package Plan' conda.log | wc -l` -eq 0; \
then echo "$TIMEOUT_MSG $conda_pid (TERM)" \
&& kill -TERM $conda_pid 2>/dev/null ; fi) &
timeout_pid=$!
wait $conda_subshell_pid || _BUILDS=""
kill $timeout_pid 2>/dev/null \
|| echo "TIMEOUT: time limit expired"
fi
fi
echo ""
if test -z "$_BUILDS"; then
echo "WARNING: $PKG is not available"
fi
done
fi
# Re-try Pyomo (optional) dependencies with pip
echo ""
echo "Installing packages only available on PyPI"
if test -n "$PYPI_DEPENDENCIES"; then
python -m pip install --cache-dir cache/pip $PYPI_DEPENDENCIES
fi
# remember this python interpreter
python -c 'import sys; print("PYTHON_EXE=%s" \
% (sys.executable,))' >> $GITHUB_ENV
#
# conda activate puts itself first in the PATH, which overrides
# any paths we add through GITHUB_PATH. We will update .profile
# to move the local runner paths back to the front (before conda).
for profile in $HOME/.profile $HOME/.bash_profile; do
if test ! -e $profile; then
continue
fi
echo '' >> $profile
echo 'export PATH=`echo "$PATH" \
| tr ":" "\\n" | grep runner | tr "\n" ":"`:`echo "$PATH" \
| tr ":" "\\n" | grep -v runner | tr "\n" ":"`' >> $profile
done
echo ""
echo "Final conda environment:"
conda list | sed 's/^/ /'