Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nbdev/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def proc_nbs(
(cache/'_quarto.yml').unlink(missing_ok=True) # single-doc renders strip the staged copy in place (`_strip_sidebar`), so always restage it

files = files.map(_proc_file, mtime=cache_mtime, cache=cache, path=path).filter()
kw = {} if IN_NOTEBOOK else {'method':'spawn'}
kw = {} if in_notebook() else {'method':'spawn'}
parallel(nbdev.serve_drv.main, files, n_workers=n_workers, pause=0.01, **kw)
if cache.exists(): cache.touch()
return cache
6 changes: 3 additions & 3 deletions nbdev/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ def test_nb(
cell_timing_min:float=None # print cells slower than this many seconds (None: no timing output)
):
"Execute tests in notebook in `fn` except those with `skip_flags`"
if not IN_NOTEBOOK and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler)
if not in_notebook() and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler)
fn = Path(fn)
_cur_nb[0] = fn
if basepath: sys.path.insert(0, str(basepath))
prev_test = os.environ.get('IN_TEST')
if not IN_NOTEBOOK: os.environ['IN_TEST'] = '1'
if not in_notebook(): os.environ['IN_TEST'] = '1'
try:
nb = NBProcessor(fn, rm_directives=False, process=True).nb
fm = nb_frontmatter(nb)
Expand Down Expand Up @@ -167,7 +167,7 @@ def nbdev_test(
if len(files)==0: return print('No files were eligible for testing')

if n_workers is None: n_workers = 0 if len(files)==1 else min(num_cpus(), 8)
if IN_NOTEBOOK: kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'}
if in_notebook(): kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'}
else: kw = {'method':'spawn'} if sys.platform=='darwin' else {}
wd_pth = cfg.nbs_path
with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()):
Expand Down
6 changes: 3 additions & 3 deletions nbs/api/12_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@
" cell_timing_min:float=None # print cells slower than this many seconds (None: no timing output)\n",
"):\n",
" \"Execute tests in notebook in `fn` except those with `skip_flags`\"\n",
" if not IN_NOTEBOOK and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler)\n",
" if not in_notebook() and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler)\n",
" fn = Path(fn)\n",
" _cur_nb[0] = fn\n",
" if basepath: sys.path.insert(0, str(basepath))\n",
" prev_test = os.environ.get('IN_TEST')\n",
" if not IN_NOTEBOOK: os.environ['IN_TEST'] = '1'\n",
" if not in_notebook(): os.environ['IN_TEST'] = '1'\n",
" try:\n",
" nb = NBProcessor(fn, rm_directives=False, process=True).nb\n",
" fm = nb_frontmatter(nb)\n",
Expand Down Expand Up @@ -356,7 +356,7 @@
" if len(files)==0: return print('No files were eligible for testing')\n",
"\n",
" if n_workers is None: n_workers = 0 if len(files)==1 else min(num_cpus(), 8)\n",
" if IN_NOTEBOOK: kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'}\n",
" if in_notebook(): kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'}\n",
" else: kw = {'method':'spawn'} if sys.platform=='darwin' else {}\n",
" wd_pth = cfg.nbs_path\n",
" with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()):\n",
Expand Down
2 changes: 1 addition & 1 deletion nbs/api/17_serve.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
" (cache/'_quarto.yml').unlink(missing_ok=True) # single-doc renders strip the staged copy in place (`_strip_sidebar`), so always restage it\n",
"\n",
" files = files.map(_proc_file, mtime=cache_mtime, cache=cache, path=path).filter()\n",
" kw = {} if IN_NOTEBOOK else {'method':'spawn'}\n",
" kw = {} if in_notebook() else {'method':'spawn'}\n",
" parallel(nbdev.serve_drv.main, files, n_workers=n_workers, pause=0.01, **kw)\n",
" if cache.exists(): cache.touch()\n",
" return cache"
Expand Down
Loading