fix: resolve model weight paths against DATA_DIR (REQ-187)

- config.py: resolve_data_path (legacy abs + rel) + rel_data_path
- all file-opening reads wrapped: preview, autolabel, training, model
  download, live count, projects.get; training_start_point hack replaced
- new writes store paths relative to data/
- legacy stale rows (/home/asus/reTraining/...) resolve without migration
- requirements: REQ-187 added; REQ-188 (per-class max box) + REQ-186
  copy-line amendment drafted for the next task
This commit is contained in:
asus committed 2026-10-02 16:59:25 +07:00
1 parent 8f41c6c85a
commit dee58e4ae5
10 files changed
+93 -32

No files matched your search

+4 -3
View File
@@ -8,7 +8,7 @@ from fastapi.responses import StreamingResponse
from pydantic import BaseModel
from typing import Optional
from backend import library, live_count, training
from backend import config, library, live_count, training
from backend.api.common import project_or_404
router = APIRouter(tags=["live-count"])
@@ -45,10 +45,11 @@ def available_models(project_id: int) -> dict:
project = project_or_404(project_id)
out = []
for version in training.listing(project_id):
if version.get("weights_path") and os.path.isfile(version["weights_path"]):
path = config.resolve_data_path(version["weights_path"])
if version.get("weights_path") and os.path.isfile(path):
out.append({
"label": version.get("name") or f"v{version['version']}",
"path": version["weights_path"],
"path": path,
"version_id": version["id"],
})
base = project.get("base_model_path")