Skip to content

Commit

Permalink
Try waiting for signals instead of dealing with modals
Browse files Browse the repository at this point in the history
  • Loading branch information
lbianchi-lbl committed Feb 15, 2022
1 parent 867ce73 commit 141995c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 21 deletions.
20 changes: 8 additions & 12 deletions foqus_lib/gui/main/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class mainWindow(QMainWindow):
This is the FOQUS main window class
"""

simCompleted = QtCore.pyqtSignal(str, bool)

def __init__(
self,
title,
Expand Down Expand Up @@ -1392,33 +1394,27 @@ def stopSim(self):
self.runningSingle = False
self.dat.flowsheet.onlySingleNode = None
if err == 0:
QMessageBox.information(
self,
self.simCompleted.emit(
"Finished in " + hhmmss(int(self.dat.flowsheet.solTime)),
"The simulation completed successfully.",
True,
)
self.setStatus(
"Finished Single Simulation... Success in "
+ hhmmss(int(self.dat.flowsheet.solTime))
)
elif err == 100:
QMessageBox.information(
self,
self.simCompleted.emit(
"Finished in " + hhmmss(int(self.dat.flowsheet.solTime)) + "s",
"The single node simulation completed successfully.",
True,
)
self.setStatus(
"Finished Single Node Simulation... Success in "
+ hhmmss(int(self.dat.flowsheet.solTime))
)
else:
QMessageBox.critical(
self,
self.simCompleted.emit(
"Error in " + hhmmss(int(self.dat.flowsheet.solTime)) + "s",
"The simulation completed with an error "
+ str(err)
+ ", "
+ errText,
False,
)
self.setStatus(
"Error Single Simulation in "
Expand Down
8 changes: 2 additions & 6 deletions foqus_lib/gui/tests/test_ml_ai.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,8 @@ def trigger_flowsheet_run_action(
pymodels_ml_ai,
):
run_action = main_window.runAction
with qtbot.replacing_with_signal(
(QtWidgets.QMessageBox, "information"),
(QtWidgets.QMessageBox, "critical"),
) as signal:
with qtbot.wait_signal(signal, timeout=2_000):
run_action.trigger()
with qtbot.wait_signal(main_window.simCompleted, timeout=2_000):
run_action.trigger()
return run_action

@pytest.fixture(scope="function")
Expand Down
2 changes: 1 addition & 1 deletion foqus_lib/gui/tests/test_uq.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_generate_samples(self, qtbot, generate_samples):
def run_simulation(self, qtbot):
with qtbot.focusing_on(self.frame.simulationTable):
qtbot.select_row(0)
with qtbot.waiting_for_modal(timeout=90_000):
with qtbot.wait_signal(self.frame.runsFinishedSignal, timeout=90_000):
qtbot.using(column="Launch").click()

@pytest.mark.usefixtures("run_simulation")
Expand Down
2 changes: 0 additions & 2 deletions foqus_lib/gui/uq/uqSetupFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1138,9 +1138,7 @@ def resultsBox(self, numSuccessful, numSamples):
msgBox = QtWidgets.QMessageBox()
msgBox.setWindowTitle("FOQUS Run Finished")
msgBox.setText("%d of %d runs were successful!" % (numSuccessful, numSamples))
result = msgBox.exec_()
self.refreshFilterData(updateResult=True)
return result

# =========================== START Brenda's stuff =========================

Expand Down

0 comments on commit 141995c

Please sign in to comment.