Spaces:
Running on Zero
Running on Zero
Download package_space.py from ManasT2485/readloops: direct link, hf CLI and curl.
- Browser
- Download file 2.19 kB
-
https://huggingface.co/spaces/ManasT2485/readloops/resolve/main/package_space.py
- Command line
-
hf download hf://spaces/ManasT2485/readloops/package_space.py
-
curl -L -o package_space.py https://huggingface.co/spaces/ManasT2485/readloops/resolve/main/package_space.py
2.19 kB
| """Build an explicit source-only upload folder. Never includes runtime data.""" | |
| import argparse | |
| import hashlib | |
| import json | |
| import shutil | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parent | |
| FILES = ( | |
| 'README.md', 'LICENSE', 'THIRD_PARTY.md', '.gitignore', | |
| 'react_space.py', 'space_api.py', 'visitors.py', 'database.py', 'sessions.py', | |
| 'jobs.py', 'learning.py', 'ope.py', 'pilot_runtime.py', 'audio_io.py', 'inference.py', | |
| 'content.py', 'scoring.py', 'exercises.py', 'policy.py', 'requirements.txt', | |
| 'assets/panda.svg', 'tests/test_space.py', 'tests/react-browser.mjs', | |
| 'package_space.py', 'VALIDATION.md', 'DESIGN_MANIFEST.json', | |
| 'frontend/package.json', 'frontend/package-lock.json', 'frontend/vite.config.js', | |
| 'frontend/index.html', 'frontend/public/panda.svg', | |
| 'licenses/Nunito.txt', 'licenses/NotoSans.txt', 'licenses/React.txt', | |
| ) | |
| def build(output): | |
| """Refuse existing output directories to prevent accidentally uploading stale files.""" | |
| output = Path(output).resolve() | |
| if not output.is_relative_to(ROOT / 'dist'): | |
| raise ValueError('The upload folder must be inside this repository\'s dist directory.') | |
| sources = list(FILES) | |
| for folder in ('frontend/src', 'frontend/dist'): | |
| sources.extend(str(p.relative_to(ROOT)).replace('\\', '/') for p in sorted((ROOT / folder).rglob('*')) if p.is_file()) | |
| for name in sources: | |
| if not (ROOT / name).is_file(): | |
| raise FileNotFoundError(name) | |
| output.mkdir(parents=True, exist_ok=False) | |
| manifest = {} | |
| for name in sources: | |
| destination = output / name | |
| destination.parent.mkdir(parents=True, exist_ok=True) | |
| shutil.copyfile(ROOT / name, destination) | |
| manifest[name] = hashlib.sha256(destination.read_bytes()).hexdigest() | |
| (output / 'SOURCE_MANIFEST.json').write_text(json.dumps(manifest, indent=2) + '\n', encoding='utf-8') | |
| print(f'Prepared {len(sources)} source/build files and a hash manifest in {output}') | |
| if __name__ == '__main__': | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument('--output', default=str(ROOT / 'dist' / 'react-space')) | |
| build(parser.parse_args().output) | |