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): retrieve state of previous runs #8676

Merged
merged 2 commits into from
Nov 9, 2021

Conversation

mcous
Copy link
Contributor

@mcous mcous commented Nov 8, 2021

Overview

This PR allows a new run to be created after a previous run has stopped. It adds the current flag to the Run model, but leaves the rest of #8594 alone for a future PR (adding entry to links, allowing current: false to be patched).

Closes #8470

Changelog

  • refactor(runs): retrieve state of previous runs

Review requests

I've updated the Postman collection to hit /runs instead of /sessions

Happy path:

  1. Create a run
  2. Stop the run
  3. Create a new run

Things to ensure:

  • Cannot create a new run if current one is not stopped
  • Can create a new run after last one has stopped
  • New run is "current", old one is marked current: false
  • Cannot issue commands to non-current run
  • Cannot issue actions to non-current run

Risk assessment

Low. Feature flagged, on it's way to a beta release for full validation

@mcous mcous added the robot-svcs Falls under the purview of the Robot Services squad (formerly CPX, Core Platform Experience). label Nov 8, 2021
@mcous mcous requested a review from a team as a code owner November 8, 2021 22:55
@codecov
Copy link

codecov bot commented Nov 8, 2021

Codecov Report

Merging #8676 (85bba08) into edge (d616b17) will increase coverage by 0.01%.
The diff coverage is 95.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge    #8676      +/-   ##
==========================================
+ Coverage   74.76%   74.77%   +0.01%     
==========================================
  Files        1731     1731              
  Lines       46511    46538      +27     
  Branches     4666     4666              
==========================================
+ Hits        34775    34800      +25     
- Misses      10932    10934       +2     
  Partials      804      804              
Flag Coverage Δ
robot-server 93.45% <95.83%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
robot-server/robot_server/runs/run_view.py 96.00% <ø> (ø)
robot-server/robot_server/runs/engine_store.py 95.00% <85.71%> (-5.00%) ⬇️
...-server/robot_server/runs/router/actions_router.py 100.00% <100.00%> (ø)
...bot-server/robot_server/runs/router/base_router.py 100.00% <100.00%> (ø)
...server/robot_server/runs/router/commands_router.py 100.00% <100.00%> (ø)
robot-server/robot_server/runs/run_models.py 100.00% <100.00%> (ø)
robot-server/robot_server/runs/run_store.py 100.00% <100.00%> (ø)

@mcous mcous changed the title refactor(runs): retrieve state of previous runs refactor(robot-server): retrieve state of previous runs Nov 8, 2021
Copy link
Contributor

@b-cooper b-cooper left a comment

Choose a reason for hiding this comment

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

🐙

Comment on lines +87 to +88
if not self.engine.state_view.commands.get_is_stopped():
raise EngineConflictError("Current engine is not stopped.")
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm reading this right, if a run stops due to an internal error or failed Protocol Engine command, the client will still need to issue a stop action on it before attempting to create a new run. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The runner always stops the engine at the conclusion of the protocol file run, even if that run bails out early due to error. So this shouldn't be a problem

robot-server/robot_server/runs/router/actions_router.py Outdated Show resolved Hide resolved
except EngineMissingError:
pass
else:
if not engine_state.commands.get_is_stopped():
Copy link
Contributor

Choose a reason for hiding this comment

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

See prior comment about whether .get_is_stopped() is the right thing to check here.

Comment on lines 42 to 45
current: bool = Field(
...,
description="Whether this Run is currently controlling the robot",
)
Copy link
Contributor

@SyntaxColoring SyntaxColoring Nov 8, 2021

Choose a reason for hiding this comment

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

How about:

Whether this run is currently occupying the robot.

"Currently occupying the robot" means either:

  • This run is actively making the robot move.
  • This run is pending physical setup or teardown, with the user's help.

At any given time, there's at most one current run.

For me, an important part of the mental model of a run is that it doesn't represent robot control. It's represents some fuzzier, broader notion of what the user "is doing with" the robot. Still including robot control, but now also including physically setting up and tearing down the deck, and reviewing the run results.

Also, my understanding from App+UI is that they're relying on HTTP calibration sessions (under /sessions) being usable while a run is current, but not "active." In that case, I wouldn't say it's the run that's "currently controlling the robot."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For me, an important part of the mental model of a run is that it doesn't represent robot control. It's represents some fuzzier, broader notion of what the user "is doing with" the robot.

I don't think that distinction is worth the extra reading. If the run is both "current" and "finished", it still has "control" over the robot insofar as it contains the most accurate state representation available of what the robot physically looks like. No other run is allowed to move the robot, so it's still in "currently in control"

Also, my understanding from App+UI is that they're relying on HTTP calibration sessions (under /sessions) being usable while a run is current, but not "active." In that case, I wouldn't say it's the run that's "currently controlling the robot."

For the 5.0 release, those API's should be considered private, deprecated, and pending removal.

At any given time, there's at most one current run.

Good call, this is important to call out

@mcous mcous merged commit 80093b3 into edge Nov 9, 2021
@mcous
Copy link
Contributor Author

mcous commented Nov 9, 2021

Merged for speed and because I think I've addressed all comments. Fast following to address #8594, can address anything outstanding there

@mcous mcous deleted the engine_current-run branch November 9, 2021 14:53
Copy link
Member

@sanni-t sanni-t left a comment

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

HTTP API: retrieve previous runs
4 participants