Fix 5 oracle findings: parse tree/blob repo-page and spaces/-prefixed URLs, budget NSFW/custom LoRA merge time in get_duration, show LoRA label for custom-only runs, correct kohya alpha/rank scaling
3cd4c9d verified Download revert_to_baseline.py from Napol3/Test3lora: direct link, hf CLI and curl.
- Browser
- Download file 2.05 kB
-
https://huggingface.co/spaces/Napol3/Test3lora/resolve/main/revert_to_baseline.py
- Command line
-
hf download hf://spaces/Napol3/Test3lora/revert_to_baseline.py
-
curl -L -o revert_to_baseline.py https://huggingface.co/spaces/Napol3/Test3lora/resolve/main/revert_to_baseline.py
2.05 kB
| """Revert the MiniMax-H3 Space to the known-good baseline commit. | |
| Usage: | |
| set HF_TOKEN=hf_xxx (token with write access to the Space) | |
| python revert_to_baseline.py | |
| What it does: | |
| 1. Clones the Space repo (source only — model weights are fetched at runtime). | |
| 2. Fetches and hard-resets to the pinned baseline commit. | |
| 3. Force-pushes that commit to the Space's main branch (--force-with-lease, | |
| so it refuses if the remote moved unexpectedly). | |
| The baseline commit is pinned below. Change TARGET only if you intend to roll | |
| forward to a different known-good commit. | |
| """ | |
| import os | |
| import subprocess | |
| import tempfile | |
| REPO = "observantdistressed/minimax-h3" | |
| TARGET = "cded1e52839f650000ccd8aefa2026cbadb61a0d" | |
| def run(cmd, cwd=None): | |
| print("+", " ".join(cmd), flush=True) | |
| # Disable the (misconfigured) git credential manager and any interactive prompt. Auth is carried | |
| # in the remote URL (token as both user and password), so git uses it directly with no prompt. | |
| env = dict(os.environ, GIT_TERMINAL_PROMPT="0") | |
| if cmd and cmd[0] == "git": | |
| cmd = cmd[:1] + ["-c", "credential.helper="] + cmd[1:] | |
| subprocess.run(cmd, cwd=cwd, check=True, env=env) | |
| def revert(): | |
| token = os.environ.get("HF_TOKEN") | |
| if not token: | |
| raise SystemExit( | |
| "HF_TOKEN is not set. Export a token with write access to the Space:\n" | |
| " Windows: set HF_TOKEN=hf_xxx\n" | |
| " Linux/mac: export HF_TOKEN=hf_xxx" | |
| ) | |
| # Token as both user and password in the URL — HF accepts the token as the password. | |
| url = f"https://{token}:{token}@huggingface.co/spaces/{REPO}" | |
| with tempfile.TemporaryDirectory() as tmp: | |
| run(["git", "clone", "--depth", "1", url, tmp]) | |
| run(["git", "-C", tmp, "fetch", "origin", TARGET]) | |
| run(["git", "-C", tmp, "reset", "--hard", TARGET]) | |
| run(["git", "-C", tmp, "push", "--force-with-lease", "origin", f"{TARGET}:main"]) | |
| print(f"Reverted {REPO} to {TARGET}") | |
| if __name__ == "__main__": | |
| revert() | |