# Module: constants_inf

## Purpose

Application-wide constants, logging infrastructure, and the object detection class registry loaded from `classes.json`.

## Public Interface

### Constants

| Name | Type | Value | Description |
|------|------|-------|-------------|
| `CONFIG_FILE` | str | `"config.yaml"` | Configuration file path |
| `QUEUE_CONFIG_FILENAME` | str | `"secured-config.json"` | Queue config filename |
| `AI_ONNX_MODEL_FILE` | str | `"azaion.onnx"` | ONNX model filename |
| `INT8_CALIB_CACHE_FILE` | str | `"azaion.int8_calib.cache"` | INT8 calibration cache filename on the Loader service |
| `CDN_CONFIG` | str | `"cdn.yaml"` | CDN configuration file |
| `MODELS_FOLDER` | str | `"models"` | Directory for model files |
| `SMALL_SIZE_KB` | int | `3` | Small file size threshold (KB) |
| `SPLIT_SUFFIX` | str | `"!split!"` | Delimiter in tiled image names |
| `TILE_DUPLICATE_CONFIDENCE_THRESHOLD` | double | `0.01` | Threshold for tile duplicate detection equality |
| `METERS_IN_TILE` | int | `25` | Physical tile size in meters for large image splitting |
| `weather_switcher_increase` | int | `20` | Offset between weather mode class ID ranges |

### Enum: WeatherMode

| Value | Name | Meaning |
|-------|------|---------|
| 0 | Norm | Normal weather |
| 20 | Wint | Winter |
| 40 | Night | Night |

### Class: AnnotationClass

Fields: `id` (int), `name` (str), `color` (str), `max_object_size_meters` (int).

Represents a detection class with its display metadata and physical size constraint.

### Functions

| Function | Signature | Description |
|----------|-----------|-------------|
| `log` | `(str log_message) -> void` | Info-level log via loguru |
| `logerror` | `(str error) -> void` | Error-level log via loguru |
| `format_time` | `(int ms) -> str` | Converts milliseconds to compact time string `HMMSSf` |

### Global: `annotations_dict`

`dict[int, AnnotationClass]` — loaded at module init from `classes.json`. Contains 19 base classes × 3 weather modes (Norm/Wint/Night) = up to 57 entries. Keys are class IDs, values are `AnnotationClass` instances.

## Internal Logic

- On import, reads `classes.json` and builds `annotations_dict` by iterating 3 weather mode offsets (0, 20, 40) and adding class ID offsets. Weather mode names are appended to class names for non-Norm modes.
- Configures loguru with:
  - File sink: `Logs/log_inference_YYYYMMDD.txt` (daily rotation, 30-day retention)
  - Stdout: INFO/DEBUG/SUCCESS levels
  - Stderr: WARNING and above

## Legacy / Orphaned Declarations

The `.pxd` header declares `QUEUE_MAXSIZE`, `COMMANDS_QUEUE`, and `ANNOTATIONS_QUEUE` (with comments referencing RabbitMQ) that are **not defined** in the `.pyx` implementation. These are remnants of a previous queue-based architecture and are unused.

## Dependencies

- **External**: `json`, `sys`, `loguru`
- **Internal**: none (leaf module)

## Consumers

- `ai_availability_status` (logging)
- `annotation` (tile duplicate threshold)
- `onnx_engine` (logging)
- `tensorrt_engine` (logging)
- `inference` (logging, constants, annotations_dict, format_time, SPLIT_SUFFIX, METERS_IN_TILE, MODELS_FOLDER, AI_ONNX_MODEL_FILE)
- `main` (annotations_dict for label lookup)

## Data Models

- `AnnotationClass` — detection class metadata
- `WeatherMode` — enum for weather conditions

## Configuration

- Reads `classes.json` at import time (must exist in working directory)

## External Integrations

None.

## Security

None.

## Tests

None found.
