mirror of
https://github.com/azaion/detections.git
synced 2026-06-21 10:41:07 +00:00
8ce40a9385
- Introduced `AIAvailabilityStatus` class to manage the availability status of AI models, including methods for setting status and logging messages. - Added `AIRecognitionConfig` class to encapsulate configuration parameters for AI recognition, with a static method for creating instances from dictionaries. - Implemented enums for AI availability states to enhance clarity and maintainability. - Updated related Cython files to support the new classes and ensure proper type handling. These changes aim to improve the structure and functionality of the AI model management system, facilitating better status tracking and configuration handling.
38 lines
1.2 KiB
Cython
38 lines
1.2 KiB
Cython
cimport cython
|
|
cimport constants_inf
|
|
|
|
AIStatus2Text = {
|
|
AIAvailabilityEnum.NONE: "None",
|
|
AIAvailabilityEnum.DOWNLOADING: "Downloading",
|
|
AIAvailabilityEnum.CONVERTING: "Converting",
|
|
AIAvailabilityEnum.UPLOADING: "Uploading",
|
|
AIAvailabilityEnum.ENABLED: "Enabled",
|
|
AIAvailabilityEnum.WARNING: "Warning",
|
|
AIAvailabilityEnum.ERROR: "Error",
|
|
}
|
|
|
|
cdef class AIAvailabilityStatus:
|
|
def __init__(self):
|
|
self.status = AIAvailabilityEnum.NONE
|
|
self.error_message = ""
|
|
|
|
def __str__(self):
|
|
with self._lock:
|
|
status_text = AIStatus2Text.get(self.status, "Unknown")
|
|
error_text = self.error_message if self.error_message else ""
|
|
return f"{status_text} {error_text}"
|
|
|
|
cdef set_status(self, int status, str error_message=""):
|
|
log_message = ""
|
|
with self._lock:
|
|
self.status = status
|
|
self.error_message = error_message
|
|
status_text = AIStatus2Text.get(self.status, "Unknown")
|
|
error_text = self.error_message if self.error_message else ""
|
|
log_message = f"{status_text} {error_text}"
|
|
|
|
if error_message:
|
|
constants_inf.logerror(<str>error_message)
|
|
else:
|
|
constants_inf.log(<str>log_message)
|