Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated integration tests to work with ultralite data #516

Merged
merged 8 commits into from
Dec 19, 2024
2 changes: 1 addition & 1 deletion tests/data/snapred-data
Submodule snapred-data updated from bd6930 to 59443a
60 changes: 34 additions & 26 deletions tests/integration/test_workflow_panels_happy_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,10 @@ def _setup_gui(self, qapp):
lambda self, *args, **kwargs: QMessageBox.Ok
if (
"The backend has encountered warning(s)" in self.text()
and "InstrumentDonor will only be used if GroupingFilename is in XML format." in self.detailedText()
and (
"InstrumentDonor will only be used if GroupingFilename is in XML format." in self.detailedText()
or "No valid FocusGroups were specified for mode: 'lite'" in self.detailedText()
)
)
else pytest.fail(
"unexpected QMessageBox.exec:"
Expand Down Expand Up @@ -861,28 +864,29 @@ def test_diffraction_calibration_panel_happy_path(self, qtbot, qapp, calibration
self.testSummary.SUCCESS()

# set "Run Number", "Convergence Threshold", ,:
requestView.runNumberField.setText("46680")
requestView.fieldConvergenceThreshold.setText("0.1")
requestView.fieldNBinsAcrossPeakWidth.setText("10")
requestView.runNumberField.setText("58882")
requestView.litemodeToggle.setState(False)

# set all dropdown selections, but make sure that the dropdown contents are as expected
requestView.sampleDropdown.setCurrentIndex(0)
assert requestView.sampleDropdown.currentIndex() == 0
assert requestView.sampleDropdown.currentText().endswith("Diamond_001.json")
requestView.sampleDropdown.setCurrentIndex(3)
assert requestView.sampleDropdown.currentIndex() == 3
assert requestView.sampleDropdown.currentText().endswith("Silicon_NIST_640D_001.json")

# Without this next 'qtbot.wait(1000)',
# the 'groupingFileDropdown' gets reset after this successful initialization.
# I assume this is because somehow the 'populateGroupingDropdown',
# triggered by the 'runNumberField' 'editComplete' hasn't actually occurred yet?
qtbot.wait(1000)
requestView.groupingFileDropdown.setCurrentIndex(1)
assert requestView.groupingFileDropdown.currentIndex() == 1
assert requestView.groupingFileDropdown.currentText() == "Bank"
requestView.groupingFileDropdown.setCurrentIndex(0)
assert requestView.groupingFileDropdown.currentIndex() == 0
assert requestView.groupingFileDropdown.currentText() == "Column"

requestView.peakFunctionDropdown.setCurrentIndex(0)
assert requestView.peakFunctionDropdown.currentIndex() == 0
assert requestView.peakFunctionDropdown.currentText() == "Gaussian"

requestView.skipPixelCalToggle.setState(False)

self.testSummary.SUCCESS()
# execute the request

Expand Down Expand Up @@ -940,7 +944,7 @@ def test_diffraction_calibration_panel_happy_path(self, qtbot, qapp, calibration

# Now that there is a new state, we need to reselect the grouping file ... :
# Why was this error box being swallowed?
requestView.groupingFileDropdown.setCurrentIndex(1)
requestView.groupingFileDropdown.setCurrentIndex(0)

# (2) execute the calibration workflow
with qtbot.waitSignal(actionCompleted, timeout=60000):
Expand All @@ -962,11 +966,11 @@ def test_diffraction_calibration_panel_happy_path(self, qtbot, qapp, calibration
warningMessageBox.start()
# ---------------------------------------------------------------------------

# set "xtal dMin", "FWHM left", and "FWHM right": these are sufficient to get "46680" to pass.
# set "xtal dMin", "FWHM left", and "FWHM right": these are sufficient to get "58882" to pass.
# TODO: set ALL of the relevant fields, and use a test initialization template for this.
tweakPeakView.fieldXtalDMin.setText("0.72")
tweakPeakView.fieldFWHMleft.setText("2.0")
tweakPeakView.fieldFWHMright.setText("2.0")
tweakPeakView.fieldFWHMleft.setText("1.5")
tweakPeakView.fieldFWHMright.setText("2")
tweakPeakView.maxChiSqField.setText("1000.0")
tweakPeakView.peakFunctionDropdown.setCurrentIndex(0)
assert tweakPeakView.peakFunctionDropdown.currentIndex() == 0
assert tweakPeakView.peakFunctionDropdown.currentText() == "Gaussian"
Expand Down Expand Up @@ -1113,23 +1117,26 @@ def test_normalization_panel_happy_path(self, qtbot, qapp, calibration_home_from
self.testSummary.SUCCESS()

# set "Run Number", "Background run number":
requestView.runNumberField.setText("46680")
requestView.backgroundRunNumberField.setText("46680")
requestView.runNumberField.setText("58882")
requestView.backgroundRunNumberField.setText("58882")

requestView.litemodeToggle.setState(False)

# set all dropdown selections, but make sure that the dropdown contents are as expected
requestView.sampleDropdown.setCurrentIndex(0)
assert requestView.sampleDropdown.currentIndex() == 0
assert requestView.sampleDropdown.currentText().endswith("Diamond_001.json")
requestView.sampleDropdown.setCurrentIndex(3)
assert requestView.sampleDropdown.currentIndex() == 3
assert requestView.sampleDropdown.currentText().endswith("Silicon_NIST_640D_001.json")

# Without this next 'qtbot.wait(1000)',
# the 'groupingFileDropdown' gets reset after this successful initialization.
# I assume this is because somehow the 'populateGroupingDropdown',
# triggered by the 'runNumberField' 'editComplete' hasn't actually occurred yet?
qtbot.wait(1000)
requestView.groupingFileDropdown.setCurrentIndex(1)
assert requestView.groupingFileDropdown.currentIndex() == 1
assert requestView.groupingFileDropdown.currentText() == "Bank"
requestView.groupingFileDropdown.setCurrentIndex(0)
assert requestView.groupingFileDropdown.currentIndex() == 0
assert requestView.groupingFileDropdown.currentText() == "Column"
self.testSummary.SUCCESS()

""" # Why no "peak function" for normalization calibration?!
requestView.peakFunctionDropdown.setCurrentIndex(0)
assert requestView.peakFunctionDropdown.currentIndex() == 0
Expand Down Expand Up @@ -1193,7 +1200,7 @@ def test_normalization_panel_happy_path(self, qtbot, qapp, calibration_home_from

# Now that there is a new state, we need to reselect the grouping file ... :
# Why was this error box being swallowed?
requestView.groupingFileDropdown.setCurrentIndex(1)
requestView.groupingFileDropdown.setCurrentIndex(0)

warningMessageBox = mock.patch( # noqa: PT008
"qtpy.QtWidgets.QMessageBox.warning",
Expand All @@ -1220,7 +1227,7 @@ def test_normalization_panel_happy_path(self, qtbot, qapp, calibration_home_from
qtbot.wait(1000)
tweakPeakView.groupingFileDropdown.setCurrentIndex(0)
assert tweakPeakView.groupingFileDropdown.currentIndex() == 0
assert tweakPeakView.groupingFileDropdown.currentText() == "All"
assert tweakPeakView.groupingFileDropdown.currentText() == "Column"

# recalculate using the new values
# * recalculate => peak display is recalculated,
Expand Down Expand Up @@ -1278,7 +1285,7 @@ def test_reduction_panel_happy_path(self, qtbot, qapp, reduction_home_from_mirro
##

# TODO: these could be initialized in the 'setup', but the current plan is to use a YML test template.
reductionRunNumber = "46680"
reductionRunNumber = "58882"
reductionStateId = "04bd2c53f6bf6754"

# Override the standard reduction-output location, using a temporary directory
Expand Down Expand Up @@ -1370,6 +1377,7 @@ def completionMessageBoxAssert(*args, **kwargs): # noqa: ARG001
qtbot.wait(1000)

# enter a "Run Number":
requestView.liteModeToggle.setState(False)
requestView.runNumberInput.setText(reductionRunNumber)
qtbot.mouseClick(requestView.enterRunNumberButton, Qt.MouseButton.LeftButton)

Expand Down
50 changes: 50 additions & 0 deletions tests/resources/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,57 @@ IPTS:
constants:
# For tests with '46680' this seems to be necessary.
maskedPixelThreshold: 1.0
logsLocation: "/mantid_workspace_1/logs"

DetectorPeakPredictor:
fwhm: 1.17741002252 # used to convert gaussian to fwhm (2 * log_e(2))

RawVanadiumCorrection:
numberOfSlices: 1
numberOfAnnuli: 1

instrument:
native:
pixelResolution: 72
definition:
file: ${module.root}/resources/ultralite/CRACKLE_Definition.xml
lite:
pixelResolution: 18
definition:
file: ${module.root}/resources/ultralite/CRACKLELite_Definition.xml
map:
file: ${module.root}/resources/ultralite/CRACKLELiteDataMap.xml

mantid:
workspace:
nameTemplate:
delimiter: "_"
template:
run: "{unit},{group},{lite},{auxiliary},{runNumber}"
diffCal:
input: "{unit},{runNumber},raw"
table: "diffract_consts,{runNumber},{version}"
output: "{unit},{group},{runNumber},{version}"
diagnostic: "diagnostic,{group},{runNumber},{version}"
mask: "diffract_consts,mask,{runNumber},{version}"
metric: "calib_metrics,{metricName},{runNumber},{version}"
timedMetric: "calib_metrics,{metricName},{runNumber},{timestamp}"
normCal:
rawVanadium: "{unit},{group},{runNumber},raw_van_corr,{version}"
focusedRawVanadium: "{unit},{group},{runNumber},raw_van_corr,{version}"
smoothedFocusedRawVanadium: "{unit},{group},{runNumber},fitted_van_corr,{version}"

calibration:
parameters:
default:
alpha: 0.1
# alpha: 1.1
beta:
- 0.02
- 0.05
# beta:
# - 1
# - 2
fitting:
# minSignal2Noise: 0.0
minSignal2Noise: 10
21 changes: 21 additions & 0 deletions tests/resources/ultralite/CRACKLEFocGroup_Column.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<detector-grouping idf-date="2018-05-01T00:00:01" instrument="CRACKLE">
<group ID="1">
<detids>0-11</detids>
</group>
<group ID="2">
<detids>12-23</detids>
</group>
<group ID="3">
<detids>24-35</detids>
</group>
<group ID="4">
<detids>36-47</detids>
</group>
<group ID="5">
<detids>48-59</detids>
</group>
<group ID="6">
<detids>60-71</detids>
</group>
</detector-grouping>
59 changes: 59 additions & 0 deletions tests/resources/ultralite/CRACKLELiteDataMap.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0"?>
<detector-grouping idf-date="2018-05-01T00:00:01" instrument="fakeSNAP">
<!-- EAST -->
<group ID="1">
<detids>0,1,2,3</detids>
</group>
<group ID="2">
<detids>4,5,6,7</detids>
</group>
<group ID="3">
<detids>8,9,10,11</detids>
</group>
<group ID="4">
<detids>12,13,14,15</detids>
</group>
<group ID="5">
<detids>16,17,18,19</detids>
</group>
<group ID="6">
<detids>20,21,22,23</detids>
</group>
<group ID="7">
<detids>24,25,26,27</detids>
</group>
<group ID="8">
<detids>28,29,30,31</detids>
</group>
<group ID="9">
<detids>32,33,34,35</detids>
</group>
<!-- EAST -->
<group ID="10">
<detids>36,37,38,39</detids>
</group>
<group ID="11">
<detids>40,41,42,43</detids>
</group>
<group ID="12">
<detids>44,45,46,47</detids>
</group>
<group ID="13">
<detids>48,49,50,51</detids>
</group>
<group ID="14">
<detids>52,53,54,55</detids>
</group>
<group ID="15">
<detids>56,57,58,59</detids>
</group>
<group ID="16">
<detids>60,61,62,63</detids>
</group>
<group ID="17">
<detids>64,65,66,67</detids>
</group>
<group ID="18">
<detids>68,69,70,71</detids>
</group>
</detector-grouping>
Loading
Loading