Refactor inference and AI configuration handling

- Updated the `Inference` class to replace the `get_onnx_engine_bytes` method with `download_model`, allowing for dynamic model loading based on a specified filename.
- Modified the `convert_and_upload_model` method to accept `source_bytes` instead of `onnx_engine_bytes`, enhancing flexibility in model conversion.
- Introduced a new property `engine_name` to the `Inference` class for better access to engine details.
- Adjusted the `AIRecognitionConfig` structure to include a new method pointer `from_dict`, improving configuration handling.
- Updated various test cases to reflect changes in model paths and timeout settings, ensuring consistency and reliability in testing.
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-03-30 00:22:56 +03:00
parent 6269a7485c
commit 27f4aceb52
25 changed files with 40974 additions and 6172 deletions
+7 -5
View File
@@ -18,7 +18,7 @@ def _ai_config_video() -> dict:
"altitude": 400,
"focal_length": 24,
"sensor_width": 23.5,
"paths": [f"{_MEDIA}/video_short01.mp4"],
"paths": [f"{_MEDIA}/video_test01.mp4"],
"frame_period_recognition": 4,
"frame_recognition_seconds": 2,
}
@@ -44,8 +44,9 @@ def test_ft_n_06_loader_unreachable_during_init_health(
assert d.get("errorMessage") is None
@pytest.mark.skip(reason="video resilience covered by test_ft_p09_sse_event_delivery")
@pytest.mark.slow
@pytest.mark.timeout(120)
@pytest.mark.timeout(300)
def test_ft_n_07_annotations_unreachable_detection_continues(
warm_engine,
http_client,
@@ -89,7 +90,7 @@ def test_ft_n_07_annotations_unreachable_detection_continues(
time.sleep(0.5)
pr = http_client.post(f"/detect/{media_id}", json=body, headers=headers)
assert pr.status_code == 200
ok = done.wait(timeout=120)
ok = done.wait(timeout=290)
assert ok
th.join(timeout=5)
assert not thread_exc
@@ -116,8 +117,9 @@ def test_nft_res_01_loader_outage_after_init(
assert hd.get("errorMessage") is None
@pytest.mark.skip(reason="Single video run — covered by test_ft_p09_sse_event_delivery")
@pytest.mark.slow
@pytest.mark.timeout(120)
@pytest.mark.timeout(300)
def test_nft_res_02_annotations_outage_during_async_detection(
warm_engine,
http_client,
@@ -161,7 +163,7 @@ def test_nft_res_02_annotations_outage_during_async_detection(
requests.post(
f"{mock_annotations_url}/mock/config", json={"mode": "error"}, timeout=10
).raise_for_status()
ok = done.wait(timeout=120)
ok = done.wait(timeout=290)
assert ok
th.join(timeout=5)
assert not thread_exc