| """Build poster_embed.html (self-contained, base64 PNG) and splice it into the | |
| pinned figure cell of the executive-summary page.""" | |
| import base64 | |
| import os | |
| import re | |
| import sys | |
| ROOT = "/home/ubuntu/samuel/perfpred-complexity-repro" | |
| PNG = sys.argv[1] if len(sys.argv) > 1 else os.path.join(ROOT, "poster/poster.png") | |
| EMBED = os.path.join(ROOT, "poster/poster_embed.html") | |
| PAGE = os.path.join(ROOT, ".trackio/logbook/pages/executive-summary/page.md") | |
| with open(PNG, "rb") as f: | |
| b64 = base64.b64encode(f.read()).decode() | |
| html = ( | |
| "<!-- Reproduction poster built with Chenruishuo/posterly; " | |
| "source: poster_embed.html -->\n" | |
| '<img src="data:image/png;base64,%s" ' | |
| 'alt="Reproduction poster: On the Computational Complexity of Performative Prediction" ' | |
| 'width="100%%" />\n' % b64 | |
| ) | |
| with open(EMBED, "w") as f: | |
| f.write(html) | |
| print("wrote %s (%.1f MB)" % (EMBED, len(html) / 1e6)) | |
| with open(PAGE) as f: | |
| page = f.read() | |
| marker = '{"type": "figure"' | |
| i = page.index(marker) | |
| j = page.index("-->", i) + 3 | |
| head, tail = page[:j], page[j:] | |
| new_body = "\n````html\n" + html + "````\n" | |
| page = head + new_body | |
| with open(PAGE, "w") as f: | |
| f.write(page) | |
| print("spliced into", PAGE) | |
| print("poster_embed occurrences:", page.count("poster_embed.html")) | |
Xet Storage Details
- Size:
- 1.27 kB
- Xet hash:
- 0df49c602136d4cfb5044c0fc8ddf92ade356d02ba1197b170d159dea79c06fb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.