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 4 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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] = "187588c10ff4804b91e0c947d6b1a4006dbb633261c0f869865de518603c5d5e"
SRC_URI = "https://github.com/giampaolo/psutil/archive/refs/tags/release-6.0.0.tar.gz"

S = "${WORKDIR}/psutil-release-6.0.0"

inherit pypi setuptools3

RDEPENDS_${PN} += "python3"

FILES_${PN} += "${libdir}/python3*/site-packages/psutil"
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ 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 \
opentrons-system-server opentrons-mcu-firmware \
opentrons-user-environment opentrons-module-firmware \
opentrons-systemd-units opentrons-ssh-keys \
opentrons-systemd-units opentrons-ssh-keys opentrons-system-resource-tracker \
libjpeg-turbo \
"

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
Environment=OT_SYSTEM_RESOURCE_TRACKER_ENABLED=true
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
@@ -0,0 +1,44 @@

inherit externalsrc
EXTERNALSRC = "${@os.path.abspath(os.path.join("${TOPDIR}", os.pardir, os.pardir, "opentrons"))}"

LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3b83ef96387f14655fc854ddc3c6bd57"

# Modify these as desired
DEST_SYSTEMD_DROPFILE ?= "${B}/system-resource-tracker-version.conf"
OT_PACKAGE = "performance-metrics"
inherit insane systemd get_ot_package_version

SYSTEMD_AUTO_ENABLE = "enable"
SYSTEMD_SERVICE:${PN} = "opentrons-system-resource-tracker.service"
FILESEXTRAPATHS:prepend = "${THISDIR}/files:"
SRC_URI:append = " file://opentrons-system-resource-tracker.service"

PIPENV_APP_BUNDLE_PROJECT_ROOT = "${S}/performance-metrics"
PIPENV_APP_BUNDLE_DIR = "/opt/opentrons-robot-server/performance-metrics"
PIPENV_APP_BUNDLE_USE_GLOBAL = "systemd-python "
PIPENV_APP_BUNDLE_STRIP_HASHES = "yes"
PIPENV_APP_BUNDLE_EXTRA_PIP_ENVARGS = "OPENTRONS_PROJECT=${OPENTRONS_PROJECT}"

do_compile:append() {
}

addtask do_write_systemd_dropfile after do_compile before do_install

do_install:append () {
# create json file to be used in VERSION.json
install -d ${D}/opentrons_versions
python3 ${S}/scripts/python_build_utils.py performance-metrics ${OPENTRONS_PROJECT} dump_br_version > ${D}/opentrons_versions/performance-metrics.json

install -d ${D}/${systemd_system_unitdir}
install -m 0644 ${WORKDIR}/opentrons-system-resource-tracker.service ${D}/${systemd_system_unitdir}/opentrons-system-resource-tracker.service
}

FILES:${PN}:append = " ${systemd_system_unitdir/opentrons-system-resource-tracker.service.d \
${systemd_system_unitdir}/opentrons-system-resource-tracker.service.d/system-resource-tracker-version.conf \
"

RDEPENDS:${PN} += " python3-systemd python3-psutil"

inherit pipenv_app_bundle
Loading