From 8b38663508c007566a59ad42e3ea7c59d85ec718 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Tue, 8 Oct 2024 13:11:28 -0600 Subject: [PATCH 01/18] Add Python 3.13 --- .github/workflows/test_branches.yml | 4 ++-- .github/workflows/test_pr_and_main.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml index c1029ff3d7b..7718aaffa55 100644 --- a/.github/workflows/test_branches.yml +++ b/.github/workflows/test_branches.yml @@ -83,7 +83,7 @@ jobs: include: - os: ubuntu-latest - python: '3.12' + python: '3.13' TARGET: linux PYENV: pip @@ -116,7 +116,7 @@ jobs: PACKAGES: openmpi mpi4py - os: ubuntu-latest - python: '3.10' + python: '3.12' other: /cython setup_options: --with-cython skip_doctest: 1 diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml index 33aacaa9e35..87432ed95b6 100644 --- a/.github/workflows/test_pr_and_main.yml +++ b/.github/workflows/test_pr_and_main.yml @@ -68,7 +68,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] - python: [ 3.8, 3.9, '3.10', '3.11', '3.12' ] + python: [ 3.8, 3.9, '3.10', '3.11', '3.12', '3.13' ] other: [""] category: [""] @@ -110,7 +110,7 @@ jobs: PACKAGES: openmpi mpi4py - os: ubuntu-latest - python: '3.10' + python: '3.12' other: /cython setup_options: --with-cython skip_doctest: 1 From d787a787db3179db06faa27b3ade8b62bd559271 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Tue, 8 Oct 2024 14:21:38 -0600 Subject: [PATCH 02/18] Whoops - accidental weirdness --- .github/workflows/test_branches.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml index 7718aaffa55..f2b04bdac17 100644 --- a/.github/workflows/test_branches.yml +++ b/.github/workflows/test_branches.yml @@ -71,7 +71,7 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] - python: ['3.12'] + python: ['3.13'] other: [""] category: [""] From de77aaeb17b048c17f460d3e46df94fd5d30e229 Mon Sep 17 00:00:00 2001 From: Miranda Mundt <55767766+mrmundt@users.noreply.github.com> Date: Mon, 4 Nov 2024 11:06:11 -0700 Subject: [PATCH 03/18] Directly import ApplicationError --- pyomo/contrib/alternative_solutions/solnpool.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pyomo/contrib/alternative_solutions/solnpool.py b/pyomo/contrib/alternative_solutions/solnpool.py index b8cef530868..a6f4f6e8cd2 100644 --- a/pyomo/contrib/alternative_solutions/solnpool.py +++ b/pyomo/contrib/alternative_solutions/solnpool.py @@ -12,6 +12,7 @@ import logging import pyomo.environ as pe +from pyomo.common.errors import ApplicationError from pyomo.contrib import appsi import pyomo.contrib.alternative_solutions.aos_utils as aos_utils from pyomo.contrib.alternative_solutions import Solution @@ -65,7 +66,7 @@ def gurobi_generate_solutions( # opt = appsi.solvers.Gurobi() if not opt.available(): - raise pe.common.errors.ApplicationError("Solver (gurobi) not available") + raise ApplicationError("Solver (gurobi) not available") opt.config.stream_solver = tee opt.config.load_solution = False @@ -83,7 +84,7 @@ def gurobi_generate_solutions( results = opt.solve(model) condition = results.termination_condition if not (condition == appsi.base.TerminationCondition.optimal): - raise pe.common.errors.ApplicationError( + raise ApplicationError( "Model cannot be solved, " "TerminationCondition = {}" ).format(condition.value) # From fe308dc6bc95c649e869dc5ea6f3ddc3b6106dcd Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Mon, 4 Nov 2024 11:09:42 -0700 Subject: [PATCH 04/18] Update other files to reflect changes to 3.13 --- .coin-or/projDesc.xml | 2 +- .github/workflows/release_wheel_creation.yml | 4 ++-- README.md | 2 +- doc/OnlineDocs/getting_started/installation.rst | 2 +- setup.py | 1 + 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.coin-or/projDesc.xml b/.coin-or/projDesc.xml index 8a5a9e0a7df..b656b18fdeb 100644 --- a/.coin-or/projDesc.xml +++ b/.coin-or/projDesc.xml @@ -287,7 +287,7 @@ Carl D. Laird, Chair, Pyomo Management Committee, claird at andrew dot cmu dot e Any - Python 3.8, 3.9, 3.10, 3.11, 3.12 + Python 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 diff --git a/.github/workflows/release_wheel_creation.yml b/.github/workflows/release_wheel_creation.yml index d439dafaf0a..31cca7f60b2 100644 --- a/.github/workflows/release_wheel_creation.yml +++ b/.github/workflows/release_wheel_creation.yml @@ -24,7 +24,7 @@ jobs: matrix: os: [ubuntu-22.04, windows-latest, macos-latest] arch: [all] - wheel-version: ['cp38*', 'cp39*', 'cp310*', 'cp311*', 'cp312*'] + wheel-version: ['cp38*', 'cp39*', 'cp310*', 'cp311*', 'cp312*', 'cp313*'] include: - wheel-version: 'cp38*' @@ -77,7 +77,7 @@ jobs: matrix: os: [ubuntu-22.04] arch: [all] - wheel-version: ['cp38*', 'cp39*', 'cp310*', 'cp311*', 'cp312*'] + wheel-version: ['cp38*', 'cp39*', 'cp310*', 'cp311*', 'cp312*', 'cp313*'] include: - wheel-version: 'cp38*' diff --git a/README.md b/README.md index 83934153361..29b900261e5 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ Pyomo is available under the BSD License - see the Pyomo is currently tested with the following Python implementations: -* CPython: 3.8, 3.9, 3.10, 3.11, 3.12 +* CPython: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 * PyPy: 3.9 _Testing and support policy_: diff --git a/doc/OnlineDocs/getting_started/installation.rst b/doc/OnlineDocs/getting_started/installation.rst index 83cd08e7a4a..e36d83d4f8a 100644 --- a/doc/OnlineDocs/getting_started/installation.rst +++ b/doc/OnlineDocs/getting_started/installation.rst @@ -3,7 +3,7 @@ Installation Pyomo currently supports the following versions of Python: -* CPython: 3.8, 3.9, 3.10, 3.11, 3.12 +* CPython: 3.8, 3.9, 3.10, 3.11, 3.12, 3.13 * PyPy: 3 At the time of the first Pyomo release after the end-of-life of a minor Python diff --git a/setup.py b/setup.py index 63c6891bda2..21613edfd1c 100644 --- a/setup.py +++ b/setup.py @@ -239,6 +239,7 @@ def __ne__(self, other): 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', + 'Programming Language :: Python :: 3.13', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Scientific/Engineering :: Mathematics', From 5fec04d5571c6872030bcb4dbd91c8fec407c68f Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Mon, 4 Nov 2024 11:17:18 -0700 Subject: [PATCH 05/18] Explicit listing of cp313 in release_wheel_creation --- .github/workflows/release_wheel_creation.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/release_wheel_creation.yml b/.github/workflows/release_wheel_creation.yml index 31cca7f60b2..ecaf6afbd59 100644 --- a/.github/workflows/release_wheel_creation.yml +++ b/.github/workflows/release_wheel_creation.yml @@ -42,12 +42,17 @@ jobs: - wheel-version: 'cp312*' TARGET: 'py312' GLOBAL_OPTIONS: "--without-cython --with-distributable-extensions" + - wheel-version: 'cp313*' + TARGET: 'py313' + GLOBAL_OPTIONS: "--without-cython --with-distributable-extensions" exclude: - wheel-version: 'cp311*' os: windows-latest - wheel-version: 'cp312*' os: windows-latest + - wheel-version: 'cp313*' + os: windows-latest steps: - uses: actions/checkout@v4 @@ -95,6 +100,9 @@ jobs: - wheel-version: 'cp312*' TARGET: 'py312' GLOBAL_OPTIONS: "--without-cython --with-distributable-extensions" + - wheel-version: 'cp313*' + TARGET: 'py313' + GLOBAL_OPTIONS: "--without-cython --with-distributable-extensions" steps: - uses: actions/checkout@v4 - name: Set up QEMU From 3ccc425304107a256ec850b8e4a1d06a3c397b30 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Mon, 4 Nov 2024 11:22:44 -0700 Subject: [PATCH 06/18] Bug was already fixed in another PR --- pyomo/contrib/alternative_solutions/solnpool.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyomo/contrib/alternative_solutions/solnpool.py b/pyomo/contrib/alternative_solutions/solnpool.py index a6f4f6e8cd2..2f82440c169 100644 --- a/pyomo/contrib/alternative_solutions/solnpool.py +++ b/pyomo/contrib/alternative_solutions/solnpool.py @@ -11,14 +11,16 @@ import logging -import pyomo.environ as pe +logger = logging.getLogger(__name__) + +from pyomo.common.dependencies import attempt_import from pyomo.common.errors import ApplicationError + +import pyomo.environ as pe from pyomo.contrib import appsi import pyomo.contrib.alternative_solutions.aos_utils as aos_utils from pyomo.contrib.alternative_solutions import Solution -logger = logging.getLogger(__name__) - def gurobi_generate_solutions( model, From 025a040658073f72bef91b5a9a23749f7fc8060d Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Mon, 4 Nov 2024 14:10:33 -0700 Subject: [PATCH 07/18] Remove pint from python 3.13 --- .github/workflows/test_branches.yml | 4 ++++ .github/workflows/test_pr_and_main.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml index 631f94e7e9a..011c36ae243 100644 --- a/.github/workflows/test_branches.yml +++ b/.github/workflows/test_branches.yml @@ -362,6 +362,10 @@ jobs: # 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" + # As of Nov 4, 2024, pint is not compatible with python 3.13 + if test "${{matrix.python}}" == "3.13"; then + CONDA_DEPENDENCIES=${CONDA_DEPENDENCIES//"pint"} + fi fi # Note: this will fail the build if any installation fails (or # possibly if it outputs messages to stderr) diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml index 50469915410..aaac28cbd76 100644 --- a/.github/workflows/test_pr_and_main.yml +++ b/.github/workflows/test_pr_and_main.yml @@ -385,6 +385,10 @@ jobs: # 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" + # As of Nov 4, 2024, pint is not compatible with python 3.13 + if test "${{matrix.python}}" == "3.13"; then + CONDA_DEPENDENCIES=${CONDA_DEPENDENCIES//"pint"} + fi fi # Note: this will fail the build if any installation fails (or # possibly if it outputs messages to stderr) From 699b2eab01b35d64f906fd36298ec5858aa69e09 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Tue, 5 Nov 2024 10:01:58 -0700 Subject: [PATCH 08/18] qtconsole is also incompatible --- .github/workflows/test_branches.yml | 8 ++++---- .github/workflows/test_pr_and_main.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml index 011c36ae243..463d7ceebca 100644 --- a/.github/workflows/test_branches.yml +++ b/.github/workflows/test_branches.yml @@ -344,6 +344,10 @@ jobs: if test "${{matrix.TARGET}}" == linux; then EXCLUDE="casadi numdifftools $EXCLUDE" fi + if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then + # As of Nov 4, 2024, pint/qtconsole are not compatible with python 3.13 on win + EXCLUDE="pint qtconsole $EXCLUDE" + fi EXCLUDE=`echo "$EXCLUDE" | xargs` if test -n "$EXCLUDE"; then for WORD in $EXCLUDE; do @@ -362,10 +366,6 @@ jobs: # 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" - # As of Nov 4, 2024, pint is not compatible with python 3.13 - if test "${{matrix.python}}" == "3.13"; then - CONDA_DEPENDENCIES=${CONDA_DEPENDENCIES//"pint"} - fi fi # Note: this will fail the build if any installation fails (or # possibly if it outputs messages to stderr) diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml index aaac28cbd76..314eb9b6ac8 100644 --- a/.github/workflows/test_pr_and_main.yml +++ b/.github/workflows/test_pr_and_main.yml @@ -367,6 +367,10 @@ jobs: if test "${{matrix.TARGET}}" == linux; then EXCLUDE="casadi numdifftools $EXCLUDE" fi + if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then + # As of Nov 4, 2024, pint/qtconsole are not compatible with python 3.13 on win + EXCLUDE="pint qtconsole $EXCLUDE" + fi EXCLUDE=`echo "$EXCLUDE" | xargs` if test -n "$EXCLUDE"; then for WORD in $EXCLUDE; do @@ -385,10 +389,6 @@ jobs: # 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" - # As of Nov 4, 2024, pint is not compatible with python 3.13 - if test "${{matrix.python}}" == "3.13"; then - CONDA_DEPENDENCIES=${CONDA_DEPENDENCIES//"pint"} - fi fi # Note: this will fail the build if any installation fails (or # possibly if it outputs messages to stderr) From b5f707eb0bca270b11116b4dafb90e39d5e1a456 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Tue, 5 Nov 2024 13:51:12 -0700 Subject: [PATCH 09/18] Exclude pytest-qt for win/3.13 --- .github/workflows/test_branches.yml | 2 +- .github/workflows/test_pr_and_main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml index 463d7ceebca..10c50e2cece 100644 --- a/.github/workflows/test_branches.yml +++ b/.github/workflows/test_branches.yml @@ -346,7 +346,7 @@ jobs: fi if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then # As of Nov 4, 2024, pint/qtconsole are not compatible with python 3.13 on win - EXCLUDE="pint qtconsole $EXCLUDE" + EXCLUDE="pint qtconsole pytest-qt $EXCLUDE" fi EXCLUDE=`echo "$EXCLUDE" | xargs` if test -n "$EXCLUDE"; then diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml index 314eb9b6ac8..def58370d81 100644 --- a/.github/workflows/test_pr_and_main.yml +++ b/.github/workflows/test_pr_and_main.yml @@ -369,7 +369,7 @@ jobs: fi if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then # As of Nov 4, 2024, pint/qtconsole are not compatible with python 3.13 on win - EXCLUDE="pint qtconsole $EXCLUDE" + EXCLUDE="pint qtconsole pytest-qt $EXCLUDE" fi EXCLUDE=`echo "$EXCLUDE" | xargs` if test -n "$EXCLUDE"; then From ab3ba6028e22b817aa26f8e1d4d3961c589ccb50 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Tue, 5 Nov 2024 15:30:16 -0700 Subject: [PATCH 10/18] Try removing qt6-main --- .github/workflows/test_branches.yml | 6 +++++- .github/workflows/test_pr_and_main.yml | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml index 10c50e2cece..3b50f66f61c 100644 --- a/.github/workflows/test_branches.yml +++ b/.github/workflows/test_branches.yml @@ -346,7 +346,7 @@ jobs: fi if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then # As of Nov 4, 2024, pint/qtconsole are not compatible with python 3.13 on win - EXCLUDE="pint qtconsole pytest-qt $EXCLUDE" + EXCLUDE="pint qtconsole $EXCLUDE" fi EXCLUDE=`echo "$EXCLUDE" | xargs` if test -n "$EXCLUDE"; then @@ -406,6 +406,10 @@ jobs: if test -n "$PYPI_DEPENDENCIES"; then python -m pip install --cache-dir cache/pip $PYPI_DEPENDENCIES fi + # Remove qt from win/3.13 so we don't trigger test_qt.py + if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then + conda remove qt6-main || echo "qt6 is not in the environment" + fi # remember this python interpreter python -c 'import sys; print("PYTHON_EXE=%s" \ % (sys.executable,))' >> $GITHUB_ENV diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml index def58370d81..9094c7120bf 100644 --- a/.github/workflows/test_pr_and_main.yml +++ b/.github/workflows/test_pr_and_main.yml @@ -429,6 +429,10 @@ jobs: if test -n "$PYPI_DEPENDENCIES"; then python -m pip install --cache-dir cache/pip $PYPI_DEPENDENCIES fi + # Remove qt from win/3.13 so we don't trigger test_qt.py + if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then + conda remove qt6-main || echo "qt6 is not in the environment" + fi # remember this python interpreter python -c 'import sys; print("PYTHON_EXE=%s" \ % (sys.executable,))' >> $GITHUB_ENV From b4b175181510f54b7acd2643d2f461f46624b651 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Wed, 6 Nov 2024 09:02:06 -0700 Subject: [PATCH 11/18] Missed pytest-qt --- .github/workflows/test_pr_and_main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml index 9094c7120bf..d378a5e7c8a 100644 --- a/.github/workflows/test_pr_and_main.yml +++ b/.github/workflows/test_pr_and_main.yml @@ -369,7 +369,7 @@ jobs: fi if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then # As of Nov 4, 2024, pint/qtconsole are not compatible with python 3.13 on win - EXCLUDE="pint qtconsole pytest-qt $EXCLUDE" + EXCLUDE="pint qtconsole $EXCLUDE" fi EXCLUDE=`echo "$EXCLUDE" | xargs` if test -n "$EXCLUDE"; then From 0fc444f79bb0e1c2d17b70bbb147c95045361f75 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Wed, 6 Nov 2024 11:23:15 -0700 Subject: [PATCH 12/18] Try removing other qt components --- .github/workflows/test_branches.yml | 2 +- .github/workflows/test_pr_and_main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml index 3b50f66f61c..53b48d0e79e 100644 --- a/.github/workflows/test_branches.yml +++ b/.github/workflows/test_branches.yml @@ -408,7 +408,7 @@ jobs: fi # Remove qt from win/3.13 so we don't trigger test_qt.py if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then - conda remove qt6-main || echo "qt6 is not in the environment" + conda remove qt6-main qt-main pyqt pyqt5-sip || echo "qt components are not in the environment" fi # remember this python interpreter python -c 'import sys; print("PYTHON_EXE=%s" \ diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml index d378a5e7c8a..2f5343fcd01 100644 --- a/.github/workflows/test_pr_and_main.yml +++ b/.github/workflows/test_pr_and_main.yml @@ -431,7 +431,7 @@ jobs: fi # Remove qt from win/3.13 so we don't trigger test_qt.py if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then - conda remove qt6-main || echo "qt6 is not in the environment" + conda remove qt6-main qt-main pyqt pyqt5-sip || echo "qt components are not in the environment" fi # remember this python interpreter python -c 'import sys; print("PYTHON_EXE=%s" \ From 81f5c6054ca121fe6a2b2c8adac4ee7113b16000 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Wed, 6 Nov 2024 13:05:02 -0700 Subject: [PATCH 13/18] Try reworking logic for qt --- pyomo/contrib/viewer/qt.py | 24 +++++++++++++----------- pyomo/contrib/viewer/tests/test_qt.py | 11 ++--------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/pyomo/contrib/viewer/qt.py b/pyomo/contrib/viewer/qt.py index f2744fa2d56..cecdb728ca7 100644 --- a/pyomo/contrib/viewer/qt.py +++ b/pyomo/contrib/viewer/qt.py @@ -38,17 +38,19 @@ import_errors = [] # Set this to the Qt wrapper module is available available = False - -for module_str in supported: - try: - qt_package = importlib.import_module(module_str) - QtWidgets = importlib.import_module(f"{module_str}.QtWidgets") - QtCore = importlib.import_module(f"{module_str}.QtCore") - QtGui = importlib.import_module(f"{module_str}.QtGui") - available = module_str - break - except Exception as e: - import_errors.append(f"{e}") +from pyomo.core.base.units_container import pint_available + +if pint_available: + for module_str in supported: + try: + qt_package = importlib.import_module(module_str) + QtWidgets = importlib.import_module(f"{module_str}.QtWidgets") + QtCore = importlib.import_module(f"{module_str}.QtCore") + QtGui = importlib.import_module(f"{module_str}.QtGui") + available = module_str + break + except Exception as e: + import_errors.append(f"{e}") if not available: # If Qt is not available, we still want to be able to test as much diff --git a/pyomo/contrib/viewer/tests/test_qt.py b/pyomo/contrib/viewer/tests/test_qt.py index b7250729cd9..73b7fc1893e 100644 --- a/pyomo/contrib/viewer/tests/test_qt.py +++ b/pyomo/contrib/viewer/tests/test_qt.py @@ -57,6 +57,8 @@ def qtbot(): """Overwrite qtbot - remove test failure""" return + pytestmark = unittest.pytest.mark.skip("Qt components are not available.") + def get_model(): # Borrowed this test model from the trust region tests @@ -100,7 +102,6 @@ def blackbox(a, b): return m -@unittest.skipIf(not available, "Qt packages are not available.") def test_get_mainwindow(qtbot): m = get_model() mw = get_mainwindow(model=m, testing=True) @@ -111,13 +112,11 @@ def test_get_mainwindow(qtbot): assert isinstance(mw.parameters, ModelBrowser) -@unittest.skipIf(not available, "Qt packages are not available.") def test_close_mainwindow(qtbot): mw = get_mainwindow(model=None, testing=True) mw.exit_action() -@unittest.skipIf(not available, "Qt packages are not available.") def test_show_model_select_no_models(qtbot): mw = get_mainwindow(model=None, testing=True) ms = mw.show_model_select() @@ -125,7 +124,6 @@ def test_show_model_select_no_models(qtbot): ms.select_model() -@unittest.skipIf(not available, "Qt packages are not available.") def test_model_information(qtbot): m = get_model() mw = get_mainwindow(model=m, testing=True) @@ -146,7 +144,6 @@ def test_model_information(qtbot): assert isinstance(mw.parameters, ModelBrowser) -@unittest.skipIf(not available, "Qt packages are not available.") def test_tree_expand_collapse(qtbot): m = get_model() mw = get_mainwindow(model=m, testing=True) @@ -154,7 +151,6 @@ def test_tree_expand_collapse(qtbot): mw.variables.treeView.collapseAll() -@unittest.skipIf(not available, "Qt packages are not available.") def test_residual_table(qtbot): m = get_model() mw = get_mainwindow(model=m, testing=True) @@ -181,7 +177,6 @@ def test_residual_table(qtbot): assert dm.data(dm.index(0, 0)) == "c5" -@unittest.skipIf(not available, "Qt packages are not available.") def test_var_tree(qtbot): m = get_model() mw = get_mainwindow(model=m, testing=True) @@ -215,7 +210,6 @@ def test_var_tree(qtbot): mw.variables.treeView.closePersistentEditor(z1_val_index) -@unittest.skipIf(not available, "Qt packages are not available.") def test_bad_view(qtbot): m = get_model() mw = get_mainwindow(model=m, testing=True) @@ -229,7 +223,6 @@ def test_bad_view(qtbot): assert err == "ValueError" -@unittest.skipIf(not available, "Qt packages are not available.") def test_qtconsole_app(qtbot): app = pv.QtApp() # empty list to prevent picking up args from pytest From 3c4bc515591bada741781f7950f48d88d26e1c87 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Wed, 6 Nov 2024 13:05:33 -0700 Subject: [PATCH 14/18] Turn off uninstall --- .github/workflows/test_branches.yml | 4 ---- .github/workflows/test_pr_and_main.yml | 4 ---- 2 files changed, 8 deletions(-) diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml index 53b48d0e79e..463d7ceebca 100644 --- a/.github/workflows/test_branches.yml +++ b/.github/workflows/test_branches.yml @@ -406,10 +406,6 @@ jobs: if test -n "$PYPI_DEPENDENCIES"; then python -m pip install --cache-dir cache/pip $PYPI_DEPENDENCIES fi - # Remove qt from win/3.13 so we don't trigger test_qt.py - if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then - conda remove qt6-main qt-main pyqt pyqt5-sip || echo "qt components are not in the environment" - fi # remember this python interpreter python -c 'import sys; print("PYTHON_EXE=%s" \ % (sys.executable,))' >> $GITHUB_ENV diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml index 2f5343fcd01..314eb9b6ac8 100644 --- a/.github/workflows/test_pr_and_main.yml +++ b/.github/workflows/test_pr_and_main.yml @@ -429,10 +429,6 @@ jobs: if test -n "$PYPI_DEPENDENCIES"; then python -m pip install --cache-dir cache/pip $PYPI_DEPENDENCIES fi - # Remove qt from win/3.13 so we don't trigger test_qt.py - if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then - conda remove qt6-main qt-main pyqt pyqt5-sip || echo "qt components are not in the environment" - fi # remember this python interpreter python -c 'import sys; print("PYTHON_EXE=%s" \ % (sys.executable,))' >> $GITHUB_ENV From 9727bb15090d2aa8177271ccc231613402d22e6b Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Wed, 6 Nov 2024 14:34:34 -0700 Subject: [PATCH 15/18] Move logic to test_qt file --- pyomo/contrib/viewer/qt.py | 24 +++++++++++------------- pyomo/contrib/viewer/tests/test_qt.py | 6 ++++++ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/pyomo/contrib/viewer/qt.py b/pyomo/contrib/viewer/qt.py index cecdb728ca7..f2744fa2d56 100644 --- a/pyomo/contrib/viewer/qt.py +++ b/pyomo/contrib/viewer/qt.py @@ -38,19 +38,17 @@ import_errors = [] # Set this to the Qt wrapper module is available available = False -from pyomo.core.base.units_container import pint_available - -if pint_available: - for module_str in supported: - try: - qt_package = importlib.import_module(module_str) - QtWidgets = importlib.import_module(f"{module_str}.QtWidgets") - QtCore = importlib.import_module(f"{module_str}.QtCore") - QtGui = importlib.import_module(f"{module_str}.QtGui") - available = module_str - break - except Exception as e: - import_errors.append(f"{e}") + +for module_str in supported: + try: + qt_package = importlib.import_module(module_str) + QtWidgets = importlib.import_module(f"{module_str}.QtWidgets") + QtCore = importlib.import_module(f"{module_str}.QtCore") + QtGui = importlib.import_module(f"{module_str}.QtGui") + available = module_str + break + except Exception as e: + import_errors.append(f"{e}") if not available: # If Qt is not available, we still want to be able to test as much diff --git a/pyomo/contrib/viewer/tests/test_qt.py b/pyomo/contrib/viewer/tests/test_qt.py index 73b7fc1893e..2108976d2ea 100644 --- a/pyomo/contrib/viewer/tests/test_qt.py +++ b/pyomo/contrib/viewer/tests/test_qt.py @@ -44,6 +44,7 @@ import pyomo.contrib.viewer.qt as myqt import pyomo.contrib.viewer.pyomo_viewer as pv from pyomo.contrib.viewer.qt import available +from pyomo.core.base.units_container import pint_available if available: import contextvars @@ -59,6 +60,11 @@ def qtbot(): pytestmark = unittest.pytest.mark.skip("Qt components are not available.") +if not pint_available: + pytestmark = unittest.pytest.mark.skip( + "contrib.viewer requires pint, which is not available." + ) + def get_model(): # Borrowed this test model from the trust region tests From 77ad4de962045f5703650c54cd5c82e4fd7a0971 Mon Sep 17 00:00:00 2001 From: blnicho Date: Thu, 7 Nov 2024 10:35:27 -0700 Subject: [PATCH 16/18] Try testing pint on 3.13 again following the 0.24.4 release --- .github/workflows/test_branches.yml | 4 ++-- .github/workflows/test_pr_and_main.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_branches.yml b/.github/workflows/test_branches.yml index 463d7ceebca..4b25fd858e7 100644 --- a/.github/workflows/test_branches.yml +++ b/.github/workflows/test_branches.yml @@ -345,8 +345,8 @@ jobs: EXCLUDE="casadi numdifftools $EXCLUDE" fi if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then - # As of Nov 4, 2024, pint/qtconsole are not compatible with python 3.13 on win - EXCLUDE="pint qtconsole $EXCLUDE" + # As of Nov 7, 2024, qtconsole is not compatible with python 3.13 on win + EXCLUDE="qtconsole $EXCLUDE" fi EXCLUDE=`echo "$EXCLUDE" | xargs` if test -n "$EXCLUDE"; then diff --git a/.github/workflows/test_pr_and_main.yml b/.github/workflows/test_pr_and_main.yml index 314eb9b6ac8..a0c45075dab 100644 --- a/.github/workflows/test_pr_and_main.yml +++ b/.github/workflows/test_pr_and_main.yml @@ -368,8 +368,8 @@ jobs: EXCLUDE="casadi numdifftools $EXCLUDE" fi if [[ "${{matrix.TARGET}}" == win && "${{matrix.python}}" == "3.13" ]]; then - # As of Nov 4, 2024, pint/qtconsole are not compatible with python 3.13 on win - EXCLUDE="pint qtconsole $EXCLUDE" + # As of Nov 7, 2024, qtconsole is not compatible with python 3.13 on win + EXCLUDE="qtconsole $EXCLUDE" fi EXCLUDE=`echo "$EXCLUDE" | xargs` if test -n "$EXCLUDE"; then From a1d11651dc538d03894571f39915799245e5680c Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Mon, 11 Nov 2024 09:08:39 -0700 Subject: [PATCH 17/18] qtconsole needs to be available as well --- pyomo/contrib/viewer/tests/test_qt.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyomo/contrib/viewer/tests/test_qt.py b/pyomo/contrib/viewer/tests/test_qt.py index 2108976d2ea..9d18cc388df 100644 --- a/pyomo/contrib/viewer/tests/test_qt.py +++ b/pyomo/contrib/viewer/tests/test_qt.py @@ -65,6 +65,11 @@ def qtbot(): "contrib.viewer requires pint, which is not available." ) +if not pv.qtconsole_available: + pytestmark = unittest.pytest.mark.skip( + "contrib.viewer requires qtconsole, which is not available." + ) + def get_model(): # Borrowed this test model from the trust region tests From f35b608695ced27736624e7760b60fda35147c01 Mon Sep 17 00:00:00 2001 From: Miranda Mundt Date: Mon, 11 Nov 2024 15:57:20 -0700 Subject: [PATCH 18/18] Override problematic docstring and fix two typos --- pyomo/contrib/pynumero/sparse/mpi_block_vector.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyomo/contrib/pynumero/sparse/mpi_block_vector.py b/pyomo/contrib/pynumero/sparse/mpi_block_vector.py index f976ee2853d..85acee1051d 100644 --- a/pyomo/contrib/pynumero/sparse/mpi_block_vector.py +++ b/pyomo/contrib/pynumero/sparse/mpi_block_vector.py @@ -305,14 +305,14 @@ def has_none(self): @property def owned_blocks(self): """ - Returns list with inidices of blocks owned by this processor. + Returns list with indices of blocks owned by this processor. """ return self._owned_blocks @property def shared_blocks(self): """ - Returns list with inidices of blocks shared by all processors + Returns list with indices of blocks shared by all processors """ return np.array([i for i in range(self.nblocks) if self._rank_owner[i] < 0]) @@ -1377,6 +1377,9 @@ def cumsum(self, axis=None, dtype=None, out=None): raise RuntimeError('Operation not supported by MPIBlockVector') def tolist(self): + """ + Disable `np.ndarray.tolist` as it is not supported. + """ raise RuntimeError('Operation not supported by MPIBlockVector') def flatten(self, order='C'):