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

Add Grocery keyset for increased safety calling Recipe #528

Merged
merged 2 commits into from
Jan 21, 2025

Conversation

rboston628
Copy link
Contributor

@rboston628 rboston628 commented Jan 9, 2025

Description of work

Groceries are passed as a grocery, where the key roughly corresponds to a mantid WorkspaceProperty, and where the value is the name of a workspace.

The Recipe ABC already had a method mandatoryInputWorkspaces, which was a set of workspaces which had to be given and had to exist in the ADS.

However, for optional workspaces, it was possible a user could pass an option workspace with an incorrect key, and it would not set that workspace.

This was a problem in Defect 8554, where the ReductionService was passing a mask workspace with the key "combinedPixelMask", but ReductionRecipe was accessing the mask by the key "combinedMask", meaning the mask was not being set.

This is fixed by also including a method allGroceryKeys, which ensures the groceries dictionary only has keys from that set.

Explanation of work

Inside the Recipe ABC, there is a new method allGroceryKeys which returns the set of all possible keys that might be passed to this recipe. If the groceries contain a key not in this set, then an error is produced.

Several workspaces inheriting from Recipe were refactored to implement this method. Some tests also had to be changed to accommodate the new behavior with workspace keys.

The ReductionRecipe required additional work because of its _applyRecipe method. This created a conflict, as the self.groceries dictionary was being passed, which included all of the workspaces needed for reduction, but which are not needed for this the sub-recipes. This was reworked to not rely on the self.groceries dictionary, and instead requires all input workspaces to be used, be passed as keyword arguments.

@ekapadi noticed similar problems and also implemented some changes to this part of ReductionRecipe. Hopefully our changes are compatible.

To test

Dev testing

Run all three workflows by hand to saving.

CIS testing

N/A

Link to EWM item

EWM#8554

Verification

  • the author has read the EWM story and acceptance critera
  • the reviewer has read the EWM story and acceptance criteria
  • the reviewer certifies the acceptance criteria below reflect the criteria in EWM

Acceptance Criteria

This list is for ease of reference, and does not replace reading the EWM story as part of the review. Verify this list matches the EWM story before reviewing.

The simple fix to the defect was implemented in PR #526 . This PR implements the enhanced validation mentioned in the story.

  • the Recipe ABC implements better validation of groceries
  • the ReductionService calls the ReductionRecipe with the correct key for the combined pixel mask

@rboston628
Copy link
Contributor Author

Merge AFTER PR #526

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 85.88235% with 12 lines in your changes missing coverage. Please review.

Project coverage is 95.96%. Comparing base (2eccb68) to head (487ab7f).
Report is 1 commits behind head on next.

Files with missing lines Patch % Lines
...d/backend/recipe/CalculateDiffCalResidualRecipe.py 50.00% 11 Missing ⚠️
src/snapred/backend/recipe/Recipe.py 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             next     #528      +/-   ##
==========================================
+ Coverage   95.80%   95.96%   +0.16%     
==========================================
  Files          68       68              
  Lines        5105     5134      +29     
==========================================
+ Hits         4891     4927      +36     
+ Misses        214      207       -7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rboston628 rboston628 marked this pull request as ready for review January 10, 2025 20:50
@rboston628 rboston628 force-pushed the ewm8554-reduction-mask branch from 49b70cc to 230af8c Compare January 10, 2025 21:49
@rboston628 rboston628 force-pushed the ewm8554-reduction-mask branch from 230af8c to 2507336 Compare January 10, 2025 21:59
@rboston628
Copy link
Contributor Author

The recipe CalculateDiffcalResidualRecipe did not formerly have a unit test for it. Creating one is outside the scope of this PR, but I did add some minimal number of tests.

@@ -247,8 +247,8 @@ constants:
highdSpacingCrop: 0.15

RawVanadiumCorrection:
numberOfSlices: 10
numberOfAnnuli: 10
numberOfSlices: 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these changed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the tests, it's the difference between running in 1 second vs running in 1 minute

@walshmm
Copy link
Collaborator

walshmm commented Jan 21, 2025

could you also add these AC and rationale to the story since this is more of a refactor?

@rboston628
Copy link
Contributor Author

could you also add these AC and rationale to the story since this is more of a refactor?

Defects can't have AC, but I added something to to description.

@walshmm
Copy link
Collaborator

walshmm commented Jan 21, 2025

performed some basic calibration, normalization, and reduction and didnt run into any regression issues.
Reviewed the code, I approve these changes.

@rboston628 rboston628 merged commit 7e89030 into next Jan 21, 2025
7 of 8 checks passed
@rboston628 rboston628 deleted the ewm8554-reduction-mask branch January 21, 2025 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants