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

feat(api): add liquid class in PAPI #16506

Merged
merged 13 commits into from
Oct 17, 2024
Merged

Conversation

sanni-t
Copy link
Member

@sanni-t sanni-t commented Oct 17, 2024

AUTH-835, AUTH-836

Overview

Adds LiquidClass class and ProtocolContext.define_liquid_class() to PAPI. Also adds an allowLiquidClasses feature flag that will need to be set to True in order to use the new API method.

Test Plan and Hands on Testing

I think the integration and unit tests in the PR are good enough for this work. This PR doesn't add the ability to actually use the liquid class in any way other than fetching values of the class so there isn't anything to be tested on a robot.

Changelog

  • added LiquidClass dataclass to PAPI
  • added ProtocolContext.define_liquid_class to define a liquid class in the protocol
  • added allowLiquidClasses internal feature flag

Some small schema changes:

  • changed liquidName -> liquidClassName and made it a safestring
  • added a displayName
  • changed tipType -> tiprack

Misc shared data changes:

  • added liquid_classes.load_definition()
  • added validation tests for liquid class definitions

Review requests

  • does the LiquidClass structure make sense?
    • background on the structure- keeping all dataclass attributes private and defining properties and setters explicitly allows us to restrict access to attributes that shouldn't change, while giving us a way to validate the properties before they are set/updated by the user.
  • any naming improvements? I am not fully satisfied with the 'tiprack' property in the liquid class schema name when the parent classification says byTipType. But byTiprackType also didn't feel correct. So looking for suggestions for improvement or reassurance that it's fine the way it is.

Risk assessment

Low. Doesn't affect anything existing, and is behind a feature flag.



class LiquidClassDefinitionDoesNotExist(Exception):
"""Specified liquid class' definition does not exist."""
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this has to be possessive.

Suggested change
"""Specified liquid class' definition does not exist."""
"""Specified liquid class definition does not exist."""

# Calling this often will degrade protocol execution performance.
liquid_class_def = liquid_classes.load_definition(name)
self._defined_liquid_class_defs_by_name[name] = liquid_class_def
except KeyError:
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldnt this be LiquidClassDefinitionDoesNotExist and not KeyError?

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch

@sanni-t sanni-t marked this pull request as ready for review October 17, 2024 19:25
@sanni-t sanni-t requested review from a team as code owners October 17, 2024 19:25
Copy link
Contributor

@jbleon95 jbleon95 left a comment

Choose a reason for hiding this comment

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

Looks good, small nitpick but otherwise 👍

def get_for(self, pipette: str, tiprack: str) -> TransferProperties:
"""Get liquid class transfer properties for the specified pipette and tip."""
settings_for_pipette: Sequence[ByPipetteSetting] = list(
filter(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is more of a style preference, but I much prefer having list comprehensions here rather than lambda expressions. Not only are they more efficient (no list call and function calls), I find them easier to read.

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Do we need a feature flaG? can we just hold it out of docs?

@sanni-t
Copy link
Member Author

sanni-t commented Oct 17, 2024

Do we need a feature flaG? can we just hold it out of docs?

I feel like feature flags, with the 'internal use' warning, set clear expectations that this code is not built for external use and can/will change without notice or version change.

Do you think it's not a good idea?

@sfoster1
Copy link
Member

Do we need a feature flaG? can we just hold it out of docs?

I feel like feature flags, with the 'internal use' warning, set clear expectations that this code is not built for external use and can/will change without notice or version change.

Do you think it's not a good idea?

I think it's fine. I just think it can be hard to do if one of the things you want it to control is like, "added a new entry to an enum", but for this it def works

@sanni-t sanni-t merged commit 8e3662f into edge Oct 17, 2024
54 checks passed
TamarZanzouri pushed a commit that referenced this pull request Oct 18, 2024
AUTH-835, AUTH-836

# Overview

Adds `LiquidClass` class and `ProtocolContext.define_liquid_class()` to
PAPI. Also adds an `allowLiquidClasses` feature flag that will need to
be set to True in order to use the new API method.

## Changelog

- added `LiquidClass` dataclass to PAPI
- added `ProtocolContext.define_liquid_class` to define a liquid class
in the protocol
- added `allowLiquidClasses` internal feature flag

Some small schema changes:
- changed `liquidName` -> `liquidClassName` and made it a `safestring`
- added a `displayName`
- changed `tipType` -> tiprack

Misc shared data changes:
- added `liquid_classes.load_definition()`
- added validation tests for liquid class definitions
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.

4 participants