c
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import json, sys, time
|
||||
|
||||
path = sys.argv[1]
|
||||
nb = json.load(open(path, encoding="utf-8"))
|
||||
g = {"__name__": "__main__"}
|
||||
|
||||
n = 0
|
||||
ok = True
|
||||
for c in nb["cells"]:
|
||||
if c["cell_type"] != "code":
|
||||
continue
|
||||
n += 1
|
||||
src = "".join(c["source"])
|
||||
t0 = time.time()
|
||||
try:
|
||||
exec(src, g)
|
||||
if "plt" in g and getattr(g["plt"], "show", None):
|
||||
g["plt"].show = lambda *a, **k: None
|
||||
except Exception as e:
|
||||
print("CELL", n, "FAILED:", type(e).__name__, e)
|
||||
ok = False
|
||||
break
|
||||
print(f" (cell {n} ok, {time.time()-t0:.1f}s)")
|
||||
if ok:
|
||||
print("ALL", n, "CODE CELLS RAN OK")
|
||||
Reference in New Issue
Block a user