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: add system_resource_tracker and performance-metrics to image #156

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ sstate-cache/

# ignore linux swap files
*.swp

.tool-versions
12 changes: 10 additions & 2 deletions layers/meta-opentrons/classes/pipenv_app_bundle.bbclass
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ python do_rewrite_requirements() {
orig = reqsfile_obj.read().split('\n')
condensed = []
working = ''
bb.verbnote("original file: {}".format("\n".join(orig)))
for line in orig:
if not line.endswith('\\'):
working += line.strip()
Expand Down Expand Up @@ -122,10 +123,17 @@ python do_rewrite_requirements() {
else:
bb.debug(1, 'Keeping ' + line)
pypi.append(line)

formatted_pypi_file = '\n'.join(pypi) + '\n'
formatted_local_file = '\n'.join(local) + '\n'

bb.verbnote("pypi.txt content: {}".format(formatted_pypi_file))
bb.verbnote("local.txt content: {}".format(formatted_local_file))

with open(pypi_outfile, 'w') as pypi_outfile_obj:
pypi_outfile_obj.write('\n'.join(pypi) + '\n')
pypi_outfile_obj.write(formatted_pypi_file)
with open(local_outfile, 'w') as local_outfile_obj:
local_outfile_obj.write('\n'.join(local) + '\n')
local_outfile_obj.write(formatted_local_file)
}

do_rewrite_requirements[vardeps] += " PIPENV_APP_BUNDLE_USE_GLOBAL PIPENV_APP_BUNDLE_EXTRAS "
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
SUMMARY = "A cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors) in Python."
DESCRIPTION = "psutil is a cross-platform library for retrieving information on running processes and system utilization (CPU, memory, disks, network, sensors) in Python."
HOMEPAGE = "https://github.com/giampaolo/psutil"
SECTION = "devel/python"
LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://LICENSE;md5=a9c72113a843d0d732a0ac1c200d81b1"

SRC_URI[sha256sum] = "8faae4f310b6d969fa26ca0545338b21f73c6b15db7c4a8d934a5482faa818f2"
SRC_URI = "https://files.pythonhosted.org/packages/source/p/psutil/psutil-${PV}.tar.gz"

PYPI_PACKAGE = "psutil"

inherit pypi python_setuptools_build_meta

DEPENDS += "${PYTHON_PN}-setuptools-native"

RDEPENDS_${PN} += " \
${PYTHON_PN}-core \
${PYTHON_PN}-distutils \
${PYTHON_PN}-shell \
${PYTHON_PN}-netclient \
${PYTHON_PN}-numbers \
${PYTHON_PN}-mmap \
${PYTHON_PN}-contextlib \
${PYTHON_PN}-datetime \
${PYTHON_PN}-pprint \
${PYTHON_PN}-logging \
${PYTHON_PN}-math \
${PYTHON_PN}-resource \
${PYTHON_PN}-fcntl \
${PYTHON_PN}-pickle \
"

BBCLASSEXTEND = "native nativesdk"
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ IMAGE_INSTALL += " \
${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'timestamp-service systemd-analyze', '', d)} \
weston-xwayland weston weston-init imx-gpu-viv \
plymouth mosquitto hidapi \
python3 python3-misc python3-modules python3-pip \
python3 python3-misc python3-modules python3-pip python3-psutil\
robot-app-wayland-launch opentrons-robot-app \
opentrons-robot-server opentrons-update-server \
opentrons-usb-bridge opentrons-jupyter-notebook \
Expand Down Expand Up @@ -108,7 +108,9 @@ python do_create_opentrons_manifest() {
"opentrons-system-server-version.json", \
"opentrons-api-version.json", \
"opentrons-usb-bridge-version.json", \
"opentrons-firmware-version.json"]
"opentrons-firmware-version.json", \
"opentrons-performance-metrics-version.json" \
]

opentrons_versions_dir = "%s/opentrons_versions" % d.getVar('STAGING_DIR_HOST')
version_files_present = os.listdir(opentrons_versions_dir)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[Unit]
Description=Opentrons System Resource Tracker
After=opentrons-robot-server.service

