Skip to content

Commit e8b00fa

Browse files
authored
write correct calibrant to norm record and then use it in reduction (#448)
* write correct calibrant to norm record and then use it in reduction * update tests
1 parent 71eccc3 commit e8b00fa

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

src/snapred/backend/dao/normalization/NormalizationRecord.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class NormalizationRecord(BaseModel):
2828
workspaceNames: List[WorkspaceName] = []
2929
version: int = Config["instrument.startingVersionNumber"]
3030
crystalDBounds: Limit[float]
31+
normalizationCalibrantSamplePath: str
3132

3233
@field_validator("runNumber", "backgroundRunNumber", mode="before")
3334
@classmethod

src/snapred/backend/service/NormalizationService.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def normalizationAssessment(self, request: NormalizationRequest):
169169
peakIntensityThreshold=request.peakIntensityThreshold,
170170
backgroundRunNumber=request.backgroundRunNumber,
171171
smoothingParameter=request.smoothingParameter,
172+
normalizationCalibrantSamplePath=request.calibrantSamplePath,
172173
calibration=calibration,
173174
crystalDBounds=request.crystalDBounds,
174175
)

src/snapred/backend/service/SousChef.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def prepReductionIngredients(
194194
)
195195
# grab information from records
196196
ingredients_ = ingredients.model_copy()
197-
ingredients_.calibrantSamplePath = calibrationRecord.calibrationFittingIngredients.calibrantSamplePath
197+
ingredients_.calibrantSamplePath = normalizationRecord.normalizationCalibrantSamplePath
198198
ingredients_.cifPath = self.dataFactoryService.getCifFilePath(Path(ingredients_.calibrantSamplePath).stem)
199199
ingredients_.peakIntensityThreshold = normalizationRecord.peakIntensityThreshold
200200
return ReductionIngredients(

tests/resources/inputs/normalization/NormalizationRecord.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"backgroundRunNumber": 58813,
55
"smoothingParameter": 0.5,
66
"peakIntensityThreshold": 0.05,
7+
"normalizationCalibrantSamplePath": "/path/to/sample",
78
"calibration":{
89
"instrumentState": {
910
"id": "ab8704b0bc2a2342",

tests/unit/backend/service/test_SousChef.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,18 @@ def test_prepDetectorPeaks_cache(self, DetectorPeakPredictorRecipe):
324324

325325
@mock.patch(thisService + "ReductionIngredients")
326326
def test_prepReductionIngredients(self, ReductionIngredients):
327-
record = mock.Mock(
328-
smoothingParamter=1.0,
329-
calibrationFittingIngredients=mock.Mock(calibrantSamplePath="a/b.x"),
327+
calibrationRecord = mock.Mock()
328+
normalizationRecord = mock.Mock(
329+
smoothingParameter=1.0,
330+
normalizationCalibrantSamplePath="a/b.x",
330331
)
331332
self.instance.prepRunConfig = mock.Mock()
332333
self.instance.prepManyPixelGroups = mock.Mock()
333334
self.instance.prepManyDetectorPeaks = mock.Mock()
334335
self.instance.dataFactoryService.getCifFilePath = mock.Mock()
335336
self.instance.dataFactoryService.getReductionState = mock.Mock()
336-
self.instance.dataFactoryService.getNormalizationRecord = mock.Mock(return_value=record)
337-
self.instance.dataFactoryService.getCalibrationRecord = mock.Mock(return_value=record)
337+
self.instance.dataFactoryService.getNormalizationRecord = mock.Mock(return_value=normalizationRecord)
338+
self.instance.dataFactoryService.getCalibrationRecord = mock.Mock(return_value=calibrationRecord)
338339

339340
res = self.instance.prepReductionIngredients(self.ingredients)
340341

@@ -343,7 +344,7 @@ def test_prepReductionIngredients(self, ReductionIngredients):
343344
assert ReductionIngredients.called_once_with(
344345
maskList=[],
345346
pixelGroups=self.instance.prepManyPixelGroups.return_value,
346-
smoothingParameter=record.smoothingParameter,
347+
smoothingParameter=normalizationRecord.smoothingParameter,
347348
detectorPeaksMany=self.instance.prepManyDetectorPeaks.return_value,
348349
)
349350
assert res == ReductionIngredients.return_value

0 commit comments

Comments
 (0)