From 3265258587ab7ce7313942ac581ed43a81c4cc00 Mon Sep 17 00:00:00 2001 From: Sam Tygier Date: Fri, 22 Mar 2024 14:16:22 +0000 Subject: [PATCH 1/6] Add argument for number of processes to start --- mantidimaging/core/parallel/manager.py | 9 ++++++--- mantidimaging/main.py | 2 +- mantidimaging/test_helpers/start_qapplication.py | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mantidimaging/core/parallel/manager.py b/mantidimaging/core/parallel/manager.py index c7ecb2ff08a..00cfc3f291a 100644 --- a/mantidimaging/core/parallel/manager.py +++ b/mantidimaging/core/parallel/manager.py @@ -28,13 +28,16 @@ pool: Pool | None = None -def create_and_start_pool(): - LOG.info('Creating process pool') +def create_and_start_pool(process_count: int) -> None: t0 = time.monotonic() context = get_context('spawn') global cores - cores = context.cpu_count() + if process_count == 0: + cores = context.cpu_count() + else: + cores = process_count global pool + LOG.info(f'Creating process pool with {cores} processes') pool = context.Pool(cores, initializer=worker_setup) if perf_logger.isEnabledFor(1): diff --git a/mantidimaging/main.py b/mantidimaging/main.py index ac3206daa4a..f4ce2bffa9f 100755 --- a/mantidimaging/main.py +++ b/mantidimaging/main.py @@ -92,7 +92,7 @@ def main() -> None: from mantidimaging import gui try: - pm.create_and_start_pool() + pm.create_and_start_pool(0) gui.execute() result = q_application.exec_() except BaseException as e: diff --git a/mantidimaging/test_helpers/start_qapplication.py b/mantidimaging/test_helpers/start_qapplication.py index 4f224bb0df8..2de23f9e1cb 100644 --- a/mantidimaging/test_helpers/start_qapplication.py +++ b/mantidimaging/test_helpers/start_qapplication.py @@ -85,7 +85,7 @@ def tearDownClass(): def start_multiprocessing_pool(cls): def setUpClass(): - create_and_start_pool() + create_and_start_pool(0) def tearDownClass(): end_pool() From 8c3aeed1bd06009ea8c16f72a53c579c1a90967a Mon Sep 17 00:00:00 2001 From: Sam Tygier Date: Fri, 22 Mar 2024 14:54:28 +0000 Subject: [PATCH 2/6] Add setting for number of processes to start --- mantidimaging/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mantidimaging/main.py b/mantidimaging/main.py index f4ce2bffa9f..22270d42ac2 100755 --- a/mantidimaging/main.py +++ b/mantidimaging/main.py @@ -8,6 +8,7 @@ import warnings import os +from PyQt5.QtCore import QSettings from PyQt5.QtWidgets import QApplication from PyQt5 import QtCore from PyQt5.QtGui import QGuiApplication @@ -90,9 +91,12 @@ def main() -> None: h.initialise_logging(args.log_level) + settings = QSettings() + process_count = settings.value("multiprocessing/process_count", 8, type=int) + from mantidimaging import gui try: - pm.create_and_start_pool(0) + pm.create_and_start_pool(process_count) gui.execute() result = q_application.exec_() except BaseException as e: From a5c6ea9aa1a0bb2bbf9e2c1da5b627bd6c9d20d4 Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Thu, 28 Mar 2024 14:27:21 +0000 Subject: [PATCH 3/6] chaning norm test --- scripts/operations_tests/test_cases.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/operations_tests/test_cases.json b/scripts/operations_tests/test_cases.json index c63865ac7c5..bf52ac56b73 100644 --- a/scripts/operations_tests/test_cases.json +++ b/scripts/operations_tests/test_cases.json @@ -578,8 +578,8 @@ "region_of_interest": [ 0, 0, - 200, - 200 + 20, + 20 ], "normalisation_mode": "Stack Average", "flat_field": null @@ -592,8 +592,8 @@ "region_of_interest": [ 0, 0, - 200, - 200 + 20, + 20 ], "normalisation_mode": "Stack Average", "flat_field": null From d213cf4c759f5f7d1c64807c6cfd7d9e5d43522a Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Wed, 3 Apr 2024 07:21:28 +0100 Subject: [PATCH 4/6] added sigRegionChangeFinished --- docs/release_notes/next/fix-2076-ROI-speed | 1 + mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 docs/release_notes/next/fix-2076-ROI-speed diff --git a/docs/release_notes/next/fix-2076-ROI-speed b/docs/release_notes/next/fix-2076-ROI-speed new file mode 100644 index 00000000000..fc4e75f0fb2 --- /dev/null +++ b/docs/release_notes/next/fix-2076-ROI-speed @@ -0,0 +1 @@ +#2076: ROI speed up \ No newline at end of file diff --git a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py index c3b84e7c792..6127af35749 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py +++ b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py @@ -205,7 +205,7 @@ def add_roi(self, roi: SensibleROI, name: str) -> None: self.roi_dict[name] = roi_object.roi self.max_roi_size = roi_object.size() - self.roi_dict[name].sigRegionChanged.connect(self.roi_changed.emit) + self.roi_dict[name].sigRegionChangeFinished.connect(self.roi_changed.emit) self.roi_dict[name].sigClicked.connect(self.roi_clicked.emit) self.image.vb.addItem(self.roi_dict[name]) self.roi_dict[name].hoverPen = mkPen(self.roi_dict[name].colour, width=3) From fb40444f925733c12851269df0ce3d03b795f478 Mon Sep 17 00:00:00 2001 From: Sam Tygier Date: Wed, 27 Mar 2024 15:50:44 +0000 Subject: [PATCH 5/6] Release notes --- docs/release_notes/next/dev-2035-process-count | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/release_notes/next/dev-2035-process-count diff --git a/docs/release_notes/next/dev-2035-process-count b/docs/release_notes/next/dev-2035-process-count new file mode 100644 index 00000000000..cc6a7c76ec5 --- /dev/null +++ b/docs/release_notes/next/dev-2035-process-count @@ -0,0 +1 @@ +#2035: Add setting for number of processes to start in multiprocessing pool (default to 8) From 51d4f26dbebafea34757957a022ff378fdac9148 Mon Sep 17 00:00:00 2001 From: ashmeigh Date: Thu, 4 Apr 2024 10:06:57 +0100 Subject: [PATCH 6/6] set_roi_visibility_flag removed dupilate code and added the sigchnagedfin to rangecontrol --- mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py index 6127af35749..8d8e8a75275 100644 --- a/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py +++ b/mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py @@ -175,9 +175,6 @@ def set_roi_visibility_flags(self, name: str, visible: bool) -> None: for handle in handles: handle.setVisible(visible) self.roi_dict[name].setVisible(visible) - self.roi_dict[name].setAcceptedMouseButtons(Qt.MouseButton.LeftButton) - self.roi_dict[name].sigRegionChanged.connect(self.roi_changed.emit) - self.roi_dict[name].sigClicked.connect(self.roi_clicked.emit) def set_roi_alpha(self, name: str, alpha: float) -> None: """ @@ -276,7 +273,7 @@ def __init__(self) -> None: self.nextRow() self._tof_range_label = self.addLabel() self.range_control = LinearRegionItem() - self.range_control.sigRegionChanged.connect(self._handle_tof_range_changed) + self.range_control.sigRegionChangeFinished.connect(self._handle_tof_range_changed) self.ci.layout.setRowStretchFactor(0, 1) def get_tof_range(self) -> tuple[int, int]: