Skip to content
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
17 changes: 12 additions & 5 deletions _states/cacophony.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def pkg_installed_from_github(
pkg_name = name

installed_version_cmd = f"dpkg-query --showformat='${{Version}}' --show {pkg_name}"
installed_version_ret = __salt__["cmd.run_all"](installed_version_cmd, python_shell=False)
installed_version_ret = __salt__["cmd.run_all"](
installed_version_cmd, python_shell=False
)

installed_version = ""
if installed_version_ret["retcode"] == 0:
Expand Down Expand Up @@ -124,7 +126,7 @@ def pkg_installed_from_github(
download_start_time = time.time()
source_url = f"https://github.com/TheCacophonyProject/{name}/releases/download/v{version}/{pkg_name}_{version}_{architecture}.deb"
download_ret = __salt__["cp.get_url"](source_url, deb_path, makedirs=True)
download_duration = time.time() - download_start_time
download_duration = time.time() - download_start_time
if not download_ret:
ret["comment"] = f"Failed to download package from {source_url}"
return ret
Expand All @@ -136,10 +138,14 @@ def pkg_installed_from_github(

if install_ret["retcode"] != 0:
ret["result"] = False
ret["comment"] = "dpkg failed to install {}. Stderr: {}".format(deb_path, install_ret["stderr"])
ret["comment"] = "dpkg failed to install {}. Stderr: {}".format(
deb_path, install_ret["stderr"]
)
else:
ret["result"] = True
ret["comment"] = f"Package {pkg_name} version {version} installed successfully in {(time.time() - start_time):.2f}. (download: {download_duration:.2f}s, install: {install_duration:.2f}s)."
ret["comment"] = (
f"Package {pkg_name} version {version} installed successfully in {(time.time() - start_time):.2f}. (download: {download_duration:.2f}s, install: {install_duration:.2f}s)."
)
ret["changes"] = {
"old": installed_version,
"new": version,
Expand All @@ -150,9 +156,10 @@ def pkg_installed_from_github(
if os.path.exists(package_tmp_dir):
os.remove(deb_path)
os.rmdir(package_tmp_dir)

return ret


def init_alsa(name):
"""Ensure that the built-in audio hardware is correctly initialised."""
if _is_audio_setup():
Expand Down
18 changes: 15 additions & 3 deletions tc2/thermal-recorder-py/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ git:
file.managed:
- source: salt://tc2/thermal-recorder-py/thermal-recorder-py.service

/etc/systemd/system/thermal-classifier.service:
file.managed:
- source: salt://tc2/thermal-recorder-py/thermal-classifier.service

/etc/systemd/system/thermal-postprocess.service:
file.managed:
- source: salt://tc2/thermal-recorder-py/thermal-postprocess.service

/etc/systemd/system/thermal-dbuslistener.service:
file.managed:
- source: salt://tc2/thermal-recorder-py/thermal-dbuslistener.service

classifier-eqs:
pkg.installed:
- pkgs:
Expand Down Expand Up @@ -36,7 +48,7 @@ classifier-env:
classifier-pipeline-pip:
cacophony.pkg_installed_from_pypi:
- name: classifier-pipeline
- version: "0.0.29"
- version: "0.0.34"
- venv: /home/pi/.venv/classifier/bin/

thermal-recorder-py-service:
Expand All @@ -55,8 +67,8 @@ thermal-recorder-service:
- mode: 755

# When updating the version make sure to update the hash also.
'download-model pi-v0.6 inc3-tflite-15122023.tar tflite 8c8ad1c4505e356bf526f7b61f84e754ff95beddb86d71c59d3fff720a6692a6':
'download-model pi-v0.7 effv2b3-202509.tar tflite ff2ed9aed0cea66c79c4813447eedc1eb6ed92d832a575de3b5d6c7a062a93ae':
cmd.run

'download-model rf-fp-v0.4 forestmodel.tar rf-fp-model fceacd8729f661ef438e9dea12221ccddb531a4d7e6c375c1b4c6224b841b33b':
'download-model rf-fp-v0.5 forestmodel.tar rf-fp-model 0bdef1c9b7cc6c9ff96c07683127ab3d494277307d69293ffca0867b918ca399':
cmd.run
12 changes: 12 additions & 0 deletions tc2/thermal-recorder-py/thermal-classifier.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Cacophony Project Python Thermal Classifier
After=multi-user.target

[Service]
Type=simple
ExecStart=/home/pi/.venv/classifier/bin/serve_model
Restart=always
RestartSec=3s

[Install]
WantedBy=multi-user.target
12 changes: 12 additions & 0 deletions tc2/thermal-recorder-py/thermal-dbuslistener.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Cacophony Project Python Thermal Dbus listener
After=multi-user.target

[Service]
Type=simple
ExecStart=/home/pi/.venv/classifier/bin/dbus_listener
Restart=always
RestartSec=3s

[Install]
WantedBy=multi-user.target
12 changes: 12 additions & 0 deletions tc2/thermal-recorder-py/thermal-postprocess.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Cacophony Project Python Thermal Post process watcher
After=multi-user.target

[Service]
Type=simple
ExecStart=/home/pi/.venv/classifier/bin/postprocess_watcher
Restart=on-failure
RestartSec=3s

[Install]
WantedBy=multi-user.target