Files
LegacyHUB/app/storage/local_paths.py
Vadim Malanov 7f72171572 chore: bootstrap repository with governance docs
Initialize git, add Apache-2.0 LICENSE, .gitattributes (LF line
endings), AGENTS.md (entry points, stack, discovery order, baseline
checks), RUNBOOK.md (dev boot, prod deploy with overlay, ingestion,
failures, rollback, scaling notes), .env.prod.example with rotated
credential placeholders, and dev-only warnings on .env.example.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 16:41:50 +03:00

43 lines
1.2 KiB
Python

"""Storage key conventions for MinIO and local working paths."""
from __future__ import annotations
import uuid
from pathlib import Path
from app.config import settings
def work_dir_for(document_id: uuid.UUID | str) -> Path:
p = Path(settings.app_work_dir) / str(document_id)
p.mkdir(parents=True, exist_ok=True)
return p
def key_original_pdf(document_id: uuid.UUID | str, sha256: str) -> str:
return f"docs/{document_id}/original/{sha256}.pdf"
def key_ocr_pdf(document_id: uuid.UUID | str) -> str:
return f"docs/{document_id}/ocr/ocr.pdf"
def key_docling_json(document_id: uuid.UUID | str) -> str:
return f"docs/{document_id}/docling/document.json"
def key_markdown(document_id: uuid.UUID | str) -> str:
return f"docs/{document_id}/docling/document.md"
def key_page_image(document_id: uuid.UUID | str, page_number: int) -> str:
return f"docs/{document_id}/pages/p{page_number:05d}.png"
def key_figure_crop(document_id: uuid.UUID | str, page_number: int, figure_index: int) -> str:
return f"docs/{document_id}/figures/p{page_number:05d}_f{figure_index:03d}.png"
def key_table_json(document_id: uuid.UUID | str, table_index: int) -> str:
return f"docs/{document_id}/tables/t{table_index:04d}.json"