SolusOps's picture
download
raw
1.71 kB
"""Refresh only study.html from the saved public notebook and existing web styling."""
from pathlib import Path
import copy
import hashlib
import re
import nbformat
from nbconvert import HTMLExporter
from editorial_records import load
from editorial_views import WEB_CSS, web_exhibit
BASE=Path(__file__).resolve().parents[1]
def export():
notebook=BASE/'study.ipynb'
study=nbformat.read(notebook,as_version=4)
evidence=load()
webpage=copy.deepcopy(study)
for cell in webpage.cells:
kind=cell.metadata.get('web_exhibit')
if kind:
cell.outputs=[nbformat.v4.new_output('display_data',data={'text/html':web_exhibit(kind,evidence)},metadata={})]
body,_=HTMLExporter(exclude_input=True).from_notebook_node(webpage,resources={'metadata':{'name':'Hindi, Hinglish and the English-trained robot'}})
body=re.sub(r'<script\b[^>]*>.*?</script\s*>','',body,flags=re.S|re.I)
version=hashlib.sha256(notebook.read_bytes()).hexdigest()
marker='<meta name="study-notebook-sha256" content="'+version+'">'
body=body.replace('</head>',marker+WEB_CSS+'</head>')
nav='<nav aria-label="Study navigation"><a href="#Part-I.-The-Problem-and-Introduction">Problem</a><a href="#Part-II.-The-Weakness-in-Current-Evaluation-and-Our-Investigation">Investigation</a><a href="#Part-III.-The-Proposed-Solution-and-Supporting-Evidence">Proposed solution</a><a href="study.ipynb">Research notebook</a><a href="supplementary_details.ipynb">Experimental record</a></nav>'
(BASE/'study.html').write_text(body.replace('<main>','<main>'+nav,1),encoding='utf-8')
return version
if __name__=='__main__':
print('Updated study.html from notebook SHA256 '+export())

Xet Storage Details

Size:
1.71 kB
·
Xet hash:
6265a89b64957230c891eb7e68d6f7f6a5389325ccb101c28effa19a4c1195fb

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.