From 1f66bfb8c0c76f3799977240248cc71c1de8346d Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 19 Sep 2024 13:05:03 +0200 Subject: [PATCH 1/9] Skip `test_multi_gridding_mix` on Ubuntu 22+ --- test/rxd/3d/test_multi_gridding_mix.py | 9 +++++++-- test/rxd/testutils.py | 21 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/test/rxd/3d/test_multi_gridding_mix.py b/test/rxd/3d/test_multi_gridding_mix.py index 2f7746b4dd..21e24a4246 100644 --- a/test/rxd/3d/test_multi_gridding_mix.py +++ b/test/rxd/3d/test_multi_gridding_mix.py @@ -1,10 +1,15 @@ +import pytest + from neuron.units import µm, mM, ms, mV -import sys sys.path.append("..") -from testutils import compare_data, tol +from testutils import compare_data, tol, skip_platform +@pytest.mark.skipif( + skip_platform(), + reason="See https://github.com/neuronsimulator/nrn-build-ci/issues/66", +) def test_multi_gridding_mix(neuron_instance): h, rxd, data, save_path = neuron_instance axon = h.Section(name="axon") diff --git a/test/rxd/testutils.py b/test/rxd/testutils.py index 2c8ca2670c..73e3c78b72 100644 --- a/test/rxd/testutils.py +++ b/test/rxd/testutils.py @@ -1,6 +1,8 @@ import inspect import itertools import os +import platform +from packaging.version import Version import numpy @@ -126,3 +128,22 @@ def compare_data(data): ) max_err = numpy.amax(abs(corr_vals.T - tst_dat[t2_0:t2_n, 1:])) return max_err + + +def skip_platform(): + """Check whether there is an issue with the test on the current platform""" + try: + test_platform = platform.freedesktop_os_release().get("VERSION_ID") + + # not a Ubuntu variant + if not test_platform: + return False + + # skip Ubuntu 22 and above + return Version(test_platform) > Version("22") + + # not a Linux variant (or a supported one anyway) + except (AttributeError, OSError): + return False + + return False From 3a688fbec3da364a52f15c841f20a2c6af0a7a4c Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 19 Sep 2024 13:06:37 +0200 Subject: [PATCH 2/9] Forgotten import --- test/rxd/3d/test_multi_gridding_mix.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/rxd/3d/test_multi_gridding_mix.py b/test/rxd/3d/test_multi_gridding_mix.py index 21e24a4246..20e3c84bc4 100644 --- a/test/rxd/3d/test_multi_gridding_mix.py +++ b/test/rxd/3d/test_multi_gridding_mix.py @@ -1,3 +1,5 @@ +import sys + import pytest from neuron.units import µm, mM, ms, mV From 6d01abf8f899af613de997dc88d797fe65b86653 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 19 Sep 2024 14:28:58 +0200 Subject: [PATCH 3/9] Make check more flexible --- test/rxd/testutils.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/test/rxd/testutils.py b/test/rxd/testutils.py index 73e3c78b72..74e5dfd315 100644 --- a/test/rxd/testutils.py +++ b/test/rxd/testutils.py @@ -133,14 +133,12 @@ def compare_data(data): def skip_platform(): """Check whether there is an issue with the test on the current platform""" try: - test_platform = platform.freedesktop_os_release().get("VERSION_ID") - - # not a Ubuntu variant - if not test_platform: - return False + test_platform = platform.freedesktop_os_release() # skip Ubuntu 22 and above - return Version(test_platform) > Version("22") + return test_platform.get("ID") == "ubuntu" and Version( + test_platform["VERSION_ID"] + ) > Version("22") # not a Linux variant (or a supported one anyway) except (AttributeError, OSError): From 44deb84ca25cb5d960947b16bf34453e9399b3ed Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 19 Sep 2024 14:32:40 +0200 Subject: [PATCH 4/9] Run the test, but mark it xfail --- test/rxd/3d/test_multi_gridding_mix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rxd/3d/test_multi_gridding_mix.py b/test/rxd/3d/test_multi_gridding_mix.py index 20e3c84bc4..4c8f849cf8 100644 --- a/test/rxd/3d/test_multi_gridding_mix.py +++ b/test/rxd/3d/test_multi_gridding_mix.py @@ -8,7 +8,7 @@ from testutils import compare_data, tol, skip_platform -@pytest.mark.skipif( +@pytest.mark.xfail( skip_platform(), reason="See https://github.com/neuronsimulator/nrn-build-ci/issues/66", ) From 835db0ef5e14beeefcb29e2c31db4dc3666ce371 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 19 Sep 2024 14:39:19 +0200 Subject: [PATCH 5/9] Catch more exceptions for any reason --- test/rxd/testutils.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/rxd/testutils.py b/test/rxd/testutils.py index 74e5dfd315..7dba9c8ca3 100644 --- a/test/rxd/testutils.py +++ b/test/rxd/testutils.py @@ -141,7 +141,5 @@ def skip_platform(): ) > Version("22") # not a Linux variant (or a supported one anyway) - except (AttributeError, OSError): + except Exception: return False - - return False From 703ff24db3a25a8e82c84b27739485e6457854e1 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 19 Sep 2024 14:39:56 +0200 Subject: [PATCH 6/9] Rename `skip_platform` to `check_platform` --- test/rxd/3d/test_multi_gridding_mix.py | 4 ++-- test/rxd/testutils.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/rxd/3d/test_multi_gridding_mix.py b/test/rxd/3d/test_multi_gridding_mix.py index 4c8f849cf8..a74e42dbd4 100644 --- a/test/rxd/3d/test_multi_gridding_mix.py +++ b/test/rxd/3d/test_multi_gridding_mix.py @@ -5,11 +5,11 @@ from neuron.units import µm, mM, ms, mV sys.path.append("..") -from testutils import compare_data, tol, skip_platform +from testutils import check_platform, compare_data, tol @pytest.mark.xfail( - skip_platform(), + check_platform(), reason="See https://github.com/neuronsimulator/nrn-build-ci/issues/66", ) def test_multi_gridding_mix(neuron_instance): diff --git a/test/rxd/testutils.py b/test/rxd/testutils.py index 7dba9c8ca3..d8042d32ec 100644 --- a/test/rxd/testutils.py +++ b/test/rxd/testutils.py @@ -130,7 +130,7 @@ def compare_data(data): return max_err -def skip_platform(): +def check_platform(): """Check whether there is an issue with the test on the current platform""" try: test_platform = platform.freedesktop_os_release() From 9b10f3e408da27e084a36b19d498d3bcfd2da41c Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 19 Sep 2024 16:46:27 +0200 Subject: [PATCH 7/9] Nah just skip it --- test/rxd/3d/test_multi_gridding_mix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rxd/3d/test_multi_gridding_mix.py b/test/rxd/3d/test_multi_gridding_mix.py index a74e42dbd4..9293672c50 100644 --- a/test/rxd/3d/test_multi_gridding_mix.py +++ b/test/rxd/3d/test_multi_gridding_mix.py @@ -8,7 +8,7 @@ from testutils import check_platform, compare_data, tol -@pytest.mark.xfail( +@pytest.mark.skip( check_platform(), reason="See https://github.com/neuronsimulator/nrn-build-ci/issues/66", ) From 46c44089f74a90bafded2c25b97bc98f4b716a43 Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Thu, 19 Sep 2024 17:22:20 +0200 Subject: [PATCH 8/9] Yes I did --- test/rxd/3d/test_multi_gridding_mix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/rxd/3d/test_multi_gridding_mix.py b/test/rxd/3d/test_multi_gridding_mix.py index 9293672c50..7fd272709f 100644 --- a/test/rxd/3d/test_multi_gridding_mix.py +++ b/test/rxd/3d/test_multi_gridding_mix.py @@ -8,7 +8,7 @@ from testutils import check_platform, compare_data, tol -@pytest.mark.skip( +@pytest.mark.skipif( check_platform(), reason="See https://github.com/neuronsimulator/nrn-build-ci/issues/66", ) From b8081dde836a2ea9b73eb1c2d531c95ee5a66b9f Mon Sep 17 00:00:00 2001 From: Goran Jelic-Cizmek Date: Mon, 23 Sep 2024 15:25:34 +0200 Subject: [PATCH 9/9] Refactor condition --- test/rxd/3d/test_multi_gridding_mix.py | 28 ++++++++++++++++++++++++-- test/rxd/testutils.py | 17 ---------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/test/rxd/3d/test_multi_gridding_mix.py b/test/rxd/3d/test_multi_gridding_mix.py index 7fd272709f..20d9e689a9 100644 --- a/test/rxd/3d/test_multi_gridding_mix.py +++ b/test/rxd/3d/test_multi_gridding_mix.py @@ -1,15 +1,39 @@ +import platform import sys import pytest +from packaging.version import Version from neuron.units import µm, mM, ms, mV sys.path.append("..") -from testutils import check_platform, compare_data, tol +from testutils import compare_data, tol + + +def check_platform_is_problematic(): + """ + Check whether the current platform is problematic so tests are skipped. + """ + if platform.system() == "Linux": + # `freedesktop_os_release` is only defined in 3.10+ + if hasattr(platform, "freedesktop_os_release"): + try: + flavor = platform.freedesktop_os_release() + return flavor["ID"] == "ubuntu" and Version( + flavor["VERSION_ID"] + ) > Version("22") + except OSError: + # we cannot determine the flavor reliably (no /etc/os-release file) + return True + else: + # we cannot determine the flavor reliably (<3.10) + return True + else: + return False @pytest.mark.skipif( - check_platform(), + check_platform_is_problematic(), reason="See https://github.com/neuronsimulator/nrn-build-ci/issues/66", ) def test_multi_gridding_mix(neuron_instance): diff --git a/test/rxd/testutils.py b/test/rxd/testutils.py index d8042d32ec..2c8ca2670c 100644 --- a/test/rxd/testutils.py +++ b/test/rxd/testutils.py @@ -1,8 +1,6 @@ import inspect import itertools import os -import platform -from packaging.version import Version import numpy @@ -128,18 +126,3 @@ def compare_data(data): ) max_err = numpy.amax(abs(corr_vals.T - tst_dat[t2_0:t2_n, 1:])) return max_err - - -def check_platform(): - """Check whether there is an issue with the test on the current platform""" - try: - test_platform = platform.freedesktop_os_release() - - # skip Ubuntu 22 and above - return test_platform.get("ID") == "ubuntu" and Version( - test_platform["VERSION_ID"] - ) > Version("22") - - # not a Linux variant (or a supported one anyway) - except Exception: - return False