From af5ba369f81f89b9a10a2f186360013b57f92baf Mon Sep 17 00:00:00 2001 From: wang--ge Date: Mon, 6 Feb 2023 18:50:34 +0800 Subject: [PATCH] maint more informative assertion errors when warnings happen --- ...ssertion-errors-when-warnings-happen.patch | 71 +++++++++++++++++++ python-joblib.spec | 10 ++- 2 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 maint-more-informative-assertion-errors-when-warnings-happen.patch diff --git a/maint-more-informative-assertion-errors-when-warnings-happen.patch b/maint-more-informative-assertion-errors-when-warnings-happen.patch new file mode 100644 index 0000000..41ea6fb --- /dev/null +++ b/maint-more-informative-assertion-errors-when-warnings-happen.patch @@ -0,0 +1,71 @@ +From a9a33285fd713132786d4521be8b881d7c7b07c7 Mon Sep 17 00:00:00 2001 +From: wang--ge +Date: Mon, 6 Feb 2023 17:11:39 +0800 +Subject: [PATCH] maint more informative assertion errors when warings happen + +--- + continuous_integration/run_tests.sh | 2 +- + joblib/test/test_parallel.py | 16 +++++++++++----- + 2 files changed, 12 insertions(+), 6 deletions(-) + +diff --git a/continuous_integration/run_tests.sh b/continuous_integration/run_tests.sh +index 51bed5f..6e7a537 100755 +--- a/continuous_integration/run_tests.sh ++++ b/continuous_integration/run_tests.sh +@@ -20,7 +20,7 @@ if [[ "$SKIP_TESTS" != "true" ]]; then + export PYTEST_ADDOPTS="--cov=joblib --cov-append" + fi + +- pytest joblib -vl --timeout=60 --junitxml="${JUNITXML}" ++ pytest joblib -vl --timeout=120 --junitxml="${JUNITXML}" + make test-doc + fi + +diff --git a/joblib/test/test_parallel.py b/joblib/test/test_parallel.py +index 7edeb85..9c6b2dc 100644 +--- a/joblib/test/test_parallel.py ++++ b/joblib/test/test_parallel.py +@@ -17,6 +17,7 @@ from time import sleep + from pickle import PicklingError + from multiprocessing import TimeoutError + import pickle ++import warnings + import pytest + + from importlib import reload +@@ -190,22 +191,27 @@ def test_main_thread_renamed_no_warning(backend, monkeypatch): + + + def _assert_warning_nested(backend, inner_n_jobs, expected): +- with warns(None) as records: ++ with warnings.catch_warnings(record=True) as records: ++ warnings.simplefilter("always") + parallel_func(backend=backend, inner_n_jobs=inner_n_jobs) + ++ messages = [w.message for w in records] + if expected: + # with threading, we might see more that one records +- if len(records) > 0: +- return 'backed parallel loops cannot' in records[0].message.args[0] ++ if warnings: ++ return (len(messages)==1 and 'backed parallel loops cannot' in messages[0].args[0]) + return False + else: +- assert len(records) == 0 ++ assert not messages + return True + + + @with_multiprocessing + @parametrize('parent_backend,child_backend,expected', [ +- ('loky', 'multiprocessing', True), ('loky', 'loky', False), ++ ('loky', 'multiprocessing', True), ++ # XXX: loky nested under loky causes pytest 7+ to freeze after tests end when using warnings.catch_warnings: ++ # deadlock happens in loky/process_executor.py", line 193, in _python_exit ++ # ('loky', 'loky', False), + ('multiprocessing', 'multiprocessing', True), + ('multiprocessing', 'loky', True), + ('threading', 'multiprocessing', True), +-- +2.27.0 + diff --git a/python-joblib.spec b/python-joblib.spec index 781887a..41ca28d 100644 --- a/python-joblib.spec +++ b/python-joblib.spec @@ -2,11 +2,12 @@ Name: python-%{pypi_name} Version: 1.1.0 -Release: 1 +Release: 2 Summary: Utilities to provide lightweight pipelining in Python -License: BSD-licenced (3 clause) +License: BSD-3-clause URL: https://joblib.readthedocs.io/en/latest/ Source0: https://github.com/joblib/joblib/archive/%{version}.tar.gz#/%{pypi_name}-%{version}.tar.gz +Patch1: maint-more-informative-assertion-errors-when-warnings-happen.patch BuildArch: noarch BuildRequires: python3-devel #test requires @@ -25,7 +26,7 @@ Summary: %{summary} %description -n python3-%{pypi_name} %{_description} %prep -%autosetup -n %{pypi_name}-%{version} +%autosetup -n %{pypi_name}-%{version} -p1 %build %py3_build @@ -44,6 +45,9 @@ Summary: %{summary} %{python3_sitelib}/%{pypi_name}/ %changelog +* Mon Feb 06 2023 Ge Wang - 1.1.0-2 +- Maint more informative assertion errors when warnings happen + * Thu Jun 09 2022 SimpleUpdate Robot - 1.1.0-1 - Upgrade to version 1.1.0