INNER CODE UNIT · Python
_ensure_parent_directory
skygazer42/MimirQ · app/main.py:238
def _ensure_parent_directory(path_value: object, *, warning_message: str) -> None:
try:
Path(str(path_value)).parent.mkdir(parents=True, exist_ok=True)
except Exception as exc: # noqa: BLE001
logger.warning("%s: %s", warning_message, str(exc)[:200])
def _ensure_optional_log_directories() -> None:
if bool(getattr(settings, "ENABLE_METRICS_LOG", False)):
_ensure_parent_directory(
getattr(settings, "METRICS_LOG_PATH", "./logs/rag_metrics.jsonl"),
warning_message="Failed to ensure metrics log dir",
)
if bool(getattr(settings, "MINIO_ENABLED", False)):
_ensure_parent_directory(
getattr(settings, "MINIO_METRICS_LOG_PATH", "./logs/minio_metrics.jsonl"),
warning_message="Failed to ensure MinIO metrics log dir",
)