"""Upload this folder to a Hugging Face Space. python scripts/deploy_space.py owner/HumanTouch-next --create --private # staging python scripts/deploy_space.py owner/HumanTouch --pr # production, as a pull request Uses the token saved by `hf auth login`; the token is never read or printed here. Files superseded by the humantouch/ package are removed from the Space in the same commit. """ import argparse from pathlib import Path from huggingface_hub import HfApi ROOT = Path(__file__).resolve().parents[1] IGNORE = ['.venv/**', '**/__pycache__/**', '*.pyc', '.pytest_cache/**', '.ruff_cache/**', '.claude/**', 'evals/results/live-*', '.env'] SUPERSEDED = ['.omx/**', '.gstack/**', '__pycache__/**', '**/__pycache__/**', 'amplify.py', 'studio.py', 'studio_ui.py', 'voice.py', 'mcp_tools.py', 'mcp_review.py', 'DESIGN.md', 'scripts/check_interface.py', 'scripts/check_mcp.py', 'tests/fixtures/**', 'tests/test_amplify.py', 'tests/test_feature_integration.py', 'tests/test_humantouch.py', 'tests/test_legacy_contract.py', 'tests/test_voice.py', 'tests/test_writing_quality.py'] def main() -> None: parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('repo_id') parser.add_argument('--create', action='store_true', help='create the Space if it does not exist') parser.add_argument('--private', action='store_true') parser.add_argument('--pr', action='store_true', help='open a pull request instead of committing to main') parser.add_argument('--message', default='HumanTouch: authorial-preservation engine, change ledger, Voiceprint, evals') args = parser.parse_args() api = HfApi() if args.create: api.create_repo(args.repo_id, repo_type='space', space_sdk='gradio', private=args.private, exist_ok=True) commit = api.upload_folder(repo_id=args.repo_id, repo_type='space', folder_path=str(ROOT), ignore_patterns=IGNORE, delete_patterns=SUPERSEDED, commit_message=args.message, create_pr=args.pr) print('commit:', commit.oid) print('url:', getattr(commit, 'pr_url', None) or f'https://huggingface.co/spaces/{args.repo_id}') if __name__ == '__main__': main()