Files
detections/_docs/02_document/modules/loader_http_client.md
T

1.8 KiB

Module: loader_http_client

Purpose

HTTP client for downloading and uploading model files (and other binary resources) via an external Loader microservice.

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 Description
__init__ (str base_url) Stores base URL, strips trailing slash
load_big_small_resource (str filename, str directory) -> LoadResult POST to /load/{filename} with JSON body {filename, folder}, returns raw bytes
upload_big_small_resource (bytes content, str filename, str directory) -> LoadResult POST to /upload/{filename} with multipart file + form data {folder}
stop () -> None No-op placeholder

Internal Logic

Both load/upload methods wrap all exceptions into LoadResult(err=str(e)). Errors are logged via loguru but never raised.

Dependencies

  • External: requests, loguru
  • Internal: none (leaf module)

Consumers

  • inference — downloads ONNX/TensorRT models, uploads converted TensorRT engines
  • main — instantiates client with LOADER_URL

Data Models

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

Configuration

  • base_url — provided at construction time, sourced from LOADER_URL environment variable in main.py

External Integrations

Integration Protocol Endpoint Pattern
Loader service HTTP POST /load/{filename} (download), /upload/{filename} (upload)

Security

None (no auth headers sent to loader).

Tests

None found.