Skip to content

refactor(api): clean up liquid class transfer code #18882

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

Open
wants to merge 3 commits into
base: chore_release-pd-8.5.0
Choose a base branch
from

Conversation

jbleon95
Copy link
Contributor

@jbleon95 jbleon95 commented Jul 10, 2025

Overview

This PR has minor refactor work for the instrument core implementation of liquid class transfers (those being transfer, distribute and consolidate), mostly to reduce the amount of repeated code between the three functions. The areas refactored are:

  • Drop tip and pick up tip logic for liquid classes, which was the largest chunk of repeated code between the three and now exists within its own private function
  • Getting the transfer properties and resulting error handling, now in a private function
  • Getting the working volume given a tip rack labware core, this is not private though it has not been added to the instrument core interface
  • Getting the sources and/or destinations and volume splitting has been put behind another function that encapsulates the getting of properties and handling the difference between multi dispense and regular dispense

Test Plan and Hands on Testing

Pure refacotr only, so existing unit tests, integration tests and snapshot tests should cover any regression.

Changelog

  • Refactored instrument core liquid class transfer code to remove repeated code and encapsulate more elsewhere

Review requests

Do we agree with these refactors, in that they make the code easier to follow? Is there any other area we'd like to see refactored?

Risk assessment

Low, these changes are pretty straightforward and a diff checker was used to ensure that all code refactored was in fact the same.

@ddcc4 ddcc4 self-requested a review July 10, 2025 22:31
@jbleon95 jbleon95 marked this pull request as ready for review July 11, 2025 13:50
@jbleon95 jbleon95 requested a review from a team as a code owner July 11, 2025 13:50
pipette=self.get_pipette_name(), tip_rack=tip_rack_uri
)
except NoLiquidClassPropertyError:
if self._protocol_core.robot_type == "OT-2 Standard":
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would it be clearer to move this if robot_type == "OT-2 Standard" up above the try? Or do you always want to attempt the lookup even if it's an OT-2?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Wait, I guess you do always want to try, because PD generates a liquid class for the OT-2.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Although the error message is a bit misleading for the OT-2 then?

I.e., say we are on the OT-2, and the user has specified a custom liquid class for the pipette, but they gave the wrong name for the tiprack they're using. This function would fail with the error message Default liquid classes are not supported with OT-2 pipettes and tip racks, which is less helpful than the default message of No properties found for {tiprack_uri} for {pipette_name}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, yeah I see what you're saying. There's two things I wanted to accomplish with this error message (which was added in an earlier PR): make it clear that no OT-2 pipette and tip rack was supported by the default liquid classes (rather than saying a certain pipette and tip rack were unavailable, which many give someone the idea that other OT-2 combinations may be possible), while also allowing for it if the user added it in some way (editing json, PD, custom liquid classes, etc). But you're right in that the existing error message gets in the way of the second case if the user provides the wrong pipette/tip rack. I'm not sure what the right solution is. Maybe we raise a different error for a wrong tip rack when a pipette exists? Check if any OT-2 compatible pipettes and tip racks exist?

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