Spaces:
Sleeping
Sleeping
Download scripts/deploy.py from boyuu/claude-document-studio: direct link, hf CLI and curl.
- Browser
- Download file 1.94 kB
-
https://huggingface.co/spaces/boyuu/claude-document-studio/resolve/main/scripts/deploy.py
- Command line
-
hf download hf://spaces/boyuu/claude-document-studio/scripts/deploy.py
-
curl -L -o deploy.py https://huggingface.co/spaces/boyuu/claude-document-studio/resolve/main/scripts/deploy.py
1.94 kB
| """Create a private HF Space and upload only the application source files.""" | |
| import argparse | |
| import getpass | |
| import os | |
| from pathlib import Path | |
| import subprocess | |
| ROOT = Path(__file__).resolve().parents[1] | |
| FILES = ["README.md", "app.py", "router.py", "attachments.py", "requirements.txt", | |
| "packages.txt", ".gitignore", ".env.example", "scripts/deploy.py", "scripts/smoke_remote.py"] | |
| def run(args: list[str], **kwargs) -> subprocess.CompletedProcess: | |
| return subprocess.run(["hf", *args], check=True, text=True, **kwargs) | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument("repo_id", help="Hugging Face username/space-name") | |
| parser.add_argument("--hardware", choices=["cpu-basic", "zero-a10g"], default="cpu-basic") | |
| args = parser.parse_args() | |
| if args.repo_id.count("/") != 1: | |
| parser.error("repo_id must be username/space-name") | |
| run(["auth", "whoami"]) | |
| key = os.environ.get("OPENROUTER_API_KEY") or getpass.getpass("OpenRouter API Key (hidden): ") | |
| if not key.strip() or "\n" in key or "\r" in key: | |
| raise SystemExit("A valid single-line OpenRouter API Key is required.") | |
| # --secrets-file - keeps values off disk and out of the process arguments. | |
| create = ["repos", "create", args.repo_id, "--type", "space", "--space-sdk", "gradio", | |
| "--private", "--flavor", args.hardware, "--secrets-file", "-"] | |
| if args.hardware == "zero-a10g": | |
| create += ["--env", "USE_ZEROGPU=1"] | |
| run(create, input="OPENROUTER_API_KEY=" + key.strip() + "\n") | |
| del key | |
| upload = ["upload", args.repo_id, str(ROOT), ".", "--repo-type", "space", | |
| "--commit-message", "Add Claude document chat with OpenRouter"] | |
| for filename in FILES: | |
| upload.extend(["--include", filename]) | |
| run(upload) | |
| print("Space: https://huggingface.co/spaces/" + args.repo_id) | |
| if __name__ == "__main__": | |
| main() | |