Files
ProxMenux/oci/tests/test_frigate_amd_profile.py
T
MacRimi 9b5cefb81a feat(oci): GPU selection per host and per image, one notification per update, and App tab for stack containers
- Immich asks what runs its video and its recognition in one menu, in both
  modes, and gives the GPU to the server and to Machine learning; AMD uses ROCm
- Frigate, Ollama, llama.cpp, Faster Whisper and Piper take the image built
  for the chosen GPU
- The acceleration menu offers only what the host can run
- An update or a recreation sends one notification with its result instead of
  the stop, backup and start of each container
- A private bridge with nothing connected is not reported as down
- Secondary containers of a stack appear in the App tab with their version and
  logo; Secure Gateway shows the same update state in both views
- A mistyped value in the wizard asks the same question again
2026-10-02 21:45:38 +02:00

56 lines
2.7 KiB
Python

"""Frigate's AMD profile takes the image built for ROCm and the two devices
it needs, and says what is left for the user to set."""
from pathlib import Path
import sys
import unittest
from unittest.mock import patch
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "src"))
sys.path.insert(0, str(Path(__file__).resolve().parent))
from proxmenux_oci.catalog import Catalog
from proxmenux_oci.installer import DEFAULT_MODE, build_deployment
from test_advanced_flow_order import RecordingUI, storages
PROMPT = "Hardware acceleration for Frigate"
# Every profile is offered: what the host has is checked in its own test.
@patch("proxmenux_oci.installer.host.gpus", return_value={"intel": ["/dev/dri/renderD128"], "amd": ["/dev/dri/renderD128"], "nvidia": True})
@patch("proxmenux_oci.installer._profile_usable", return_value=True)
@patch("proxmenux_oci.i18n.language", return_value="en")
@patch("proxmenux_oci.installer.host.storages", side_effect=storages)
@patch("proxmenux_oci.installer.host.bridges", return_value=[{"iface": "vmbr0", "cidr": "192.0.2.10/24"}])
@patch("proxmenux_oci.installer.host.timezone", return_value="Europe/Madrid")
class FrigateAmdProfileTests(unittest.TestCase):
def build(self, profile):
template = Catalog(ROOT).compose("frigate")
plan = build_deployment(template, RecordingUI({PROMPT: profile}), DEFAULT_MODE)
return template, plan
def test_the_amd_profile_uses_the_rocm_image_with_both_devices(self, *_):
template, plan = self.build("rocm")
self.assertEqual(template["container_contract"]["image"]["reference"],
"ghcr.io/blakeblackshear/frigate:stable-rocm")
self.assertEqual([device["host_path"] for device in plan["devices"]], ["/dev/dri/renderD128", "/dev/kfd"])
self.assertEqual(plan["devices"][0]["drm_vendor_ids"], ["0x1002"])
self.assertTrue(any("type: onnx" in note for note in plan["completion_notes"]))
def test_the_other_profiles_keep_their_image(self, *_):
for profile, tag in (("none", "stable"), ("vaapi", "stable"), ("nvidia", "stable-tensorrt")):
template, plan = self.build(profile)
self.assertTrue(template["container_contract"]["image"]["reference"].endswith(":" + tag), profile)
self.assertFalse(plan.get("completion_notes"), profile)
def test_the_shipped_copy_matches_the_curated_profile(self, *_):
import json
read = lambda name: json.loads((ROOT / f"catalog/{name}/frigate.json").read_text())[
"proxmox"]["installer_profile"]["hardware_acceleration"]
self.assertEqual(read("curated"), read("apps"))
if __name__ == "__main__":
unittest.main()