-
Notifications
You must be signed in to change notification settings - Fork 178
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
chore(api): allow specifying module models to sim #15104
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,8 @@ | |
|
||
mod_log = logging.getLogger(__name__) | ||
|
||
AttachedModuleSpec = Dict[str, List[Union[str, Tuple[str, str]]]] | ||
|
||
|
||
class API( | ||
ExecutionManagerProvider, | ||
|
@@ -255,7 +257,7 @@ async def build_hardware_simulator( | |
attached_instruments: Optional[ | ||
Dict[top_types.Mount, Dict[str, Optional[str]]] | ||
] = None, | ||
attached_modules: Optional[Dict[str, List[str]]] = None, | ||
attached_modules: Optional[Dict[str, List[modules.SimulatingModule]]] = None, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Much better 😀 |
||
config: Optional[Union[RobotConfig, OT3Config]] = None, | ||
loop: Optional[asyncio.AbstractEventLoop] = None, | ||
strict_attached_instruments: bool = True, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,7 +49,7 @@ class Simulator: | |
async def build( | ||
cls, | ||
attached_instruments: Dict[types.Mount, Dict[str, Optional[str]]], | ||
attached_modules: Dict[str, List[str]], | ||
attached_modules: Dict[str, List[modules.SimulatingModule]], | ||
config: RobotConfig, | ||
loop: asyncio.AbstractEventLoop, | ||
strict_attached_instruments: bool = True, | ||
|
@@ -71,8 +71,9 @@ async def build( | |
This dict should map mounts to either | ||
empty dicts or to dicts containing | ||
'model' and 'id' keys. | ||
:param attached_modules: A list of module model names (e.g. | ||
`'tempdeck'` or `'magdeck'`) representing | ||
:param attached_modules: A map of module type names (e.g. | ||
`'tempdeck'` or `'magdeck'`) to lists of (serial, model) | ||
tuples representing | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not tuples anymore |
||
modules the simulator should assume are | ||
attached. Like `attached_instruments`, used | ||
to make the simulator match the setup of the | ||
|
@@ -105,7 +106,7 @@ async def build( | |
def __init__( | ||
self, | ||
attached_instruments: Dict[types.Mount, Dict[str, Optional[str]]], | ||
attached_modules: Dict[str, List[str]], | ||
attached_modules: Dict[str, List[modules.SimulatingModule]], | ||
config: RobotConfig, | ||
loop: asyncio.AbstractEventLoop, | ||
gpio_chardev: GPIODriverLike, | ||
|
@@ -333,13 +334,14 @@ def set_active_current(self, axis_currents: Dict[Axis, float]) -> None: | |
@ensure_yield | ||
async def watch(self) -> None: | ||
new_mods_at_ports = [] | ||
for mod, serials in self._stubbed_attached_modules.items(): | ||
for serial in serials: | ||
for mod_name, list_of_modules in self._stubbed_attached_modules.items(): | ||
for module_details in list_of_modules: | ||
new_mods_at_ports.append( | ||
modules.SimulatingModuleAtPort( | ||
port=f"/dev/ot_module_sim_{mod}{str(serial)}", | ||
name=mod, | ||
serial_number=serial, | ||
port=f"/dev/ot_module_sim_{mod_name}{str(module_details.serial_number)}", | ||
name=mod_name, | ||
serial_number=module_details.serial_number, | ||
model=module_details.model, | ||
) | ||
) | ||
await self.module_controls.register_modules(new_mods_at_ports=new_mods_at_ports) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,8 +114,6 @@ def synchronizer(*args: Any, **kwargs: Any) -> Any: | |
def build_thread_manager() -> ThreadManager[Union[API, OT3API]]: | ||
return ThreadManager( | ||
API.build_hardware_controller, | ||
use_usb_bus=ff.rear_panel_integration(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mmm is this removal ok? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup! This was revealed by |
||
update_firmware=update_firmware, | ||
feature_flags=HardwareFeatureFlags.build_from_ff(), | ||
) | ||
|
||
|
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.
Just for me why do we need this type: ignore now? Looks like the code is the same?
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.
It's this bug in mypy where if you have
Generic
__init__
method that takes a typevarthen you get an error when you try to bind to it.