From 5c1f97da2dcb08c93e56e17fd86bbe3903775343 Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Fri, 1 Mar 2024 17:53:47 -0500 Subject: [PATCH 1/9] enable testing of more python versions in ci --- .github/workflows/regression.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index eb82a89c2..9fb7ebcac 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -15,14 +15,17 @@ jobs: runs-on: ubuntu-20.04 strategy: fail-fast: false + matrix: + python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: '3.6' + python-version: ${{ matrix.python-version }} + cache: 'pip' - name: Install numpy run: | From 977803cee10d57e869ac632e0f957fb862875f38 Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Fri, 1 Mar 2024 17:54:15 -0500 Subject: [PATCH 2/9] fix: pass levels as kw arg to fix tests for py 3.8 --- omas/omas_plot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/omas/omas_plot.py b/omas/omas_plot.py index bba21fa19..9b35ff38a 100644 --- a/omas/omas_plot.py +++ b/omas/omas_plot.py @@ -800,7 +800,7 @@ def get2d(contour_quantity): z = scipy.ndimage.zoom(z, sf) value_2d = scipy.ndimage.zoom(value_2d, sf) - cs = ax.contour(r, z, value_2d, levels, **kw) + cs = ax.contour(r, z, value_2d, levels=levels, **kw) if label_contours or ((label_contours is None) and (contour_quantity == 'q')): ax.clabel(cs) From ffa8f0afeab598ac905686a7ce70cd57d29410c9 Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Fri, 1 Mar 2024 18:00:13 -0500 Subject: [PATCH 3/9] add extra build dependencies for python 3.7 build --- .github/workflows/regression.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 9fb7ebcac..a483239df 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -27,6 +27,13 @@ jobs: python-version: ${{ matrix.python-version }} cache: 'pip' + + - name: Extra dependencies required for 3.7 + if: ${{matrix.python-version == '3.7'}} + run: | + sudo apt-get update + sudo apt-get install libhdf5-dev libnetcdf-dev + - name: Install numpy run: | python3 -m pip install numpy From 0cb1bbaa3c9124aba9907e6dbcca2648bed839a7 Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Fri, 1 Mar 2024 18:25:53 -0500 Subject: [PATCH 4/9] skip test if xarray star import raises error --- omas/tests/failed_imports.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/omas/tests/failed_imports.py b/omas/tests/failed_imports.py index 53fbf9782..05e8f7ddf 100644 --- a/omas/tests/failed_imports.py +++ b/omas/tests/failed_imports.py @@ -3,7 +3,6 @@ from omas.omas_setup import omas_rcparams import os import warnings -from omas.tests.warning_setup import hard_warnings, set_omas_warnings import socket if 'iter' in socket.gethostname(): @@ -69,6 +68,8 @@ failed_OMFIT = False except ImportError as _excp: failed_OMFIT = _excp + except AttributeError as _excp: + failed_OMFIT = "omfit_classes, from xarray import * bug " try: import MDSplus From 2efc51dfcc1b5ed12d94000bca4889f8809d6aac Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Fri, 1 Mar 2024 18:53:00 -0500 Subject: [PATCH 5/9] remove 3.12 and fix 3.7 build --- .github/workflows/regression.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index a483239df..51e67dfbf 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -16,7 +16,8 @@ jobs: strategy: fail-fast: false matrix: - python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', '3.11'] + # 3.12 does not yet work because numpy removed numpy.distutils that pygacode relies on steps: - uses: actions/checkout@v4 @@ -42,7 +43,17 @@ jobs: run: | python3 -m pip install -r requirements.txt - - name: Install OMAS + # numpy is a build time dependency of pygacode + # but before 1.0 it did not specify it so we need to build without build isolation + # and manually install numpy + - name: Install OMAS (Py 3.7) + if: ${{matrix.python-version == '3.7'}} + run: | + python3 -m pip install wheel + python3 -m pip install --no-build-isolation .[machine] + + - name: Install OMAS (normal) + if: ${{matrix.python-version != '3.7'}} run: | python3 -m pip install .[machine] From 8374d8174488fe4e7c7c35c66cb72ab33e3a94ce Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Fri, 1 Mar 2024 20:58:47 -0500 Subject: [PATCH 6/9] skip broken omfit_classes test when using 3.7 --- .github/workflows/regression.yml | 5 +++-- omas/tests/test_omas_examples.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 51e67dfbf..7dfde2755 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -44,8 +44,9 @@ jobs: python3 -m pip install -r requirements.txt # numpy is a build time dependency of pygacode - # but before 1.0 it did not specify it so we need to build without build isolation - # and manually install numpy + # but before pygacode 1.0 it did not specify its build dependencies correctly + # and pygacode requires python >= 3.8, + # so for 3.7 we need to build without build isolation and manually install numpy - name: Install OMAS (Py 3.7) if: ${{matrix.python-version == '3.7'}} run: | diff --git a/omas/tests/test_omas_examples.py b/omas/tests/test_omas_examples.py index 78b090530..7f16778bc 100644 --- a/omas/tests/test_omas_examples.py +++ b/omas/tests/test_omas_examples.py @@ -97,6 +97,8 @@ def test_uncertain(self): @unittest.skipIf(failed_OMFIT, str(failed_OMFIT)) def test_plot_g_s_2_ip(self): + if sys.version_info.minor==7: + raise unittest.SkipTest("Avoid Py 3.7 omfit_classes bug.") from omas.examples import plot_g_s_2_ip def test_plot_saveload_scaling(self): From 87b9aa020a4a6c44e87e8ceba02fd8d96a26d6ce Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Sun, 3 Mar 2024 13:52:24 -0500 Subject: [PATCH 7/9] avoid xarray+importlib_metadata bug on 3.7 --- requirements.txt | 31 ++++++++++++++++--------------- setup.py | 3 ++- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/requirements.txt b/requirements.txt index 5c5e3cfd4..d5a4b857b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,21 +2,22 @@ # # usage: pip install -r requirements.txt -numpy>=1.16.1 # required -uncertainties # required -pint # required -netCDF4 # required -boto3 # required -matplotlib # required -scipy # required -h5py # required -pymongo # required -dnspython # required -xmltodict # required -xarray # required -setuptools>=41.2 # required -tqdm # required -Cython # required +numpy>=1.16.1 # required +uncertainties # required +pint # required +netCDF4 # required +boto3 # required +matplotlib # required +scipy # required +h5py # required +pymongo # required +dnspython # required +xmltodict # required +xarray # required +setuptools>=41.2 # required +tqdm # required +Cython # required +importlib_metadata <5;python_version=='3.7' # required # omfit_classes # machine # pexpect # machine diff --git a/setup.py b/setup.py index 5552fc857..8974f017e 100644 --- a/setup.py +++ b/setup.py @@ -19,6 +19,7 @@ 'setuptools>=41.2', 'tqdm', 'Cython', + "importlib_metadata <5;python_version=='3.7'" ] extras_require = { @@ -44,7 +45,7 @@ f.write('# Do not edit this file by hand, operate on setup.py instead\n#\n') f.write('# usage: pip install -r requirements.txt\n\n') for item in install_requires: - f.write(item.ljust(25) + '# required\n') + f.write(item.ljust(50) + ' # required\n') for requirement in extras_require: f.write('\n') for item in extras_require[requirement]: From a38f1c98b60c97e581362f475116cc435847816b Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Sun, 3 Mar 2024 14:14:06 -0500 Subject: [PATCH 8/9] add more explanations to the workarounds --- omas/tests/test_omas_examples.py | 4 ++++ setup.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/omas/tests/test_omas_examples.py b/omas/tests/test_omas_examples.py index 7f16778bc..f6c881e31 100644 --- a/omas/tests/test_omas_examples.py +++ b/omas/tests/test_omas_examples.py @@ -97,6 +97,10 @@ def test_uncertain(self): @unittest.skipIf(failed_OMFIT, str(failed_OMFIT)) def test_plot_g_s_2_ip(self): + # on 3.7 this test raises: + # ValueError: Number of rows must be a positive integer, not 7.0 + # It seems like this is caused by a bug in omfit_classes where a float + # instead of int is passed to plot if sys.version_info.minor==7: raise unittest.SkipTest("Avoid Py 3.7 omfit_classes bug.") from omas.examples import plot_g_s_2_ip diff --git a/setup.py b/setup.py index 8974f017e..0b7c5c4db 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ import os -import sys import glob import subprocess @@ -19,6 +18,8 @@ 'setuptools>=41.2', 'tqdm', 'Cython', + # latest xarray version that works with 3.7 doesn't work + # with importlib_metadata >5 since they deprecated the `get()` method on Entrypoints "importlib_metadata <5;python_version=='3.7'" ] From c5e5903743254cc566b08db64a5b2effe1cbe73e Mon Sep 17 00:00:00 2001 From: Christoph Hasse Date: Sun, 3 Mar 2024 14:31:07 -0500 Subject: [PATCH 9/9] revert temp import removal from debugging session --- omas/tests/failed_imports.py | 1 + 1 file changed, 1 insertion(+) diff --git a/omas/tests/failed_imports.py b/omas/tests/failed_imports.py index 05e8f7ddf..f3b72c0a6 100644 --- a/omas/tests/failed_imports.py +++ b/omas/tests/failed_imports.py @@ -3,6 +3,7 @@ from omas.omas_setup import omas_rcparams import os import warnings +from omas.tests.warning_setup import hard_warnings, set_omas_warnings import socket if 'iter' in socket.gethostname():