improved logging

This commit is contained in:
Ayzen
2026-06-06 00:52:52 +03:00
parent af6005d68f
commit aea49f6128
65 changed files with 1206 additions and 240 deletions
@@ -4,6 +4,7 @@ from __future__ import annotations
from contextlib import suppress
import json
import logging
import os
from pathlib import Path
@@ -16,6 +17,8 @@ from python_app.orchestration.preprocess_assets import (
)
from python_app.storage.npz_store import NpzStore
logger = logging.getLogger(__name__)
class ConfigWriter:
"""Write runtime artifacts consumed by C++ processes."""
@@ -39,6 +42,7 @@ class ConfigWriter:
spec = PREPROCESS_ASSET_SPECS[key]
asset = preprocess_asset_model(config, key)
bundle_path = self._runtime_dir / spec.runtime_filename
logger.debug("Exporting preprocess bundle %s (set=%s) -> %s", key, asset.set_name, bundle_path)
store.export_set_bundle(spec.set_kind, radar_key, asset.set_name, bundle_path)
asset.bundle_path = str(bundle_path)
@@ -63,10 +67,12 @@ class ConfigWriter:
os.fsync(handle.fileno())
os.replace(tmp_path, output_path)
except Exception:
logger.exception("Failed to write run config to %s; removing temp file", output_path)
# Never leave a half-written .tmp behind on a write/fsync failure.
with suppress(OSError):
tmp_path.unlink()
raise
logger.debug("Wrote run config to %s (%d bytes)", output_path, len(serialized))
return output_path