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

chore(api): Add infrastructure for a br2-external tree for buildroot #3217

Merged
merged 3 commits into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Configuration for Buildroot integration
source "$BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH/api/Config.in"
# source "$BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH/update-server/Config.in"
11 changes: 11 additions & 0 deletions api/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
config BR2_PACKAGE_PYTHON_OPENTRONS_API
bool "python-opentrons-api"
depends on BR2_PACKAGE_PYTHON3
select BR2_PACKAGE_PYTHON_NUMPY # runtime
select BR2_PACKAGE_PYTHON_SERIAL # runtime
select BR2_PACKAGE_PYTHON_URWID # runtime
select BR2_PACKAGE_PYTHON_AIOHTTP # runtime
help
Opentrons API server. Controls an OT2 robot.

https://opentrons.com
36 changes: 36 additions & 0 deletions api/buildroot.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
################################################################################
#
# python-opentrons-api
#
################################################################################

# Get a key from package.json (like version)
define get_pkg_json_key
$(shell python -c "import json; print(json.load(open('$(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/api/src/opentrons/package.json'))[\"$(1)\"])")
endef

PYTHON_OPENTRONS_API_VERSION = $(call get_pkg_json_key,version)
PYTHON_OPENTRONS_API_LICENSE = $(call get_pkg_json_key,license)
PYTHON_OPENTRONS_API_LICENSE_FILES = $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/LICENSE
PYTHON_OPENTRONS_API_SETUP_TYPE = setuptools
PYTHON_OPENTRONS_API_SITE_METHOD = local
PYTHON_OPENTRONS_API_SITE = $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)
PYTHON_OPENTRONS_API_SUBDIR = api

ot_api_name := python-opentrons-api

define PYTHON_OPENTRONS_API_INSTALL_INIT_SYSTEMD
$(INSTALL) -D -m 0644 $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/api/opentrons-api-server.service \
$(TARGET_DIR)/etc/systemd/system/opentrons-api-server.service

mkdir -p $(TARGET_DIR)/etc/systemd/system/opentrons.target.wants

ln -sf ../opentrons-api-server.service \
$(TARGET_DIR)/etc/systemd/system/opentrons.target.wants/opentrons-api-server.service
endef

# Calling inner-python-package directly instead of using python-package macro
# because our directory layout doesn’t conform to buildroot’s expectation of
# having the directory name be the package name
$(eval $(call inner-python-package,python-opentrons-api,$(call UPPERCASE,$(ot_api_name)),$(call UPPERCASE,$(ot_api_name)),target))

12 changes: 12 additions & 0 deletions api/opentrons-api-server.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Opentrons API server
Requires=nginx.service
After=nginx.service

[Service]
Type=exec
ExecStart=python -m opentrons.main -U /run/aiohttp.sock
Environment=OT_SMOOTHIE_ID=AMA

[Install]
WantedBy=opentrons.target
1 change: 0 additions & 1 deletion api/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ def read(*parts):
zip_safe=False,
classifiers=CLASSIFIERS,
install_requires=INSTALL_REQUIRES,
setup_requires=['pytest-runner'],
tests_require=['pytest'],
include_package_data=True,
package_dir={'': 'src'},
Expand Down
6 changes: 5 additions & 1 deletion api/src/opentrons/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ def run(**kwargs):
loop.run_until_complete(hardware.home_z())
else:
hardware.home_z()
udev.setup_rules_file()
try:
udev.setup_rules_file()
except Exception:
log.exception(
"Could not setup udev rules, modules may not be detected")
# Explicitly unlock resin updates in case a prior server left them locked
resin.unlock_updates()

Expand Down
2 changes: 2 additions & 0 deletions external.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
name: OPENTRONS_MONOREPO
desc: Tree containing Opentrons API and update infrastructure
3 changes: 3 additions & 0 deletions external.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Makefile inclusions for buildroot integration
include $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/api/buildroot.mk
# include $(BR2_EXTERNAL_OPENTRONS_MONOREPO_PATH)/update-server/buildroot.mk
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment meant to be here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could delete it if you want, it's mostly a memory aid for when we add the update server

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope you can keep it in if it's useful for relevant work later on.