Files
sientia-dataops-model-manager/model_manager/runtime_paths.py

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)