From 0a10d53e05de54a66d769020269a8c68a3c69189 Mon Sep 17 00:00:00 2001 From: Nathan Cooper Date: Mon, 24 Aug 2026 14:25:09 -0400 Subject: [PATCH] change to in_notebook fn --- nbdev/__init__.py | 2 +- nbdev/serve.py | 2 +- nbdev/test.py | 6 +++--- nbs/api/12_test.ipynb | 6 +++--- nbs/api/17_serve.ipynb | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/nbdev/__init__.py b/nbdev/__init__.py index e3d7f2218..088676342 100644 --- a/nbdev/__init__.py +++ b/nbdev/__init__.py @@ -4,7 +4,7 @@ - `nbdev.extract_attachments`: A preprocessor that extracts all of the attachments from the notebook file. The extracted attachments are returned in the 'resources' dictionary. - `nbdev.moddocs`: # Module docs: creating them from existing notebooks -- `nbdev.skill`: Author clear, executable nbdev notebooks where code, prose, examples, outputs, and tests form one coherent narrative.""" +- `nbdev.skill`: Author clear, executable nbdev notebooks where code, prose, examples, outputs, and tests form one coherent narrative. Trigger: ALWAYS read this before ANY notebook edit.""" __version__ = "3.3.13" diff --git a/nbdev/serve.py b/nbdev/serve.py index d80d3cd07..cc073df0b 100644 --- a/nbdev/serve.py +++ b/nbdev/serve.py @@ -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 diff --git a/nbdev/test.py b/nbdev/test.py index dbbe3e158..9b139374a 100644 --- a/nbdev/test.py +++ b/nbdev/test.py @@ -68,12 +68,12 @@ def test_nb( cell_timeout:int=600 # seconds before each cell times out (None: no limit) ): "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: flags=set(L(skip_flags)) - set(L(force_flags)) nb = NBProcessor(fn, rm_directives=False, process=True).nb @@ -143,7 +143,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()): diff --git a/nbs/api/12_test.ipynb b/nbs/api/12_test.ipynb index d112c514a..0e9c05f8f 100644 --- a/nbs/api/12_test.ipynb +++ b/nbs/api/12_test.ipynb @@ -112,12 +112,12 @@ " cell_timeout:int=600 # seconds before each cell times out (None: no limit)\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", " flags=set(L(skip_flags)) - set(L(force_flags))\n", " nb = NBProcessor(fn, rm_directives=False, process=True).nb\n", @@ -295,7 +295,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", diff --git a/nbs/api/17_serve.ipynb b/nbs/api/17_serve.ipynb index 060ac4e62..e1737ff3c 100644 --- a/nbs/api/17_serve.ipynb +++ b/nbs/api/17_serve.ipynb @@ -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"