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

feat(app): Persist known robots to file-system when using new discovery #2065

Merged
merged 4 commits into from
Aug 15, 2018

Conversation

mcous
Copy link
Contributor

@mcous mcous commented Aug 15, 2018

overview

This PR adds robot persistence to file to the app and wires up the necessary state. It also includes some tweaks to various values and configurations based on how discovery behaves in the real world.

changelog

  • feat(app): Persist known robots to file-system when using new discovery

review requests

Try this out on your machine!

  1. make -C discovery-client (Re-build discovery client)
  2. make -C app dev OT_APP_DISCOVERY__ENABLED=1
  • discovery.robotsByName state is prepopulated at app launch from file
  • App picks up virtual smoothie as opentrons-dev
  • App picks up IPv6 robots as their actual name
  • Unplugging an IPv6 robot from USB will get it to fall back to WiFi (faster if list is currently refreshing)
  • Ditto for IPv4 (should be unchanged from refactor(app): Move discovery / optionally enable discovery-client (2 of 2) #2045)
  • RPC connection to robots still works

Known issues:

  • RPC client and health-check module do not handle USB disconnections gracefully when RPC is connected
    • This may be a blocker for actual release of new discovery
    • For now though its enough for me to keep it behind the feature flag

@mcous mcous added feature Ticket is a feature request / PR introduces a feature app Affects the `app` project ready for review medium labels Aug 15, 2018
@@ -1,7 +1,7 @@
// simple script to advertise a MDNS service for local API
// TODO(mc, 2017-10-31): remove this file once API can advertise for itself
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically should've updated this TODO. This file will now go away when new discovery is enabled by default

Copy link
Contributor

@Kadee80 Kadee80 left a comment

Choose a reason for hiding this comment

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

🐩 tested on wandering 👩

@codecov
Copy link

codecov bot commented Aug 15, 2018

Codecov Report

Merging #2065 into edge will increase coverage by <.01%.
The diff coverage is 76.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge    #2065      +/-   ##
==========================================
+ Coverage   33.09%   33.09%   +<.01%     
==========================================
  Files         445      445              
  Lines        7125     7200      +75     
==========================================
+ Hits         2358     2383      +25     
- Misses       4767     4817      +50
Impacted Files Coverage Δ
app/src/config/index.js 50% <ø> (ø) ⬆️
app/src/index.js 0% <0%> (ø) ⬆️
app/src/shell/index.js 82.6% <100%> (+0.79%) ⬆️
app/src/robot/selectors.js 82.16% <100%> (+0.11%) ⬆️
discovery-client/src/index.js 98.79% <100%> (+0.01%) ⬆️
app/src/discovery/index.js 95.23% <100%> (+0.5%) ⬆️
app-shell/src/config.js 25% <20%> (ø) ⬆️
app-shell/src/discovery.js 90% <85.71%> (-5.24%) ⬇️
app/src/components/TempDeckStatusCard/index.js 0% <0%> (ø) ⬆️
... and 5 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 c25c081...956f7ca. Read the comment docs.

Copy link
Contributor

@IanLondon IanLondon left a comment

Choose a reason for hiding this comment

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

Tested on Sunset (v4) and QA (v6)

}
}

return state
}

function flattenRobots (robots: Array<DiscoveredRobot> = []): RobotsMap {
Copy link
Contributor

Choose a reason for hiding this comment

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

flatten is a little misleading for array -> map IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, I'm gonna rename this to normalizeRobots as per redux convention. Don't know what was happening in my head when I named it "flatten"

}
}

return state
}

function flattenRobots (robots: Array<DiscoveredRobot> = []): RobotsMap {
return robots.reduce(
(robotsMap, robot) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

ever since it made Flow crash on me a few months ago (facebook/flow#5831) I've been paranoid about unannotated accumulators in reduce -- you might wanna robotsMap: RobotsMap. AFAIK it's safe to leave the value (robot here) without annotation, but not the accumulator arg in the reduce cb.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted. Already touching this file; will add type annotations for safety

@Laura-Danielle
Copy link
Contributor

A few comments from Windows 10:

Took a few refreshes to see the robot USB (IPv4) -> could be what that customer was seeing earlier today.
Same with getting the robot to show up for WiFi. IPv6 worked like a 🥇

Copy link
Contributor

@Laura-Danielle Laura-Danielle left a comment

Choose a reason for hiding this comment

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

🍠

@mcous mcous merged commit 55b4000 into edge Aug 15, 2018
@mcous mcous deleted the app_persist-known-robots branch August 15, 2018 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app Affects the `app` project feature Ticket is a feature request / PR introduces a feature medium
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants