diff --git a/conftest.py b/conftest.py index abb0c0f52757e4b2228d7d48e3dc07e08b302841..b63d3efb33f5b2c02185f16e8753231d1853e66c 100644 --- a/conftest.py +++ b/conftest.py @@ -66,5 +66,5 @@ def default_session_fixture(request): # request.addfinalizer(unpatch) - with mock.patch("multiprocessing.cpu_count", return_value=1): + with mock.patch("psutil.cpu_count", return_value=1): yield diff --git a/mlair/run_modules/pre_processing.py b/mlair/run_modules/pre_processing.py index 11d732760d99a8ac1c9b94e6e87378f21fe8b825..c7d7f920743cd2973870bdecde860fe9fa57ae37 100644 --- a/mlair/run_modules/pre_processing.py +++ b/mlair/run_modules/pre_processing.py @@ -245,7 +245,7 @@ class PreProcessing(RunEnvironment): max_process = self.data_store.get("max_number_multiprocessing") n_process = min([psutil.cpu_count(logical=False), len(set_stations), max_process]) # use only physical cpus - if n_process > 1 and use_multiprocessing: # parallel solution + if n_process > 1 and use_multiprocessing is True: # parallel solution logging.info("use parallel validate station approach") pool = multiprocessing.Pool(n_process) logging.info(f"running {getattr(pool, '_processes')} processes in parallel") diff --git a/test/test_run_modules/test_pre_processing.py b/test/test_run_modules/test_pre_processing.py index 5ae64bf3d535e72d9361394741ed8b8094091b1d..0f2ee7a10fd2e3190c0b66da558626747d4c03c9 100644 --- a/test/test_run_modules/test_pre_processing.py +++ b/test/test_run_modules/test_pre_processing.py @@ -109,7 +109,7 @@ class TestPreProcessing: assert caplog.record_tuples[-1] == ('root', 20, PyTestRegex(r'run for \d+:\d+:\d+ \(hh:mm:ss\) to check 6 ' r'station\(s\). Found 5/6 valid stations.')) - @mock.patch("multiprocessing.cpu_count", return_value=3) + @mock.patch("psutil.cpu_count", return_value=3) @mock.patch("multiprocessing.Pool", return_value=multiprocessing.Pool(3)) def test_validate_station_parallel(self, mock_pool, mock_cpu, caplog, obj_with_exp_setup): pre = obj_with_exp_setup