-
Notifications
You must be signed in to change notification settings - Fork 179
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
fix(api): make frontRightNozzle and backLeftNozzle required for Quadrant config #16025
fix(api): make frontRightNozzle and backLeftNozzle required for Quadrant config #16025
Conversation
…, added more errors to configure_nozzle_layout, updated and added tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
I think we could have gotten away with changing the command schema if you wanted, but I don't think that approach would have been any better than this one. And I'm certainly glad to make the Protocol Engine API stricter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These fixes and slight refactors look great, and nicely cleaned up our growing nozzle layout api method. Thanks Sanniti!
if any([end, front_right, back_left]): | ||
raise ValueError( | ||
f"Parameters 'end', 'front_right' and 'back_left' cannot be used with " | ||
f"the {style.name} nozzle configuration." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New addition to this existing check- including 'end' in this validation
def _raise_if_has_end_nozzle_for_quadrant(end: Optional[str]) -> None: | ||
if end is not None: | ||
raise ValueError( | ||
"Parameter 'end' is not supported for QUADRANT configuration." | ||
" Use 'front_right' and 'back_left' arguments to specify the quadrant nozzle map instead." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New validation check
frontRightNozzle: str = Field( | ||
..., | ||
regex=NOZZLE_NAME_REGEX, | ||
description="The front right nozzle in your configuration.", | ||
) | ||
backLeftNozzle: Optional[str] = Field( | ||
backLeftNozzle: str = Field( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixes RQA-2992
decoy.verify( | ||
mock_instrument_core.configure_nozzle_layout( | ||
style=nozzle_layout_args.style, | ||
primary_nozzle=expected_core_args.primary_nozzle, | ||
front_right_nozzle=expected_core_args.front_right_nozzle, | ||
back_left_nozzle=expected_core_args.back_left_nozzle, | ||
) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test to make sure PARTIAL_COLUMN (the only publicly available configuration that uses Quadrant config) always populates the front_right_nozzle
and back_left_nozzle
back_left_resolved = validated_end | ||
front_right_resolved = validated_start | ||
elif start == "A1" or start == "A12": | ||
if "H" in end: | ||
raise ValueError( | ||
f"A partial column configuration with 'start'={start} cannot have its 'end' parameter be in row H. Use `ALL` configuration to utilize all nozzles." | ||
) | ||
front_right_resolved = end | ||
|
||
if style == NozzleLayout.QUADRANT: | ||
if front_right is None and back_left is None: | ||
raise ValueError( | ||
"Cannot configure a QUADRANT layout without a front right or back left nozzle." | ||
) | ||
elif not (front_right is None and back_left is None): | ||
raise ValueError( | ||
f"Parameters 'front_right' and 'back_left' cannot be used with a {style.value} nozzle configuration." | ||
front_right_resolved = validated_end | ||
back_left_resolved = validated_start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both front_right and back_left will be resolved now
if front_right is None: | ||
front_right_resolved = validated_start | ||
elif back_left is None: | ||
back_left_resolved = validated_start |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same- Both front_right and back_left will be resolved now
Closes RQA-2992
Overview
The
QuadrantNozzleLayoutConfiguration
has two optional fields-frontRightNozzle
andbackLeftNozzle
, but they didn't have a default value assigned. So when the app tried to fetch the run's data by sending aGET /runs/{run_id}/commands/
request, if theconfigureNozzleLayout
command was saved as the following valid command in the database-..then pydantic ran into a validation error since it didn't know how to parse
configurationParams
with a missingfrontRightNozzle
.This was resulting in the 'Download Run Log' option to give a 500 error, which this PR fixes by making the fields no longer optional.
Changelog
We could have made the default values
None
but that would require a change in the command schema. So in order to not change the schema, and also make the API a bit more strict while doing it, we decided to make the fields non-optional.This PR makes this change and updates the
configure_nozzle_layout
API method so that a Quadrant configuration (used by the API-sidePARTIAL_COLUMN
&QUADRANT
configurations) will always set itsfront_right
&back_left
nozzles.While making this change, I discovered a missing check on the
end
param- that it should be only allowed forPARTIAL_COLUMN
configuration. While adding that I ended up refactoring the validation check since it was bloating up even further.Similarly, adding more test cases was making the tests quite wordy and taking up a lot of space in the 1k+ lines file. So I moved all the partial tip test setup stuff to its own file and added more test cases
Test Plan and Hands on Testing
Protocol for testing:
Review requests
configure_nozzle_layout
Risk assessment
Low. A bug fix and mostly refactoring of rest of the code.