permanence / tools /upload_eval_only.py
chane335's picture
Run 7: R4/R5 calibration + env precondition fix β€” forced variants preserved, git_push_force β†’ R2 when no overwrite
8867e44 verified
"""Push Run 6.1 (env precondition fix) to training Space with eval-only entrypoint.
Uploads:
* current repo state (so env fix + new tests are on the Space)
* entrypoint_eval_only.sh AS entrypoint.sh on the Space root
After this, restart the Space β€” it downloads the Run 6 adapter from HF Hub,
runs `--only eval`, re-uploads eval/results.json + comparison.csv.
"""
from __future__ import annotations
import os
import pathlib
import subprocess
import sys
from huggingface_hub import HfApi
_PROJECT_ROOT = pathlib.Path(__file__).resolve().parent.parent
os.chdir(_PROJECT_ROOT)
COMMON_IGNORE = [
".git/*", ".git",
"__pycache__/*", "__pycache__", "*.pyc", "*.egg-info/*",
"permanence_output/*", ".pytest_cache/*",
"node_modules/*", "dashboard/dist/*",
"training_runs/*",
"results/*.json",
"tools/upload_all.py",
"tools/check_training.sh",
"tools/plot_runs.py",
"tools/extract_metrics.py",
"*.pdf",
"hackathon_pdf.txt",
]
def _token() -> str:
tok = os.environ.get("HF_TOKEN")
if tok:
return tok
return subprocess.check_output(["hf", "auth", "token"], text=True).strip().splitlines()[0]
def main() -> None:
token = _token()
api = HfApi(token=token)
print("── Uploading Run 6.1 repo to chane335/permanence-training ──")
api.upload_folder(
folder_path=".",
repo_id="chane335/permanence-training",
repo_type="space",
ignore_patterns=COMMON_IGNORE + ["deploy/serving/*"],
commit_message="Run 6.1: env precondition fix (destructive DB ops on missing tables short-circuit)",
)
api.upload_file(
path_or_fileobj="deploy/training/Dockerfile",
path_in_repo="Dockerfile",
repo_id="chane335/permanence-training",
repo_type="space",
commit_message="Promote training Dockerfile",
)
# KEY: use the eval-only entrypoint for 6.1
api.upload_file(
path_or_fileobj="deploy/training/entrypoint_eval_only.sh",
path_in_repo="entrypoint.sh",
repo_id="chane335/permanence-training",
repo_type="space",
commit_message="Use eval-only entrypoint for Run 6.1",
)
api.upload_file(
path_or_fileobj="deploy/training/README.md",
path_in_repo="README.md",
repo_id="chane335/permanence-training",
repo_type="space",
commit_message="Training Space README",
)
print("βœ“ Uploaded. Now restart the Space to trigger eval-only run.")
if __name__ == "__main__":
main()