[Service]
Type=notify
ExecStart=python3 -m performance_metrics.system_resource_tracker
StateDirectory=system-resource-tracker
Environment=PYTHONPATH=/opt/opentrons-robot-server:/usr/lib/python3.10/site-packages
Environment=OT_SYSTEM_RESOURCE_TRACKER_ENABLED=false
Environment=OT_SYSTEM_RESOURCE_TRACKER_REFRESH_INTERVAL=15.0

Restart=no
TimeoutSec=10s

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ OT_PACKAGE = "robot-server"
inherit insane systemd get_ot_package_version

SYSTEMD_AUTO_ENABLE = "enable"
SYSTEMD_SERVICE:${PN} = "opentrons-robot-server.service opentrons-ot3-canbus.service"
SYSTEMD_SERVICE:${PN} = "opentrons-robot-server.service opentrons-ot3-canbus.service opentrons-system-resource-tracker.service"
FILESEXTRAPATHS:prepend = "${THISDIR}/files:"
SRC_URI:append = " file://opentrons-robot-server.service file://opentrons-ot3-canbus.service file://95-opentrons-modules.rules"
SRC_URI:append = " file://opentrons-robot-server.service file://opentrons-system-resource-tracker.service file://opentrons-ot3-canbus.service file://95-opentrons-modules.rules"

PIPENV_APP_BUNDLE_PROJECT_ROOT = "${S}/robot-server"
PIPENV_APP_BUNDLE_DIR = "/opt/opentrons-robot-server"
Expand Down Expand Up @@ -42,22 +42,27 @@ do_install:append () {
install -d ${D}/opentrons_versions
python3 ${S}/scripts/python_build_utils.py robot-server ${OPENTRONS_PROJECT} dump_br_version > ${D}/opentrons_versions/opentrons-robot-server-version.json
python3 ${S}/scripts/python_build_utils.py api ${OPENTRONS_PROJECT} dump_br_version > ${D}/opentrons_versions/opentrons-api-version.json
python3 ${S}/scripts/python_build_utils.py performance-metrics ${OPENTRONS_PROJECT} dump_br_version > ${D}/opentrons_versions/opentrons-performance-metrics-version.json

install -d ${D}${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/opentrons-robot-server.service ${D}${systemd_system_unitdir}/opentrons-robot-server.service
install -d ${D}${systemd_system_unitdir}/opentrons-robot-server.service.d
install -m 0644 ${B}/robot-server-version.conf ${D}${systemd_system_unitdir}/opentrons-robot-server.service.d/robot-server-version.conf
install -m 0644 ${WORKDIR}/opentrons-ot3-canbus.service ${D}${systemd_system_unitdir}/opentrons-ot3-canbus.service
install -m 0644 ${WORKDIR}/opentrons-system-resource-tracker.service ${D}/${systemd_system_unitdir}/opentrons-system-resource-tracker.service

install -d ${D}${sysconfdir}/udev/rules.d/
install -m 0644 ${WORKDIR}/95-opentrons-modules.rules ${D}${sysconfdir}/udev/rules.d/95-opentrons-modules.rules

}

FILES:${PN}:append = " ${systemd_system_unitdir/opentrons-robot-server.service.d \
${systemd_system_unitdir}/opentrons-robot-server.service.d/robot-server-version.conf \
${systemd_system_unitdir}/opentrons-system-resource-tracker.service.d/system-resource-tracker-version.conf \
${sysconfdir}/udev/rules.d/95-opentrons-modules.rules \
${sysconfdir}/release-notes.md \
"

RDEPENDS:${PN} += " udev python3-numpy python3-systemd nginx python-can python3-pyzmq libgpiod-python python-aionotify mosquitto python-byonoy"
RDEPENDS:${PN} += " udev python3-numpy python3-systemd nginx python-can python3-pyzmq libgpiod-python python-aionotify mosquitto python-byonoy python3-psutil"

inherit pipenv_app_bundle
Loading