Skip to content

Commit

Permalink
Small fixes for singleton clearing + trying on windows [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
dbouget committed Oct 4, 2024
1 parent 1471da0 commit 1b8a3fe
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/build_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ jobs:

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
7 changes: 7 additions & 0 deletions .github/workflows/build_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ jobs:
pip install matplotlib==3.3.4
pip install --force-reinstall --no-cache-dir pyside6
- name: Integration tests
env:
DISPLAY: ':99.0'
run: |
pip install pytest-qt pytest-cov
pytest --cov=gui --cov=utils ${{github.workspace}}/integration_tests
- name: Build software
run: |
pip install pyinstaller==5.13.2
Expand Down
13 changes: 13 additions & 0 deletions gui/RaidionicsMainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ def __set_mainmenu_interface(self):
'Images/download-tray-icon.png')),
'Download test data', self)
self.file_menu.addAction(self.download_example_data_action)
self.clear_scene_action = QAction(QIcon(os.path.join(os.path.dirname(os.path.realpath(__file__)),
'Images/trash-bin_icon.png')), 'Clear', self)
self.file_menu.addAction(self.clear_scene_action)

self.quit_action = QAction(QIcon(os.path.join(os.path.dirname(os.path.realpath(__file__)),
'Images/power-icon.png')), 'Quit', self)
self.quit_action.setShortcut("Ctrl+Q")
Expand Down Expand Up @@ -367,6 +371,7 @@ def __set_menubar_connections(self):
self.batch_mode_action.triggered.connect(self.__on_study_batch_clicked)
self.settings_preferences_action.triggered.connect(self.__on_settings_preferences_clicked)
# self.quit_action.triggered.connect(sys.exit)
self.clear_scene_action.triggered.connect(self.on_clear_scene)
self.quit_action.triggered.connect(self.__on_exit_software)
self.download_example_data_action.triggered.connect(self.__on_download_example_data)

Expand Down Expand Up @@ -533,3 +538,11 @@ def standardOutputWritten(self, text):
# self.singleuse_mode_widget.standardOutputWritten(text)
elif self.central_stackedwidget.currentIndex() == 2:
self.batch_mode_widget.standardOutputWritten(text)

def on_clear_scene(self):
logging.info("[RaidionicsMainWindow] Interface clean-up. Removing all loaded patients and studies.")
self.batch_study_widget.on_clear_scene()
self.single_patient_widget.on_clear_scene()
SoftwareConfigResources.getInstance().reset() # <= Necessary for the integration tests not to crash...
if len(list(SoftwareConfigResources.getInstance().patients_parameters.keys())) > 0:
raise ValueError("[Software error] Existing patient IDs after clearing the scene!")
3 changes: 3 additions & 0 deletions gui/SinglePatientComponent/SinglePatientWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,6 @@ def on_annotation_volume_imported(self, uid: str) -> None:
def on_atlas_volume_imported(self, uid: str) -> None:
self.layers_panel.on_atlas_volume_import(uid)

def on_clear_scene(self):
for w in list(self.results_panel.patient_results_widgets.keys()):
self.results_panel.patient_results_widgets[w].patient_closed.emit(w)
5 changes: 5 additions & 0 deletions gui/StudyBatchComponent/StudyBatchWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,8 @@ def on_patient_refresh_triggered(self, patient_uid: str) -> None:
SoftwareConfigResources.getInstance().get_active_study().refresh_patient_statistics(patient_uid,
SoftwareConfigResources.getInstance().get_patient(patient_uid))
self.patient_refreshed.emit(patient_uid)

def on_clear_scene(self):
# @TODO. Not enough, the graphical display for the center and right panels should also be cleared and updated.
for w in list(self.studies_panel.single_study_widgets.keys()):
self.studies_panel.single_study_widgets[w].study_closed.emit(w)
1 change: 1 addition & 0 deletions integration_tests/batch_study_empty_study_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def window():
"""
window = RaidionicsMainWindow()
window.on_clear_scene()
return window

"""
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/batch_study_loading_study_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def window():
"""
window = RaidionicsMainWindow()
window.on_clear_scene()
return window

"""
Expand Down Expand Up @@ -78,6 +79,7 @@ def test_study_reloading(qtbot, test_location, test_data_folder, window):
sleep(10)
assert len(list(SoftwareConfigResources.getInstance().get_active_study().included_patients_uids.keys())) == 2


def test_cleanup(window):
if window.logs_thread.isRunning():
window.logs_thread.stop()
Expand Down
2 changes: 2 additions & 0 deletions integration_tests/single_patient_empty_patient_test.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
import os
import shutil
from time import sleep
Expand Down Expand Up @@ -53,6 +54,7 @@ def window():
"""
window = RaidionicsMainWindow()
window.on_clear_scene()
return window


Expand Down
1 change: 1 addition & 0 deletions integration_tests/single_patient_patient_loading_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def window():
"""
window = RaidionicsMainWindow()
window.on_clear_scene()
return window

""" Remaining tests to add:
Expand Down
3 changes: 3 additions & 0 deletions utils/software_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,6 @@ def get_annotation_generation_types(self) -> List[str]:
for anno in AnnotationGenerationType:
results.append(anno.name)
return results

def reset(self):
self.__set_default_values()

0 comments on commit 1b8a3fe

Please sign in to comment.