mirror of
https://github.com/azaion/detections.git
synced 2026-04-22 23:56:31 +00:00
1fe9425aa8
- Update module docs: main, inference, ai_config, loader_http_client - Add new module doc: media_hash - Update component docs: inference_pipeline, api - Update system-flows (F2, F3) and data_parameters - Add Task Mode to document skill for incremental doc updates - Insert Step 11 (Update Docs) in existing-code flow, renumber 11-13 to 12-14 Made-with: Cursor
2.6 KiB
2.6 KiB
Module: loader_http_client
Purpose
HTTP client for downloading/uploading model files via the Loader service, and for querying the Annotations service API (user AI settings, media path resolution).
Public Interface
Class: LoadResult
Simple result wrapper.
| Field | Type | Description |
|---|---|---|
err |
str or None | Error message if operation failed |
data |
bytes or None | Response payload on success |
Class: LoaderHttpClient
| Method | Signature | Access | Description |
|---|---|---|---|
__init__ |
(str base_url) |
public | Stores base URL, strips trailing slash |
load_big_small_resource |
(str filename, str directory) -> LoadResult |
cdef | POST to /load/{filename} with JSON body, returns raw bytes |
upload_big_small_resource |
(bytes content, str filename, str directory) -> LoadResult |
cdef | POST to /upload/{filename} with multipart file |
fetch_user_ai_settings |
(str user_id, str bearer_token) -> object |
cpdef | GET /api/users/{user_id}/ai-settings, returns parsed JSON dict or None |
fetch_media_path |
(str media_id, str bearer_token) -> object |
cpdef | GET /api/media/{media_id}, returns path string from response or None |
Internal Logic
Model load/upload methods wrap all exceptions into LoadResult(err=str(e)). Errors are logged via loguru but never raised.
fetch_user_ai_settings and fetch_media_path (added in AZ-174) call the Annotations service API with Bearer auth. On non-200 response or exception, they return None.
Dependencies
- External:
requests,loguru - Internal: none (leaf module)
Consumers
inference— downloads ONNX/TensorRT models, uploads converted TensorRT enginesmain— instantiates two clients: one for Loader (LOADER_URL), one for Annotations (ANNOTATIONS_URL). Usesfetch_user_ai_settingsandfetch_media_pathon the annotations client.
Data Models
LoadResult— operation result with error-or-data semantics
Configuration
base_url— provided at construction time, sourced from env vars inmain.py
External Integrations
| Integration | Protocol | Endpoint Pattern |
|---|---|---|
| Loader service | HTTP POST | /load/{filename} (download), /upload/{filename} (upload) |
| Annotations service | HTTP GET | /api/users/{user_id}/ai-settings, /api/media/{media_id} |
Security
Bearer token forwarded in Authorization header for Annotations service calls.
Tests
tests/test_az174_db_driven_config.py— tests_resolve_media_for_detectwhich exercisesfetch_user_ai_settingsandfetch_media_path