"""Upload the prepared repository using the user's normal HF authentication.""" import argparse import os from pathlib import Path from huggingface_hub import HfApi, get_token parser=argparse.ArgumentParser();parser.add_argument('--repo',default='fffiloni/openusd-explorer');parser.add_argument('--update',action='store_true');args=parser.parse_args() root=Path(__file__).resolve().parents[1] # Use an explicit allow-list so a prior local build cannot upload binaries. source_paths=[] for directory, folders, names in os.walk(root): folders[:]=[name for name in folders if name not in {'node_modules','dist','.cache','.git','.openai','__pycache__'}] for name in names: path=Path(directory)/name if name.startswith('.env') or name.endswith(('.wasm','.pyc','.log','.zip','.tmp')): continue if path.is_symlink(): raise SystemExit(f'Refusing to upload a symlink: {path.relative_to(root)}') try: content=path.read_text(encoding='utf-8') except UnicodeDecodeError: raise SystemExit(f'Binary file excluded: remove {path.relative_to(root)} before upload.') if '\x00' in content: raise SystemExit(f'Binary file excluded: remove {path.relative_to(root)} before upload.') source_paths.append(path.relative_to(root).as_posix()) token=get_token() if not token: raise SystemExit('Authenticate securely first with hf auth login (a repository write token is required).') api=HfApi(token=token) account=api.whoami()['name'] if args.repo.split('/')[0]!=account: raise SystemExit('Repository owner must match the authenticated account for this deployment.') if api.repo_exists(args.repo,repo_type='space'): if not args.update: raise SystemExit('Space already exists. Inspect it first; use --update only for the intended existing Space.') else: api.create_repo(args.repo,repo_type='space',space_sdk='static',private=False) api.upload_folder(repo_id=args.repo,repo_type='space',folder_path=str(root),allow_patterns=sorted(source_paths),commit_message='Build objects: spatial OpenUSD explorer with articulated previews') print('Uploaded: https://huggingface.co/spaces/'+args.repo) print('Check the HF build and runtime status before considering deployment complete.')