| #!/usr/bin/env python3 | |
| """ | |
| Final execution of the complete CA11 notebook | |
| """ | |
| import nbformat | |
| from nbconvert.preprocessors import ExecutePreprocessor | |
| from pathlib import Path | |
| import sys | |
| def execute_final_notebook(notebook_path): | |
| """Execute the final complete notebook""" | |
| print(f"๐ฏ Final Execution of Complete Notebook") | |
| print("="*80) | |
| print(f"๐ Notebook: {notebook_path}") | |
| print("="*80) | |
| with open(notebook_path, 'r', encoding='utf-8') as f: | |
| nb = nbformat.read(f, as_version=4) | |
| # Configure executor with longer timeout | |
| ep = ExecutePreprocessor( | |
| timeout=900, # 15 minutes per cell | |
| kernel_name='python3', | |
| allow_errors=True # Continue on errors to see all outputs | |
| ) | |
| notebook_dir = Path(notebook_path).parent | |
| print("\nโ๏ธ Executing all cells...") | |
| print("This may take several minutes...\n") | |
| # Execute | |
| try: | |
| ep.preprocess(nb, {'metadata': {'path': str(notebook_dir)}}) | |
| print("\nโ Execution completed successfully!") | |
| except Exception as e: | |
| print(f"\nโ ๏ธ Execution completed with some issues: {e}") | |
| print("Continuing to save results...") | |
| # Save to the original CA11.ipynb location (overwriting with complete version) | |
| final_output = "notebooks/CA11.ipynb" | |
| with open(final_output, 'w', encoding='utf-8') as f: | |
| nbformat.write(nb, f) | |
| print(f"\n๐พ Final notebook saved to: {final_output}") | |
| # Generate detailed statistics | |
| print("\n" + "="*80) | |
| print("๐ DETAILED EXECUTION STATISTICS") | |
| print("="*80) | |
| code_cells = [c for c in nb.cells if c.cell_type == 'code'] | |
| markdown_cells = [c for c in nb.cells if c.cell_type == 'markdown'] | |
| executed_cells = [c for c in code_cells if c.get('outputs')] | |
| error_cells = [c for c in code_cells | |
| if any('ename' in out for out in c.get('outputs', []))] | |
| success_cells = [c for c in executed_cells if c not in error_cells] | |
| print(f"\n๐ Content Statistics:") | |
| print(f" Total cells: {len(nb.cells)}") | |
| print(f" Markdown cells: {len(markdown_cells)}") | |
| print(f" Code cells: {len(code_cells)}") | |
| print(f"\nโ๏ธ Execution Statistics:") | |
| print(f" Executed: {len(executed_cells)}/{len(code_cells)}") | |
| print(f" Successful: {len(success_cells)}") | |
| print(f" With errors: {len(error_cells)}") | |
| print(f" Success rate: {len(success_cells)/len(code_cells)*100:.1f}%") | |
| if error_cells: | |
| print(f"\nโ ๏ธ Cells with errors:") | |
| for i, cell in enumerate(error_cells, 1): | |
| # Find error info | |
| for output in cell.get('outputs', []): | |
| if 'ename' in output: | |
| print(f" {i}. {output['ename']}: {output.get('evalue', 'Unknown error')[:80]}") | |
| break | |
| else: | |
| print(f"\nโ No errors detected!") | |
| print("\n" + "="*80) | |
| print("๐ LESSON COMPLETION STATUS") | |
| print("="*80) | |
| topics_covered = [ | |
| "โ Theoretical Foundations of Chain of Thought", | |
| "โ Core Data Structures (ReasoningStep, ReasoningChain)", | |
| "โ Basic CoT Reasoner Implementation", | |
| "โ Neural Network Architecture for CoT", | |
| "โ Training Pipeline for Neural CoT", | |
| "โ Tree of Thought (Multi-path Exploration)", | |
| "โ Graph-based CoT with Self-Reflection", | |
| "โ Comprehensive Evaluation Framework", | |
| "โ Domain-Specific Applications (Medical, Business)", | |
| "โ Comparative Analysis & Visualization", | |
| "โ Best Practices & Implementation Tips", | |
| "โ Extended Exercises & Further Reading" | |
| ] | |
| for topic in topics_covered: | |
| print(f" {topic}") | |
| print("\n" + "="*80) | |
| print("๐ CONGRATULATIONS!") | |
| print("="*80) | |
| print("You have successfully completed the Chain of Thought lesson!") | |
| print("The notebook is now fully executed with all outputs captured.") | |
| print(f"\n๐ Final notebook location: {final_output}") | |
| print("\n๐ Next steps:") | |
| print(" 1. Review all cell outputs in Jupyter") | |
| print(" 2. Try the extended exercises") | |
| print(" 3. Adapt the code for your own projects") | |
| print(" 4. Explore the recommended papers and resources") | |
| return final_output | |
| if __name__ == "__main__": | |
| notebook_path = "notebooks/CA11_fixed_complete.ipynb" | |
| if len(sys.argv) > 1: | |
| notebook_path = sys.argv[1] | |
| final_path = execute_final_notebook(notebook_path) | |
| print(f"\n๐ฏ All done! Your complete notebook is ready: {final_path}") | |
Xet Storage Details
- Size:
- 4.64 kB
- Xet hash:
- 6104caf3f70e3ddc567f074f15c1d2cf74ecf8ef63dd0416715d58b348ef9854
ยท
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.