Files
wehub-resource-sync 86db9aae8e
Documentation / build (push) Has been cancelled
Documentation / deploy (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:34:55 +08:00

24 lines
850 B
Python

import os
import nbformat
def fix_notebook_metadata(file_path):
with open(file_path, 'r', encoding='utf-8') as f:
nb = nbformat.read(f, as_version=nbformat.NO_CONVERT)
# Remove broken widgets metadata
if 'widgets' in nb.metadata:
if 'application/vnd.jupyter.widget-state+json' in nb.metadata['widgets']:
widget_meta = nb.metadata['widgets']['application/vnd.jupyter.widget-state+json']
if 'state' not in widget_meta:
print(f"[FIXING] {file_path}")
widget_meta['state'] = {}
with open(file_path, 'w', encoding='utf-8') as f:
nbformat.write(nb, f)
# Walk through all notebooks
for root, _, files in os.walk("../examples/Notebooks"):
for file in files:
if file.endswith(".ipynb"):
fix_notebook_metadata(os.path.join(root, file))