Spaces:
Running
Running
Download build.py from FineEnvs/retroenv-rollouts: direct link, hf CLI and curl.
- Browser
- Download file 838 Bytes
-
https://huggingface.co/spaces/FineEnvs/retroenv-rollouts/resolve/main/build.py
- Command line
-
hf download hf://spaces/FineEnvs/retroenv-rollouts/build.py
-
curl -L -o build.py https://huggingface.co/spaces/FineEnvs/retroenv-rollouts/resolve/main/build.py
838 Bytes
| """Inline the three startup files into index.html so the first paint needs no fetch.""" | |
| import io, json, pathlib | |
| root = pathlib.Path(__file__).parent | |
| src = (root / 'index.src.html').read_text(encoding='utf-8') | |
| blocks = [] | |
| for el, name in (('d-index', 'index.json'), ('d-checkpoints', 'checkpoints.json'), ('d-frontier', 'frontier.json')): | |
| data = json.loads((root / name).read_text(encoding='utf-8')) | |
| # </script> inside JSON would close the tag early | |
| text = json.dumps(data, separators=(',', ':')).replace('</', '<\\/') | |
| blocks.append(f'<script id="{el}" type="application/json">{text}</script>') | |
| out = src.replace('<!--INLINE-DATA-->', '\n'.join(blocks)) | |
| assert '<!--INLINE-DATA-->' not in out | |
| (root / 'index.html').write_text(out, encoding='utf-8') | |
| print(f'index.html {len(out)/1e6:.2f} MB (inlined {len(blocks)} files)') | |