Skip to content

Commit

Permalink
Merge branch '2143_Settings_Menu_Themes' of https://github.com/mantid…
Browse files Browse the repository at this point in the history
…project/mantidimaging into 2143_Settings_Menu_Themes
  • Loading branch information
MikeSullivan7 committed Apr 10, 2024
2 parents 884cec4 + 056df53 commit 764091e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/release_notes/next/dev-2035-process-count
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#2035: Add setting for number of processes to start in multiprocessing pool (default to 8)
1 change: 1 addition & 0 deletions docs/release_notes/next/fix-2076-ROI-speed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#2076: ROI speed up
9 changes: 6 additions & 3 deletions mantidimaging/core/parallel/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
7 changes: 2 additions & 5 deletions mantidimaging/gui/windows/spectrum_viewer/spectrum_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -205,7 +202,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)
Expand Down Expand Up @@ -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]:
Expand Down
6 changes: 5 additions & 1 deletion mantidimaging/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import os

import darkdetect
from PyQt5.QtCore import QSettings
from PyQt5.QtWidgets import QApplication
from PyQt5 import QtCore
from PyQt5.QtGui import QGuiApplication, QFont, QFontInfo
Expand Down Expand Up @@ -112,9 +113,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()
pm.create_and_start_pool(process_count)
gui.execute()
result = q_application.exec_()
except BaseException as e:
Expand Down
2 changes: 1 addition & 1 deletion mantidimaging/test_helpers/start_qapplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 764091e

Please sign in to comment.