Files
Oleksandr Bezdieniezhnykh 1fe9425aa8 [AZ-172] Update documentation for distributed architecture, add Update Docs step to workflow
- 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
2026-03-31 17:25:58 +03:00

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 engines
  • main — instantiates two clients: one for Loader (LOADER_URL), one for Annotations (ANNOTATIONS_URL). Uses fetch_user_ai_settings and fetch_media_path on the annotations client.

Data Models

  • LoadResult — operation result with error-or-data semantics

Configuration

  • base_url — provided at construction time, sourced from env vars in main.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_detect which exercises fetch_user_ai_settings and fetch_media_path