Skip to content

Commit

Permalink
Update win_batch_md2ipynb.py
Browse files Browse the repository at this point in the history
  • Loading branch information
astonzhang authored Dec 19, 2018
1 parent cb46c13 commit 412d16c
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions build/win_batch_md2ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def mkdir_if_not_exist(path):
os.makedirs(os.path.join(*path))

# Timeout for each notebook, in sec
timeout = 20 * 60
timeout = 60 * 60

# The files will be ingored for execution
ignore_execution = ['chapter_computational-performance/async-computation.md']
Expand All @@ -32,19 +32,24 @@ def mkdir_if_not_exist(path):
if md != 'index.md':
in_md = os.path.join(chap, md)
out_nb = os.path.join('win_ipynb', in_md[3:-2] + 'ipynb')
print('---', in_md[3:])
# read
with open(in_md, 'r', encoding="utf8") as f:
notebook = reader.read(f)

if do_eval and chap[3:] + '/' + md not in ignore_execution:
tic = time.time()
notedown.run(notebook, timeout)
print('=== Finished evaluation in %f sec'%(time.time()-tic))

# write
# need to add language info to for syntax highlight
notebook['metadata'].update({'language_info':{'name':'python'}})

with open(out_nb, 'w', encoding="utf8") as f:
f.write(nbformat.writes(notebook))

if not os.path.exists(out_nb):

print('---', in_md[3:])
# read
with open(in_md, 'r', encoding="utf8") as f:
notebook = reader.read(f)

if do_eval and chap[3:] + '/' + md not in ignore_execution:
tic = time.time()
notedown.run(notebook, timeout)
print('=== Finished evaluation in %f sec'%(time.time()-tic))

# write
# need to add language info to for syntax highlight
notebook['metadata'].update({'language_info':{'name':'python'}})

with open(out_nb, 'w', encoding="utf8") as f:
f.write(nbformat.writes(notebook))


0 comments on commit 412d16c

Please sign in to comment.