Skip to content

Commit

Permalink
removed comment, updated completion text to use old informative blob
Browse files Browse the repository at this point in the history
  • Loading branch information
walshmm committed Oct 24, 2024
1 parent c79974f commit fec92ca
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/snapred/ui/presenter/WorkflowPresenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ def __init__(
iterateLambda=None,
resetLambda=None,
cancelLambda=None,
completionMessage=None,
completionMessageLambda=None,
parent=None,
):
super().__init__()

# 'WorkerPool' is a singleton:
# declaring it as an instance attribute, rather than a class attribute,
# allows singleton reset during testing.
self.completionMessage = completionMessage
self.completionMessageLambda = completionMessageLambda

self.worker_pool = WorkerPool()

Expand Down Expand Up @@ -144,7 +144,7 @@ def advanceWorkflow(self):
QMessageBox.information(
self.view,
"‧₊Workflow Complete‧₊",
self.completionMessage,
self.completionMessageLambda(),
)
self.reset()
else:
Expand Down
4 changes: 2 additions & 2 deletions src/snapred/ui/widget/Workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(
iterateLambda=None,
resetLambda=None,
cancelLambda=None,
completionMessage=None,
completionMessageLambda=None,
parent=None,
):
# default loading subview
Expand All @@ -21,7 +21,7 @@ def __init__(
iterateLambda=iterateLambda,
resetLambda=resetLambda,
cancelLambda=cancelLambda,
completionMessage=completionMessage,
completionMessageLambda=completionMessageLambda,
parent=parent,
)

Expand Down
31 changes: 23 additions & 8 deletions src/snapred/ui/workflow/ReductionWorkflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def __init__(self, parent=None):
startLambda=self.start,
# Retain reduction-output workspaces.
resetLambda=lambda: self.reset(True),
completionMessage=(
"Reduction has completed successfully.\n" "Your workspaces are available in the workspace list."
),
completionMessageLambda=self.completionMessage,
parent=parent,
)
.addNode(
Expand All @@ -53,7 +51,6 @@ def __init__(self, parent=None):
"Reduction",
continueAnywayHandler=self._continueAnywayHandler,
)
# .addNode(self._nothing, self._reductionSaveView, "Save")
.build()
)

Expand All @@ -66,6 +63,27 @@ def _enableConvertToUnits(self):
def _nothing(self, workflowPresenter): # noqa: ARG002
return SNAPResponse(code=200)

def completionMessage(self):
panelText = ""
if (
self.continueAnywayFlags is not None
and ContinueWarning.Type.NO_WRITE_PERMISSIONS in self.continueAnywayFlags
):
panelText = (
"<p>You didn't have permissions to write to "
+ f"<br><b>{self.savePath}</b>,<br>"
+ "but you can still save using the workbench tools.</p>"
+ "<p>Please remember to save your output workspaces!</p>"
)
else:
panelText = (
"<p>Reduction has completed successfully!"
+ "<br>Reduction workspaces have been saved to "
+ f"<br><b>{self.savePath}</b>.<br></p>"
+ "<p>If required later, these can be reloaded into Mantid workbench using 'LoadNexus'.</p>"
)
return panelText

@ExceptionToErrLog
def _populatePixelMaskDropdown(self):
if len(self._reductionRequestView.getRunNumbers()) == 0:
Expand Down Expand Up @@ -156,10 +174,7 @@ def _triggerReduction(self, workflowPresenter):
record, unfocusedData = response.data.record, response.data.unfocusedData

# .. update "save" panel message:
savePath = self.request(path="reduction/getSavePath", payload=record.runNumber).data
self._reductionSaveView.updateContinueAnyway(self.continueAnywayFlags)
# Warning: 'updateSavePath' uses the current 'continueAnywayFlags'
self._reductionSaveView.updateSavePath(savePath)
self.savePath = self.request(path="reduction/getSavePath", payload=record.runNumber).data

# Save the reduced data. (This is automatic: it happens before the "save" panel opens.)
if ContinueWarning.Type.NO_WRITE_PERMISSIONS not in self.continueAnywayFlags:
Expand Down
6 changes: 3 additions & 3 deletions src/snapred/ui/workflow/WorkflowBuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ def __init__(
resetLambda=None,
cancelLambda=None,
parent=None,
completionMessage=Config["ui.default.workflow.completionMessage"],
completionMessageLambda=lambda: Config["ui.default.workflow.completionMessage"],
):
self.parent = parent
self._startLambda = startLambda
self._iterateLambda = iterateLambda
self._resetLambda = resetLambda
self._cancelLambda = cancelLambda
self._completionMessage = completionMessage
self._completionMessageLambda = completionMessageLambda
self._workflow = None

def addNode(
Expand Down Expand Up @@ -57,6 +57,6 @@ def build(self):
iterateLambda=self._iterateLambda,
resetLambda=self._resetLambda,
cancelLambda=self._cancelLambda,
completionMessage=self._completionMessage,
completionMessageLambda=self._completionMessageLambda,
parent=self.parent,
)
4 changes: 4 additions & 0 deletions src/snapred/ui/workflow/WorkflowImplementer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
)
from snapred.backend.error.ContinueWarning import ContinueWarning
from snapred.backend.log.logger import snapredLogger
from snapred.meta.Config import Config
from snapred.ui.handler.SNAPResponseHandler import SNAPResponseHandler
from snapred.ui.widget.Workflow import Workflow

Expand Down Expand Up @@ -117,6 +118,9 @@ def complete(self):
for hook in self.resetHooks:
hook()

def completionMessage(self):
return Config["ui.default.workflow.completionMessage"]

def _request(self, request: SNAPRequest):
response = self.interfaceController.executeRequest(request)
self._handleComplications(response)
Expand Down

0 comments on commit fec92ca

Please sign in to comment.