Refactor inference engine and task management: Remove obsolete inference engine and ONNX engine files, update inference processing to utilize batch handling, and enhance task management structure in documentation. Adjust paths for task specifications to align with new directory organization.

This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-03-28 01:04:28 +02:00
parent 1e4ef299f9
commit 5be53739cd
60 changed files with 111875 additions and 208 deletions
+22 -10
View File
@@ -1,30 +1,42 @@
import json
import os
import threading
import time
import uuid
import pytest
_MEDIA = os.environ.get("MEDIA_DIR", "/media")
def _ai_config_video(mock_loader_url: str) -> dict:
base = mock_loader_url.rstrip("/")
def _ai_config_video() -> dict:
return {
"probability_threshold": 0.25,
"tracking_intersection_threshold": 0.6,
"altitude": 400,
"focal_length": 24,
"sensor_width": 23.5,
"paths": [f"{base}/load/video_short01.mp4"],
"paths": [f"{_MEDIA}/video_short01.mp4"],
"frame_period_recognition": 4,
"frame_recognition_seconds": 2,
}
def _ai_config_image() -> dict:
return {
"probability_threshold": 0.25,
"altitude": 400,
"focal_length": 24,
"sensor_width": 23.5,
"paths": [f"{_MEDIA}/image_small.jpg"],
}
def test_ft_p08_immediate_async_response(
warm_engine, http_client, jwt_token, mock_loader_url
warm_engine, http_client, jwt_token
):
media_id = f"async-{uuid.uuid4().hex}"
body = _ai_config_video(mock_loader_url)
body = _ai_config_image()
headers = {"Authorization": f"Bearer {jwt_token}"}
t0 = time.monotonic()
r = http_client.post(f"/detect/{media_id}", json=body, headers=headers)
@@ -37,10 +49,10 @@ def test_ft_p08_immediate_async_response(
@pytest.mark.slow
@pytest.mark.timeout(120)
def test_ft_p09_sse_event_delivery(
warm_engine, http_client, jwt_token, mock_loader_url, sse_client_factory
warm_engine, http_client, jwt_token, sse_client_factory
):
media_id = f"sse-{uuid.uuid4().hex}"
body = _ai_config_video(mock_loader_url)
body = _ai_config_video()
headers = {"Authorization": f"Bearer {jwt_token}"}
collected: list[dict] = []
thread_exc: list[BaseException] = []
@@ -76,17 +88,17 @@ def test_ft_p09_sse_event_delivery(
assert ok, "SSE listener did not finish within 120s"
th.join(timeout=5)
assert not thread_exc, thread_exc
assert any(e.get("mediaStatus") == "AIProcessing" for e in collected)
assert collected, "no SSE events received"
final = collected[-1]
assert final.get("mediaStatus") == "AIProcessed"
assert final.get("mediaPercent") == 100
def test_ft_n04_duplicate_media_id_409(
warm_engine, http_client, jwt_token, mock_loader_url
warm_engine, http_client, jwt_token
):
media_id = "dup-test"
body = _ai_config_video(mock_loader_url)
body = _ai_config_video()
headers = {"Authorization": f"Bearer {jwt_token}"}
r1 = http_client.post(f"/detect/{media_id}", json=body, headers=headers)
assert r1.status_code == 200