-
Notifications
You must be signed in to change notification settings - Fork 178
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
Resin for app-3-0 (Chore) #347
Changes from 23 commits
6c8ef50
21a48e6
cb3bb6d
48fa589
c98e215
b7d5ed2
28eea70
3c39780
fbeb5a6
062e92c
e92c707
5b714ce
a0d950f
6960e98
9a8de8a
3f5ff6b
d0c0410
b7ea0e8
ae848f7
880f988
70763e9
8a8649f
b25eae1
3e52132
43dc9e2
c7adc9a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# http://docs.resin.io/pages/deployment/docker-templates | ||
FROM resin/raspberrypi3-python:3.5-slim-20170705 | ||
|
||
WORKDIR /usr/src | ||
|
||
|
||
COPY ./api/requirements.txt ./requirements.txt | ||
RUN apt-get update | ||
RUN apt-get install gcc make git g++ | ||
|
||
RUN pip install -r ./requirements.txt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a way to install the app-3-0 branch using pip? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great but out of scope for alpha |
||
|
||
COPY ./api ./api | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the two copy calls? I would think it would work if we did COPY ./api ./api
# ...
RUN pip install -r ./api/requirements.txt
# ... |
||
|
||
COPY data-user_storage.mount /etc/systemd/system/ | ||
RUN systemctl enable data-user_storage.mount | ||
|
||
|
||
ENV INITSYSTEM on | ||
RUN echo $PWD | ||
CMD ["/usr/src/api/scripts/compute/start.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
This document provides information on resin.io in the context of Opentrons. | ||
Last updated: 9/24/17 - Jared Greene | ||
|
||
Overview: | ||
resin.io is a service that is used for fleet management. Opentrons uses it to update and support our automated pipetting systems. | ||
Resin works upon resin.os which is a custom operating system they build ontop of Yocto linux distro. It is a stripped down version of | ||
linux and, most importantly, runs docker. Two docker containers run within each resin-supported device: | ||
1) the resin supervisor container | ||
2) the opentrons server container | ||
|
||
The resin supervisor container monitors the opentrons container and device. It also connects with the resin system | ||
which allows multiple forms for support; including secure remote updating. | ||
|
||
The opentrons server container runs the opentrons server and api which accepts incoming client connects and | ||
allows clients to control the robot and upload/run protocols on it. | ||
|
||
|
||
Getting Started [INTERNAL]: | ||
Let's walk through our first api update / deployment. | ||
For the sake of this walkthrough, we assume that you want to push an updated server image to | ||
all the devices on an existing resin application (a fleet of devices). | ||
|
||
1) Make an account on resin.io (make sure you set up an ssh key) | ||
2) Commit your changes | ||
3) then build your docker image and deploy it to all of the devices with: | ||
`git push resin [CURRENT_BRANCH_NAME]:master` | ||
|
||
Done! This will push this update out to all devices on this application (as long as the image is successfully built). | ||
|
||
If you want to do something more complicated like pushing updates to a single device, creating a new application, or adding | ||
a new device to a new or existing fleet then check out the resin docs at: https://docs.resin.io/introduction/ | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pylama | ||
pyserial==3.2.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I think we need to align as a team on where dev dependencies go and where prod dependencies go. I'm fine with prod dependencies living here, but I've heard stuff about why pyserial isn't in requirements.txt so I'd like to understand what we're doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mcous see my comment in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Some background is here: https://www.python.org/dev/peps/pep-0518/ |
||
pytest | ||
pytest-cov | ||
pytest-aiohttp | ||
|
@@ -7,4 +8,4 @@ numpydoc==0.6.0 | |
# June 15 2017 (artyom) : https://github.com/pyinstaller/pyinstaller/issues/2434 | ||
git+https://github.com/pyinstaller/pyinstaller.git@7e814646474efc868206beb8fb9dfe45af527109 | ||
Sphinx==1.4.8 | ||
twine==1.8.1 | ||
twine==1.8.1 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket | ||
cd /usr/src/api | ||
|
||
echo "[BOOT] Starting server" | ||
python /usr/src/api/opentrons/server/main.py '0.0.0.0':8080 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason to move from our There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point, I'll change it back |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import os | ||
import time | ||
|
||
import serial | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks specific to our testing environment. Do we need this file here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for andy to be able to test on ot-2 |
||
|
||
''' | ||
SETUP VARIABLES | ||
''' | ||
|
||
robot_portname = '/dev/tty.usbserial-AL0158RY' | ||
robot_baud = 14400 | ||
robot_port = None | ||
|
||
|
||
''' | ||
ROBOT | ||
''' | ||
|
||
|
||
def robot_read(): | ||
data = robot_port.readline() | ||
if b'error' in data or b'ALARM' in data: | ||
raise Exception(data) | ||
return data | ||
|
||
|
||
def robot_write(data): | ||
global robot_port | ||
while int(robot_port.in_waiting): | ||
robot_port.reset_input_buffer() | ||
time.sleep(0.02) | ||
if isinstance(data, str): | ||
data = data.encode() | ||
data = data + b' M400\r\n' | ||
print(b'-> ' + data) | ||
robot_port.write(data) | ||
print(b' <- ' + robot_read()) # blocking | ||
print(b' <- ' + robot_read()) # blocking | ||
|
||
# steps/mm command (M92) always returns current values | ||
if b'M92' in data: | ||
print(b' <- ' + robot_read()) # blocking | ||
|
||
|
||
def connect_to_robot(): | ||
global robot_port | ||
try: | ||
print('Connecting to robot...') | ||
robot_port = serial.Serial( | ||
port=robot_portname, baudrate=robot_baud) | ||
robot_write('') | ||
robot_write('M999') | ||
# current | ||
robot_write('M907 X1.5 Y1.5 Z0.7 A0.7 B0.2 C0.2') | ||
# acceleration | ||
robot_write('M204 S5000 X2500 Y2000 Z2000 A2000 B2000 C2000') | ||
# speeds | ||
robot_write('G0F120000 M203.1 X500 Y300 Z70 A70 B40 C40') | ||
# steps/mm | ||
robot_write('M92 X160 Y160 Z800 A800 B767.38 C767.38 M52 M54') | ||
except: | ||
raise RuntimeError('Please connect to robot USB') | ||
|
||
|
||
def home(axis=''): | ||
if not axis: | ||
return | ||
robot_write('G28.2 ' + axis) | ||
|
||
|
||
def back_forth(): | ||
x_travel = 360 | ||
z_step = 180 | ||
# robot_write('G90 G0X380B15 G91') | ||
robot_write('G90 G0X380 G91') | ||
for i in range(4): | ||
robot_write('G0X{} G0X{}'.format(-x_travel, x_travel)) | ||
|
||
for i in range(4): | ||
robot_write('G0X{}Z{}A{} G0X{}Z{}A{}'.format( | ||
-x_travel, -z_step, -z_step, x_travel, z_step, z_step)) | ||
|
||
|
||
''' | ||
RUN | ||
''' | ||
|
||
|
||
connect_to_robot() | ||
|
||
while True: | ||
home('ZA') | ||
home('X') | ||
# home('Y') | ||
back_forth() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description = USB Stick inserted by user | ||
|
||
[Mount] | ||
What = /dev/sda1 | ||
Where = /data/user_storage | ||
Type = vfat | ||
Options = rw | ||
|
||
[Install] | ||
WantedBy = multi-user.target |
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.
Why do we need these?
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.
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.
Gotcha. Do you think we can pre-build packages requiring native compilation to reduce image size?
We might want to run
apt-get
series in a singleRUN
command: https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#runThere 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.
great but out of scope for alpha