-
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
refactor(app): load modules to retrieve moduleId for run setup module controls #10451
Conversation
… controls This PR loads the modules in the protocol and then retrieves the moduleId from the protocol analysis and feeds it to the corresponding createCommand for each module action.
Codecov Report
@@ Coverage Diff @@
## edge #10451 +/- ##
==========================================
- Coverage 73.81% 73.65% -0.17%
==========================================
Files 2138 2136 -2
Lines 57468 57464 -4
Branches 5780 5807 +27
==========================================
- Hits 42422 42325 -97
- Misses 13836 13919 +83
- Partials 1210 1220 +10
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.
The logic in here looks great and works as expected. Thanks so much for tackling this monstrous task.
const filteredModules = attachedModules.filter( | ||
item => | ||
item.moduleModel === module.moduleModel || | ||
compatibleWith.includes(item.moduleModel) |
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.
how come we have to check compatibleWith
? i.e. if there is a temp module v1 and a temp module v2, they should be treated as two different modules right?
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.
We have to check compatible with, because we need to have an array of all of the modules that the robot server would use as candidates to match with the specced module. That way we can pair the load index with the usb index. This is a (currently necessary) duplication of logic on the backend.
const moduleIndex = filteredModules.findIndex( | ||
attachedModule => attachedModule.serialNumber === module.serialNumber | ||
) | ||
|
||
const moduleIdFromRun = loadModuleCommands?.[moduleIndex].result.moduleId | ||
|
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 wonder if we should have some null check safety here, in the event someone unplugs a module or something. if for some reason loadModuleCommands?.[moduleIndex]
is undefined
, this would white screen
const loadCommands: LoadModuleRunTimeCommand[] = protocolData?.commands.filter( | ||
command => command.commandType === 'loadModule' | ||
) as LoadModuleRunTimeCommand[] |
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.
instead of using an as
cast, you can use a type predicate:
const loadCommands: LoadModuleRunTimeCommand[] = protocolData?.commands.filter(
(command: RunTimeCommand): command is LoadModuleRunTimeCommand =>
command.commandType === 'loadModule'
)
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.
Tested on Robot and works as expected. The fix looks good!
Overview
This PR loads the modules in the protocol when the module control tab in the run setup page is visited. It retrieves the moduleId from the protocol analysis and feeds it to the corresponding createCommand for each module action pertaining to the run. When there is a
runId
present (during an active run) the module commands shouldPOST
commands to the/runs/:id/commands
end point.paired with @shlokamin @jerader
Changelog
useModuleIdFromRun
to retrieve the correct moduleId from protocol analysis.ProtocolRunModuleControls
to issue the necessaryloadModule
commands.Review requests
Upload a protocol with modules. Then visit the
Module Controls
tab in the setup page. Using the module dropdown menus and slideouts, issue commands (e.g. set temperature module to 45 degrees, then deactivate it). Check that when sending these request they are sendingPOST
requests to the/runs/:id/commands
end point.Remove the protocol above and un-current the run. With a fresh slate, visit the device details page where all the module cards are listed. Perform the same commands/actions performed previously in the run detail page. This time check that the commands are sending
POST
requests to the/commands
end point.Note: Due to a polling issue currently, anytime you issue a command you will have to refresh the page. You can also open a menu and close it which will re-render the component quickly.
Risk assessment
low, only adds ability to send requests to alternative end point when
runId
is present