Files
pbl02/scripts/run_notebook_test.py
T
2026-10-08 16:43:48 +09:00

22 lines
638 B
Python

import json
import traceback
with open('uploads/OPS01/OPS01.ipynb', encoding='utf-8') as f:
nb = json.load(f)
print("=== Executing OPS01.ipynb cells sequentially ===")
global_scope = {}
for i, cell in enumerate(nb['cells']):
if cell['cell_type'] == 'code':
code_src = ''.join(cell['source'])
print(f"\n--- Running Code Cell {i} ---")
try:
exec(code_src, global_scope)
print(" [SUCCESS]")
except Exception as e:
print(f" [FAILED in cell {i}]: {e}")
traceback.print_exc()
break
print("\n=== All code cells executed successfully! ===")