-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix(notebooks): clean output metadata and validate notebooks for GitHub rendering #202
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
WalkthroughTwo new utility scripts are added to the Build-reasoning-model directory. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 4
🧹 Nitpick comments (1)
Build-reasoning-model/fix_notebooks.py (1)
10-26: Metadata fixing logic is sound.The logic correctly handles the two cases mentioned in the PR objectives:
- Replacing invalid metadata (None or containing None values) with empty dicts
- Adding missing metadata for display_data outputs
The use of
changedflag and defensivenb.get("cells", [])is good practice.For additional robustness, consider adding error handling for unexpected notebook structures:
for cell in nb.get("cells", []): outputs = cell.get("outputs") if not outputs or not isinstance(outputs, list): continue for output in outputs: if not isinstance(output, dict): continue # existing logic...
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
Build-reasoning-model/fix_notebooks.py(1 hunks)Build-reasoning-model/validate_nb.py(1 hunks)
🔇 Additional comments (1)
Build-reasoning-model/validate_nb.py (1)
1-3: LGTM!The imports are appropriate for the notebook validation functionality.
This PR fixes the "Invalid Notebook" issue #200 rendering error on GitHub caused by invalid/missing
metadatain cell outputs (the renderer requires certain keys indisplay_dataand disallows unexpected metadata fields).What I changed
metadatain cell outputs for notebook (in the Build-reasoning-model) that had invalid or missing entries (e.g.metadata: {"tags": null}or missingmetadatafordisplay_data).nbformat.validate()locally.scripts/:scripts/fix_notebooks.py— scans and fixes output metadata issues for all.ipynbfiles.scripts/validate_nb.py— validates notebooks usingnbformat.python3 scripts/fix_notebooks.py.python3 scripts/validate_nb.py— all notebooks show VALID.- However this resulted the notebook to trip down and remove some of the cell output from the original. As mainly this caused the problem in rendering.
- If this helps, let me know i will go through each of the these issues and will try to fix them.