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(api): Monitor PAPI commands, not PE commands #13724

Merged
merged 6 commits into from
Oct 10, 2023

Conversation

SyntaxColoring
Copy link
Contributor

@SyntaxColoring SyntaxColoring commented Oct 4, 2023

Overview

Closes RSS-320 for Python protocols (but not for JSON protocols). Also moves us towards other things in RSS-318.

Test Plan

No manual tests needed. This is covered by unit tests now, and it's going to be covered by other manual tests as work continues on RSS-318.

If you do test it manually, note that there's at least one unrelated bug that causes the run log text to be wrong: RSS-368.

Changelog

#13629 added a mechanism to monitor the progress of Protocol Engine commands. It turns out that that isn't a great approach for RSS-318.

When opentrons_simulate and opentrons_execute print commands, we want them to preserve the structure of the original protocol file: transfers contain aspirates and dispenses, and so on. If we only see a flat sequence of Protocol Engine commands, we lose that structure.

Also, we don't have any mechanism right now for converting raw Protocol Engine commands into human-readable strings. That's RSS-368, and we will probably need it for JSON protocols, but we would prefer to not have to deal with it to get opentrons_simulate to work for Python protocols again.

So, instead, we go back to how things worked in our olden RPC times. Instead of a flat sequence of Protocol Engine commands, opentrons_simulate and opentrons_execute will see a nested sequence of Python Protocol API commands.

Specifically, we:

Review requests

Is this a good approach, architecturally?

Risk assessment

Low, but there is a tradeoff going forward.

Although these messages give us human readability by default, they are not exhaustive by default. ProtocolContext, InstrumentContext, and ModuleContext need to explicitly publish activity that they want to print. We will need to make sure they do this for the new commands like move_labware(). Let's track that as RSS-377.

This partially reverts commit 24eb3c1 ("fix(api): New protocols print a JSON "run log" from opentrons_execute and opentrons.execute.execute()  (#13629)").
@SyntaxColoring SyntaxColoring added api Affects the `api` project protocol-engine Ticket related to the Protocol Engine project and associated HTTP APIs labels Oct 4, 2023
@SyntaxColoring SyntaxColoring requested a review from a team October 4, 2023 20:54
@SyntaxColoring SyntaxColoring requested a review from a team as a code owner October 4, 2023 20:54
Resolve conflicts in api/src/opentrons/protocol_engine/state/state.py.
@codecov
Copy link

codecov bot commented Oct 4, 2023

Codecov Report

Merging #13724 (886685d) into chore_release-7.0.1 (4443204) will not change coverage.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##           chore_release-7.0.1   #13724   +/-   ##
====================================================
  Coverage                71.26%   71.26%           
====================================================
  Files                     2427     2427           
  Lines                    68300    68300           
  Branches                  8000     8000           
====================================================
  Hits                     48676    48676           
  Misses                   17743    17743           
  Partials                  1881     1881           
Flag Coverage Δ
app 68.83% <ø> (ø)
g-code-testing 96.44% <ø> (ø)
notify-server 89.13% <ø> (ø)
protocol-designer 46.09% <ø> (ø)
step-generation 86.82% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
api/src/opentrons/execute.py 54.09% <ø> (ø)
...i/src/opentrons/protocol_engine/protocol_engine.py 100.00% <ø> (ø)
...opentrons/protocol_engine/state/change_notifier.py 100.00% <ø> (ø)
...pi/src/opentrons/protocol_engine/state/commands.py 99.45% <ø> (ø)
api/src/opentrons/protocol_engine/state/state.py 100.00% <ø> (ø)
...i/src/opentrons/protocol_runner/protocol_runner.py 100.00% <ø> (ø)

Copy link
Contributor

@CaseyBatten CaseyBatten left a comment

Choose a reason for hiding this comment

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

This looks good, local tests all pass as well. One comment to note for the future of this and things related to it, app team seems interested in the notion of "generic annotations" inside PE going forward (so wrapping multiple aspirations under a parent transfer command at the highest level of the log and only having the individual aspirates appear once you looked into the log contents of that transfer, if my understanding is correct). So long as this supports that kind of "readability" change in the future I see no reason why, architecturally, this wouldn't be acceptable.

@SyntaxColoring SyntaxColoring merged commit 47d486c into chore_release-7.0.1 Oct 10, 2023
38 of 39 checks passed
@SyntaxColoring SyntaxColoring deleted the move_broker_to_runner branch October 10, 2023 16:07
SyntaxColoring added a commit that referenced this pull request Oct 19, 2023
* Remove broker from ProtocolEngine.

This partially reverts commit 24eb3c1 ("fix(api): New protocols print a JSON "run log" from opentrons_execute and opentrons.execute.execute()  (#13629)").

* Add broker to ProtocolRunner.

* Update execute.py.

* Update test_execute.py.

* Further deduplicate test_execute.py.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Affects the `api` project protocol-engine Ticket related to the Protocol Engine project and associated HTTP APIs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants