"""Tiny helper for deploying the app to a Hugging Face Space. Usage (PowerShell, from the project root): # one-time pip install "huggingface_hub[cli]" huggingface-cli login # create the Space (do this once) huggingface-cli repo create us-flow-scanner --type space --space-sdk gradio # initialise git in this folder and push git init git checkout -b main git add . git commit -m "Initial deploy" git remote add space https://huggingface.co/spaces//us-flow-scanner git push --set-upstream space main # subsequent updates git add . git commit -m "..." git push space main """ from __future__ import annotations import os import subprocess import sys def _run(cmd: list[str]) -> None: print(f"\n$ {' '.join(cmd)}") subprocess.run(cmd, check=False) def main() -> None: username = os.environ.get("HF_USERNAME") space = os.environ.get("HF_SPACE_NAME", "us-flow-scanner") if not username: print("Set HF_USERNAME env var (your HF handle).", file=sys.stderr) sys.exit(1) repo_id = f"{username}/{space}" _run(["huggingface-cli", "repo", "create", space, "--type", "space", "--space-sdk", "gradio", "--exist-ok"]) if not os.path.isdir(".git"): _run(["git", "init"]) _run(["git", "checkout", "-b", "main"]) _run(["git", "add", "."]) _run(["git", "commit", "-m", "Deploy to HF Space", "--allow-empty"]) remote = f"https://huggingface.co/spaces/{repo_id}" _run(["git", "remote", "add", "space", remote]) _run(["git", "push", "--set-upstream", "space", "main", "--force"]) if __name__ == "__main__": main()