Spaces:
Running
Running
Download preflight.py from Hugdrigo/modelops-research-lab: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/spaces/Hugdrigo/modelops-research-lab/resolve/main/preflight.py
- Command line
-
hf download hf://spaces/Hugdrigo/modelops-research-lab/preflight.py
-
curl -L -o preflight.py https://huggingface.co/spaces/Hugdrigo/modelops-research-lab/resolve/main/preflight.py
1.48 kB
| #!/usr/bin/env python3 | |
| """Zero-dependency Hugging Face Static Space preflight.""" | |
| from pathlib import Path | |
| import json,re,hashlib | |
| root=Path(__file__).resolve().parent | |
| readme=(root/'README.md').read_text(encoding='utf-8') | |
| assert readme.startswith('---\n'), 'Missing README front matter' | |
| front=readme.split('---',2)[1] | |
| values=dict(re.findall(r'^([A-Za-z_]+):\s*(.*?)\s*$',front,re.M)) | |
| assert values['sdk']=='static', 'Space needs sdk: static' | |
| assert values['app_file']=='index.html', 'Wrong app file' | |
| assert values['license']=='mit', 'Wrong code license' | |
| assert len(values['short_description'])<=60, 'Short description too long' | |
| assert values['colorFrom'] in {'red','yellow','green','blue','indigo','purple','pink','gray'} | |
| assert values['colorTo'] in {'red','yellow','green','blue','indigo','purple','pink','gray'} | |
| for name in ('index.html','styles.css','engine.js','app.js','train.json','iid_test.json','challenge.json'): | |
| assert (root/name).is_file(), 'Missing '+name | |
| manifest=json.loads((root/'dataset_manifest.json').read_text()) | |
| for name,digest in manifest['files_sha256'].items(): | |
| assert hashlib.sha256((root/name).read_bytes()).hexdigest()==digest, f'Data checksum changed: {name}' | |
| for name,count in [('train.json',842),('iid_test.json',130),('challenge.json',54)]: | |
| assert len(json.loads((root/name).read_text()))==count,name | |
| print('PASS: Static SDK, app entry point, license, 60-char description, colors, source files, dataset SHA256 and partition counts.') | |