File size: 770 Bytes
877add7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""Canonical SFT training module."""

from __future__ import annotations

import subprocess
import sys
import os
from pathlib import Path


def run_sft_train(checkpoint_dir: Path | None = None) -> dict[str, str]:
    """Run SFT training via the script entrypoint.

    ``checkpoint_dir`` is accepted for interface stability; the current
    implementation writes to the repository checkpoint folder.
    """
    _ = checkpoint_dir
    root = Path(__file__).resolve().parents[2]
    script = root / "scripts" / "train_sft.py"
    env = dict(os.environ)
    env["PYTHONPATH"] = f"{root}:{env.get('PYTHONPATH', '')}".rstrip(":")
    subprocess.run([sys.executable, str(script)], check=True, cwd=str(root), env=env)
    return {"status": "ok"}


__all__ = ["run_sft_train"]