-
Notifications
You must be signed in to change notification settings - Fork 176
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
refactor(api, robot-server): move feature flag file access outside of hardware_control #13963
refactor(api, robot-server): move feature flag file access outside of hardware_control #13963
Conversation
…trol instantiators are responsible for passing them in
…are-code # Conflicts: # api/src/opentrons/hardware_control/ot3api.py
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## edge #13963 +/- ##
==========================================
- Coverage 70.59% 70.49% -0.11%
==========================================
Files 2506 2507 +1
Lines 71081 71083 +2
Branches 8907 8916 +9
==========================================
- Hits 50179 50108 -71
- Misses 18723 18790 +67
- Partials 2179 2185 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
I think unfortunately we need to not build function argument defaults like this but other than that looks great!
@@ -111,6 +112,7 @@ def __init__( | |||
backend: Union[Controller, Simulator], | |||
loop: asyncio.AbstractEventLoop, | |||
config: RobotConfig, | |||
feature_flags: HardwareFeatureFlags = HardwareFeatureFlags(), |
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.
this probably wants to be Optional[HardwareFeatureFlags] = None
because this code will create one default HardwareFeatureFlags()
at function parse time that will be reused lol
@@ -170,6 +173,7 @@ async def build_hardware_controller( | |||
port: Optional[str] = None, | |||
loop: Optional[asyncio.AbstractEventLoop] = None, | |||
firmware: Optional[Tuple[pathlib.Path, str]] = None, | |||
feature_flags: HardwareFeatureFlags = HardwareFeatureFlags(), |
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.
ditto here
@@ -249,6 +258,7 @@ async def build_hardware_simulator( | |||
config: Optional[Union[RobotConfig, OT3Config]] = None, | |||
loop: Optional[asyncio.AbstractEventLoop] = None, | |||
strict_attached_instruments: bool = True, | |||
feature_flags: HardwareFeatureFlags = HardwareFeatureFlags(), |
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.
ditto here
config: OT3Config, | ||
use_usb_bus: bool = False, | ||
check_updates: bool = True, | ||
feature_flags: HardwareFeatureFlags = HardwareFeatureFlags(), |
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.
ditto here
@@ -274,6 +283,7 @@ def __init__( | |||
usb_driver: Optional[SerialUsbDriver] = None, | |||
eeprom_driver: Optional[EEPROMDriver] = None, | |||
check_updates: bool = True, | |||
feature_flags: HardwareFeatureFlags = HardwareFeatureFlags(), |
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.
ditto here
@hardware_feature_flags.setter | ||
def hardware_feature_flags(self, feature_flags: HardwareFeatureFlags) -> None: | ||
self._feature_flags = feature_flags | ||
if isinstance(self._backend, OT3Controller): |
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.
let's just do it for the simulator too
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.
Looks good though I feel like we might want a note about the no-arguments constructor wanting to be where default-true arguments are or something
Overview
As a part of the long-term goal of the hardware controller process split, we need to address simultaneous access & modification of the feature flags file on a robot. This PR takes out any parts of the
hardware_control
submodule in theopentrons
package that directly access the feature flags file, replacing them with a dataclass that just gets populated by the caller of the factory functions. This gets used to dictate whether the pipette handlers use the new or old aspiration functions, as well as a few Flex-specific hardware functions.Test Plan
To verify that the settings are being updated in the API correctly, I pushed on a robot, used HTTP to change the advanced setting requiring the estop, and disconnected the estop to ensure that no error popped up.
CI tests should cover that the settings are still being set/read the right way.
Ran the REPL on a robot and changed some settings in
feature_flags.json
to ensure they are reflected in the constructed API.Changelog
Review requests
I don't like this interface but I don't see an elegant alternative. Injecting into the robot configs seems inappropriate imo. Any strong opinion on an alternative approach is appreciated.
Risk assessment
Medium, mostly if I missed any hardware API initializers somewhere in the repo.