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

refactor(robot-server,api): wire up JSON protocol runner to /sessions #7935

Merged
merged 5 commits into from
Jun 14, 2021

Conversation

mcous
Copy link
Contributor

@mcous mcous commented Jun 11, 2021

Overview

This PR gets us pretty close to #7808.

  • You can create a protocol session from an uploaded JSON protocol file
  • On session creation, a JSON protocol runner is created and loads the protocol state into a Protocol Engine
  • You can issue a start action to kick off the run

There's still a few items to address before I think 7808 can be considered complete, but we're almost there!

Changelog

  • Implement a basic version of ProtocolEngine::add_command
  • Create ProtocolSession response model type(s)
  • Allow the EngineStore to create and load an AbtractFileRunner if needed

Review requests

Postman testing collections here

  1. POST /protocols with a JSON protocol
    • I took the protocol at shared-data/protocol/fixtures/5/simpleV5.json and stripped out all the commands that CommandTranslator doesn't know about
  2. POST /sessions with sessionType: "protocol" and createParams: { protocolId: "{{ protocol_id }}" }
  3. POST /sessions/{{ session_id }}/actions with actionType: "start"

Risk assessment

Low. Feature-flagged endpoints.

@mcous mcous added robot-svcs Falls under the purview of the Robot Services squad (formerly CPX, Core Platform Experience). protocol-engine Ticket related to the Protocol Engine project and associated HTTP APIs labels Jun 11, 2021
@mcous mcous requested a review from a team as a code owner June 11, 2021 18:47
@codecov
Copy link

codecov bot commented Jun 11, 2021

Codecov Report

Merging #7935 (7d58098) into edge (875e86a) will decrease coverage by 9.62%.
The diff coverage is 95.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge    #7935      +/-   ##
==========================================
- Coverage   93.48%   83.86%   -9.63%     
==========================================
  Files         130      352     +222     
  Lines        5141    21730   +16589     
==========================================
+ Hits         4806    18223   +13417     
- Misses        335     3507    +3172     
Impacted Files Coverage Δ
robot-server/robot_server/sessions/session_view.py 95.65% <66.66%> (+0.41%) ⬆️
robot-server/robot_server/sessions/engine_store.py 97.36% <93.33%> (-2.64%) ⬇️
robot-server/robot_server/protocols/__init__.py 100.00% <100.00%> (ø)
...obot-server/robot_server/sessions/action_models.py 100.00% <100.00%> (ø)
robot-server/robot_server/sessions/router.py 100.00% <100.00%> (+3.27%) ⬆️
...bot-server/robot_server/sessions/session_models.py 100.00% <100.00%> (ø)
opentrons/commands/protocol_commands.py 94.73% <0.00%> (ø)
opentrons/api/util.py 92.59% <0.00%> (ø)
opentrons/protocol_api_experimental/labware.py 81.53% <0.00%> (ø)
opentrons/hardware_control/simulator_setup.py 97.91% <0.00%> (ø)
... and 218 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 875e86a...7d58098. Read the comment docs.

@mcous mcous requested review from a team, X-sam, celsasser, sanni-t and SyntaxColoring and removed request for a team, X-sam and celsasser June 11, 2021 18:50
robot-server/robot_server/sessions/router.py Outdated Show resolved Hide resolved
protocol = None

if isinstance(create_data, ProtocolSessionCreateData):
protocol = protocol_store.get(protocol_id=create_data.createParams.protocolId)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This may raise a ProtocolNotFound (or something) error from the ProtocolStore and needs to map to a 404

robot-server/robot_server/sessions/session_models.py Outdated Show resolved Hide resolved
robot-server/robot_server/sessions/session_models.py Outdated Show resolved Hide resolved
Copy link
Contributor

@SyntaxColoring SyntaxColoring left a comment

Choose a reason for hiding this comment

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

Paired and reviewed in a call. Looks good to me, assuming CI passes. 🦜 🕺

@mcous mcous merged commit 77685a5 into edge Jun 14, 2021
@mcous mcous deleted the robot-server_run-json-protocol branch June 14, 2021 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
protocol-engine Ticket related to the Protocol Engine project and associated HTTP APIs robot-svcs Falls under the purview of the Robot Services squad (formerly CPX, Core Platform Experience).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants