- Introduced PROJECT_BASE_PATH constant for consistent project directory reference. - Updated Reports class to require template_path for loading HTML templates. - Modified DataManagerRepository to pass the new template_path when generating reports.
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
"""Filesystem layout for worker runtime data outside the application package tree."""
|
|
|
|
from os import makedirs
|
|
from os.path import join
|
|
|
|
# Root for all mutable runtime data (not under /app; avoids clashing with git clone under /app).
|
|
RUNTIME_DATA_ROOT = '/var/lib/model-manager'
|
|
|
|
# Training reports (HTML, CSV exports, etc.) and related outputs.
|
|
REPORTS_ROOT = join(RUNTIME_DATA_ROOT, 'reports')
|
|
|
|
# project base path
|
|
PROJECT_BASE_PATH = '/app/model_manager'
|
|
|
|
# Per-training run folders (name + timestamp); cleanup cron deletes stale entries here.
|
|
REPORTS_TEMP_DIR = join(REPORTS_ROOT, 'temp')
|
|
|
|
# Worker log files when file logging is wired; stdout remains primary until then.
|
|
LOGS_DIR = join(RUNTIME_DATA_ROOT, 'logs')
|
|
|
|
|
|
def ensure_runtime_directories() -> None:
|
|
"""Create runtime directories expected by the worker process."""
|
|
# REPORTS_ROOT: base directory for report artifacts; remove if all outputs move elsewhere.
|
|
makedirs(REPORTS_ROOT, exist_ok=True)
|
|
# REPORTS_TEMP_DIR: transient run subdirs; remove after retention/cleanup is centralized.
|
|
makedirs(REPORTS_TEMP_DIR, exist_ok=True)
|
|
# LOGS_DIR: on-disk logs; remove if logging stays stdout-only forever.
|
|
makedirs(LOGS_DIR, exist_ok=True)
|