Skip to content

Commit

Permalink
feat: add system_resource_tracker and performance-metrics to image
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekMaggio committed Jul 19, 2024
1 parent ad5d1e0 commit 9848175
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python 3.10.13
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=d2ac07f3999abbbb82c4c1a5397a2b27"

SRC_URI[sha256sum] = "9e4c75b17b7c4e40b0d3f6e3e44dc9f9a23e5468ae75c4c28f42d3717cfc2580"
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 @@ -57,6 +57,7 @@ IMAGE_INSTALL += " \
plymouth \
mosquitto \
opentrons-jupyter-notebook \
python3-psutil \
"

# We do NOT want the toradex libusbgx packages that autoconfigure the OTG USB
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

0 comments on commit 9848175

Please sign in to comment.