mirror of
https://github.com/azaion/detections.git
synced 2026-04-23 09:56:33 +00:00
2.1 KiB
2.1 KiB
Module: ai_availability_status
Purpose
Thread-safe status tracker for the AI engine lifecycle (downloading, converting, uploading, enabled, warning, error).
Public Interface
Enum: AIAvailabilityEnum
| Value | Name | Meaning |
|---|---|---|
| 0 | NONE | Initial state, not yet initialized |
| 10 | DOWNLOADING | Model download in progress |
| 20 | CONVERTING | ONNX-to-TensorRT conversion in progress |
| 30 | UPLOADING | Converted model upload in progress |
| 200 | ENABLED | Engine ready for inference |
| 300 | WARNING | Operational with warnings |
| 500 | ERROR | Failed, not operational |
Class: AIAvailabilityStatus
| Field | Type | Description |
|---|---|---|
status |
AIAvailabilityEnum | Current status |
error_message |
str or None | Error/warning details |
| Method | Signature | Description |
|---|---|---|
__init__ |
() |
Sets status=NONE, error_message=None |
__str__ |
() -> str |
Thread-safe formatted string: "StatusText ErrorText" |
serialize |
() -> bytes |
Thread-safe msgpack serialization {s: status, m: error_message} (legacy — not called in current codebase) |
set_status |
(AIAvailabilityEnum status, str error_message=None) -> void |
Thread-safe status update; logs via constants_inf (error or info) |
Internal Logic
All public methods acquire a threading.Lock before reading/writing status fields. set_status logs the transition: errors go to constants_inf.logerror, normal transitions go to constants_inf.log.
Dependencies
- External:
msgpack,threading - Internal:
constants_inf(logging)
Consumers
inference— creates instance, callsset_statusduring engine lifecycle, exposesai_availability_statusfor health checksmain— readsai_availability_statusvia inference for/healthendpoint
Data Models
AIAvailabilityEnum— status enumAIAvailabilityStatus— stateful status holder
Configuration
None.
External Integrations
None.
Security
Thread-safe via Lock — safe for concurrent access from FastAPI async + ThreadPoolExecutor.
Tests
None found.