Buckets:
| #!/usr/bin/env python3 | |
| """ | |
| Check for errors in the executed notebook | |
| """ | |
| import nbformat | |
| import json | |
| def check_notebook_errors(notebook_path): | |
| """Find all cells with errors""" | |
| with open(notebook_path, "r", encoding="utf-8") as f: | |
| nb = nbformat.read(f, as_version=4) | |
| errors = [] | |
| for i, cell in enumerate(nb.cells): | |
| if cell.cell_type == "code" and cell.get("outputs"): | |
| for output in cell.outputs: | |
| if output.output_type == "error": | |
| error_info = { | |
| "cell_index": i, | |
| "error_name": output.get("ename", "Unknown"), | |
| "error_value": output.get("evalue", ""), | |
| "traceback": output.get("traceback", []), | |
| "cell_source": ( | |
| cell.source[:200] + "..." | |
| if len(cell.source) > 200 | |
| else cell.source | |
| ), | |
| } | |
| errors.append(error_info) | |
| return errors | |
| if __name__ == "__main__": | |
| notebook_path = "notebooks/CA6.ipynb" | |
| print("=" * 80) | |
| print("CHECKING NOTEBOOK FOR ERRORS") | |
| print("=" * 80) | |
| errors = check_notebook_errors(notebook_path) | |
| if not errors: | |
| print("\n✅ No errors found!") | |
| else: | |
| print(f"\n⚠️ Found {len(errors)} cells with errors:\n") | |
| for i, error in enumerate(errors, 1): | |
| print(f"\n{'='*80}") | |
| print(f"ERROR {i}: Cell {error['cell_index']}") | |
| print(f"{'='*80}") | |
| print(f"Error Type: {error['error_name']}") | |
| print(f"Error Message: {error['error_value']}") | |
| print(f"\nCell Source (first 200 chars):") | |
| print(error["cell_source"]) | |
| print(f"\nTraceback:") | |
| for line in error["traceback"][-5:]: # Last 5 lines | |
| print(line) | |
Xet Storage Details
- Size:
- 1.93 kB
- Xet hash:
- 569e3dc450f949332f0118bc7a98480bded9141d6ff4d2c9211e7c75392e8573
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.