tahamajs's picture
download
raw
4.64 kB
#!/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.