nbdev 3.3.17__tar.gz → 3.3.19__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. {nbdev-3.3.17/nbdev.egg-info → nbdev-3.3.19}/PKG-INFO +2 -3
  2. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/__init__.py +1 -1
  3. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/_modidx.py +2 -0
  4. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/doclinks.py +4 -1
  5. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/serve.py +1 -1
  6. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/test.py +37 -17
  7. {nbdev-3.3.17 → nbdev-3.3.19/nbdev.egg-info}/PKG-INFO +2 -3
  8. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev.egg-info/requires.txt +1 -2
  9. {nbdev-3.3.17 → nbdev-3.3.19}/pyproject.toml +2 -3
  10. {nbdev-3.3.17 → nbdev-3.3.19}/CONTRIBUTING.md +0 -0
  11. {nbdev-3.3.17 → nbdev-3.3.19}/LICENSE +0 -0
  12. {nbdev-3.3.17 → nbdev-3.3.19}/README.md +0 -0
  13. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/clean.py +0 -0
  14. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/cli.py +0 -0
  15. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/config.py +0 -0
  16. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/diff.py +0 -0
  17. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/export.py +0 -0
  18. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/extract_attachments.py +0 -0
  19. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/frontmatter.py +0 -0
  20. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/imports.py +0 -0
  21. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/maker.py +0 -0
  22. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/merge.py +0 -0
  23. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/migrate.py +0 -0
  24. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/moddocs.py +0 -0
  25. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/process.py +0 -0
  26. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/processors.py +0 -0
  27. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/qmd.py +0 -0
  28. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/quarto.py +0 -0
  29. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/release.py +0 -0
  30. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/scrubmagics.py +0 -0
  31. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/serve_drv.py +0 -0
  32. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/showdoc.py +0 -0
  33. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/skill.py +0 -0
  34. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev/sync.py +0 -0
  35. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev.egg-info/SOURCES.txt +0 -0
  36. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev.egg-info/dependency_links.txt +0 -0
  37. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev.egg-info/entry_points.txt +0 -0
  38. {nbdev-3.3.17 → nbdev-3.3.19}/nbdev.egg-info/top_level.txt +0 -0
  39. {nbdev-3.3.17 → nbdev-3.3.19}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbdev
3
- Version: 3.3.17
3
+ Version: 3.3.19
4
4
  Summary: Create delightful software with Jupyter Notebooks
5
5
  Author-email: "Jeremy Howard and the fast.ai community" <j@fast.ai>
6
6
  License: Apache-2.0
@@ -16,7 +16,7 @@ Classifier: License :: OSI Approved :: Apache Software License
16
16
  Requires-Python: >=3.10
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
- Requires-Dist: fastcore>=2.2.23
19
+ Requires-Dist: fastcore>=2.2.28
20
20
  Requires-Dist: execnb>=0.3.3
21
21
  Requires-Dist: astunparse
22
22
  Requires-Dist: ghapi>=2.0.2
@@ -35,7 +35,6 @@ Requires-Dist: pandas; extra == "dev"
35
35
  Requires-Dist: matplotlib; extra == "dev"
36
36
  Requires-Dist: black; extra == "dev"
37
37
  Requires-Dist: svg.py; extra == "dev"
38
- Requires-Dist: nbclassic; extra == "dev"
39
38
  Requires-Dist: pysym2md>=0.0.6; extra == "dev"
40
39
  Requires-Dist: llms-txt; extra == "dev"
41
40
  Requires-Dist: sphinx; extra == "dev"
@@ -6,7 +6,7 @@ Modules:
6
6
  - `nbdev.moddocs`: # Module docs: creating them from existing notebooks
7
7
  - `nbdev.skill`: Author nbdev notebooks as source, documentation, examples, and tests. Ensure this guidance is in context before any notebook edit."""
8
8
 
9
- __version__ = "3.3.17"
9
+ __version__ = "3.3.19"
10
10
 
11
11
  from .doclinks import nbdev_export
12
12
  from .showdoc import show_doc
@@ -388,5 +388,7 @@ d = { 'settings': { 'branch': 'main',
388
388
  'nbdev.test': { 'nbdev.test._await_chain': ('api/test.html#_await_chain', 'nbdev/test.py'),
389
389
  'nbdev.test._int_handler': ('api/test.html#_int_handler', 'nbdev/test.py'),
390
390
  'nbdev.test._keep_file': ('api/test.html#_keep_file', 'nbdev/test.py'),
391
+ 'nbdev.test._skip_cell': ('api/test.html#_skip_cell', 'nbdev/test.py'),
392
+ 'nbdev.test.nb_test_cells': ('api/test.html#nb_test_cells', 'nbdev/test.py'),
391
393
  'nbdev.test.nbdev_test': ('api/test.html#nbdev_test', 'nbdev/test.py'),
392
394
  'nbdev.test.test_nb': ('api/test.html#test_nb', 'nbdev/test.py')}}}
@@ -129,12 +129,15 @@ def nbglob_cli(
129
129
  symlinks:bool=False, # Follow symlinks?
130
130
  file_glob:str='*.ipynb', # Only include files matching glob
131
131
  file_re:str=None, # Only include files matching regex
132
+ path_glob:str=None, # Only include files whose full paths match glob (wildcards match separators)
133
+ path_re:str=None, # Only include files whose full paths match regex
132
134
  folder_re:str=None, # Only enter folders matching regex
133
135
  skip_file_glob:str=None, # Skip files matching glob
134
136
  skip_file_re:str='^[_.]', # Skip files matching regex
135
137
  skip_folder_re:str = '^[_.]'): # Skip folders matching regex
136
138
  "Find all files in a directory matching an extension given a config key."
137
- return nbglob(path, symlinks=symlinks, file_glob=file_glob, file_re=file_re, folder_re=folder_re,
139
+ return nbglob(path, symlinks=symlinks, file_glob=file_glob, file_re=file_re,
140
+ path_glob=path_glob, path_re=path_re, folder_re=folder_re,
138
141
  skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, skip_folder_re=skip_folder_re)
139
142
 
140
143
  # %% ../nbs/api/05_doclinks.ipynb #5e6fbe08
@@ -87,7 +87,7 @@ def proc_nbs(
87
87
  (cache/'_quarto.yml').unlink(missing_ok=True) # single-doc renders strip the staged copy in place (`_strip_sidebar`), so always restage it
88
88
 
89
89
  files = files.map(_proc_file, mtime=cache_mtime, cache=cache, path=path).filter()
90
- kw = {} if IN_NOTEBOOK else {'method':'spawn'}
90
+ kw = {} if in_notebook() else {'method':'spawn'}
91
91
  parallel(nbdev.serve_drv.main, files, n_workers=n_workers, pause=0.01, **kw)
92
92
  if cache.exists(): cache.touch()
93
93
  return cache
@@ -5,10 +5,10 @@ Docs: https://nbdev.fast.ai/api/test.html.md"""
5
5
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/12_test.ipynb.
6
6
 
7
7
  # %% auto #0
8
- __all__ = ['test_nb', 'nbdev_test']
8
+ __all__ = ['nb_test_cells', 'test_nb', 'nbdev_test']
9
9
 
10
10
  # %% ../nbs/api/12_test.ipynb #45e10c3f
11
- import time,os,sys,io,traceback,contextlib,inspect,signal,asyncio,threading
11
+ import time,os,sys,io,traceback,contextlib,signal,asyncio,threading
12
12
  from fastcore.basics import *
13
13
  from fastcore.imports import *
14
14
  from fastcore.foundation import *
@@ -54,6 +54,29 @@ def _int_handler(signum, frame):
54
54
  os.write(2, f'\n=== nbdev-test interrupted: {_cur_nb[0]} ===\n{buf.getvalue()}'.encode())
55
55
  os._exit(130)
56
56
 
57
+ # %% ../nbs/api/12_test.ipynb #b831e0b8
58
+ def _skip_cell(nb, skip_flags=None, force_flags=None):
59
+ "Predicate for the cells of `nb` that `test_nb` leaves out"
60
+ fm = nb_frontmatter(nb)
61
+ if str2bool(fm.get('skip_exec', False)) or nb_lang(nb) != 'python': return lambda cell: True
62
+ flags = set(L(skip_flags)) - set(L(force_flags))
63
+ dflt = fm_default_eval(fm)
64
+ def _f(cell):
65
+ if cell.cell_type != 'code': return True
66
+ if not does_cell_eval(cell, dflt): return True
67
+ return flags & (getattr(cell, 'directives_', {}) or {}).keys()
68
+ return _f
69
+
70
+ def nb_test_cells(
71
+ fn, # Notebook path
72
+ skip_flags=None, # Flags marking cells to skip
73
+ force_flags=None, # Flags marking cells to always run
74
+ ):
75
+ "The cells `test_nb` would run in the notebook at `fn`"
76
+ nb = NBProcessor(fn, rm_directives=False, process=True).nb
77
+ skip = _skip_cell(nb, skip_flags, force_flags)
78
+ return [c for c in nb.cells if not skip(c)]
79
+
57
80
  # %% ../nbs/api/12_test.ipynb #3f4fa1ad
58
81
  def test_nb(
59
82
  fn, # file name of notebook to test
@@ -69,23 +92,17 @@ def test_nb(
69
92
  cell_timing_min:float=None # print cells slower than this many seconds (None: no timing output)
70
93
  ):
71
94
  "Execute tests in notebook in `fn` except those with `skip_flags`"
72
- if not IN_NOTEBOOK and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler)
95
+ if not in_notebook() and threading.current_thread() is threading.main_thread(): signal.signal(signal.SIGINT, _int_handler)
73
96
  fn = Path(fn)
74
97
  _cur_nb[0] = fn
75
98
  if basepath: sys.path.insert(0, str(basepath))
76
99
  prev_test = os.environ.get('IN_TEST')
77
- if not IN_NOTEBOOK: os.environ['IN_TEST'] = '1'
100
+ if not in_notebook(): os.environ['IN_TEST'] = '1'
78
101
  try:
79
- flags=set(L(skip_flags)) - set(L(force_flags))
80
102
  nb = NBProcessor(fn, rm_directives=False, process=True).nb
81
103
  fm = nb_frontmatter(nb)
82
104
  if str2bool(fm.get('skip_exec', False)) or nb_lang(nb) != 'python': return True, 0
83
-
84
- dflt = fm_default_eval(fm)
85
- def _no_eval(cell):
86
- if cell.cell_type != 'code': return True
87
- if not does_cell_eval(cell, dflt): return True
88
- return flags & (getattr(cell, 'directives_', {}) or {}).keys()
105
+ _no_eval = _skip_cell(nb, skip_flags, force_flags)
89
106
 
90
107
  def _postproc(cell):
91
108
  elapsed = cell.metadata['execution']['total']
@@ -102,9 +119,9 @@ def test_nb(
102
119
  if save: write_nb(nb, fn)
103
120
  res = True
104
121
  except:
105
- if showerr: sys.stderr.write(k.prettytb(fname=fn)+'\n')
122
+ if showerr: sys.__stderr__.write((k.prettytb(fname=fn) or traceback.format_exc())+'\n')
106
123
  res=False
107
- if k.leaks and showerr: sys.stderr.write(f'{fn}: {len(k.leaks)} leaked task(s) survived cancellation\n')
124
+ if k.leaks and showerr: sys.__stderr__.write(f'{fn}: {len(k.leaks)} leaked task(s) survived cancellation\n')
108
125
  if do_print: print(f'- Completed {fn}')
109
126
  return res,time.time()-start
110
127
  finally:
@@ -126,7 +143,7 @@ def _keep_file(
126
143
  @call_parse(pos=['path'])
127
144
  @delegates(nbglob_cli)
128
145
  def nbdev_test(
129
- path:str=None, # A notebook name or glob to test
146
+ path:str=None, # A notebook, directory, or full-path glob to test
130
147
  flags:str='', # Space separated list of test flags to run that are normally ignored
131
148
  n_workers:int=None, # Number of workers
132
149
  timing:bool=False, # Time each notebook to see which are slow
@@ -140,6 +157,7 @@ def nbdev_test(
140
157
  **kwargs
141
158
  ):
142
159
  "Test in parallel notebooks matching `path`, passing along `flags`"
160
+ if path and not Path(path).exists(): kwargs['path_glob'],path = os.path.abspath(path),Path.cwd()
143
161
  cfg = get_config(Path(path).resolve() if path else None)
144
162
  cell_timeout,cell_timing_min = ifnone(cell_timeout, cfg.cell_timeout),ifnone(cell_timing_min, cfg.get('cell_timing_min'))
145
163
  skip_flags = cfg.tst_flags
@@ -150,14 +168,16 @@ def nbdev_test(
150
168
  if len(files)==0: return print('No files were eligible for testing')
151
169
 
152
170
  if n_workers is None: n_workers = 0 if len(files)==1 else min(num_cpus(), 8)
153
- if IN_NOTEBOOK: kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'}
171
+ if in_notebook(): kw = {'method':'spawn'} if os.name=='nt' or sys.platform=='darwin' else {'method':'forkserver'}
154
172
  else: kw = {'method':'spawn'} if sys.platform=='darwin' else {}
155
173
  wd_pth = cfg.nbs_path
156
174
  with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()):
175
+ setup = cfg.get('test_setup')
176
+ if setup: import_obj(setup)([c for f in files for c in nb_test_cells(f, skip_flags, force_flags)])
157
177
  try:
158
178
  results = parallel(test_nb, files, skip_flags=skip_flags, force_flags=force_flags, n_workers=n_workers,
159
- basepath=cfg.config_path, pause=pause, do_print=do_print, verbose=verbose, save=save,
160
- cell_timeout=cell_timeout or None, cell_timing_min=cell_timing_min, **kw)
179
+ basepath=cfg.config_path, pause=pause, do_print=do_print, verbose=verbose, save=save,
180
+ cell_timeout=cell_timeout or None, cell_timing_min=cell_timing_min, **kw)
161
181
  except KeyboardInterrupt:
162
182
  sys.stderr.write('\nnbdev-test interrupted; in-flight notebook stacks shown above\n')
163
183
  sys.exit(130)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbdev
3
- Version: 3.3.17
3
+ Version: 3.3.19
4
4
  Summary: Create delightful software with Jupyter Notebooks
5
5
  Author-email: "Jeremy Howard and the fast.ai community" <j@fast.ai>
6
6
  License: Apache-2.0
@@ -16,7 +16,7 @@ Classifier: License :: OSI Approved :: Apache Software License
16
16
  Requires-Python: >=3.10
17
17
  Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
- Requires-Dist: fastcore>=2.2.23
19
+ Requires-Dist: fastcore>=2.2.28
20
20
  Requires-Dist: execnb>=0.3.3
21
21
  Requires-Dist: astunparse
22
22
  Requires-Dist: ghapi>=2.0.2
@@ -35,7 +35,6 @@ Requires-Dist: pandas; extra == "dev"
35
35
  Requires-Dist: matplotlib; extra == "dev"
36
36
  Requires-Dist: black; extra == "dev"
37
37
  Requires-Dist: svg.py; extra == "dev"
38
- Requires-Dist: nbclassic; extra == "dev"
39
38
  Requires-Dist: pysym2md>=0.0.6; extra == "dev"
40
39
  Requires-Dist: llms-txt; extra == "dev"
41
40
  Requires-Dist: sphinx; extra == "dev"
@@ -1,4 +1,4 @@
1
- fastcore>=2.2.23
1
+ fastcore>=2.2.28
2
2
  execnb>=0.3.3
3
3
  astunparse
4
4
  ghapi>=2.0.2
@@ -20,7 +20,6 @@ pandas
20
20
  matplotlib
21
21
  black
22
22
  svg.py
23
- nbclassic
24
23
  pysym2md>=0.0.6
25
24
  llms-txt
26
25
  sphinx
@@ -19,12 +19,11 @@ classifiers = [
19
19
  "License :: OSI Approved :: Apache Software License",
20
20
  ]
21
21
  dynamic = ["version"]
22
- dependencies = [ "fastcore>=2.2.23", "execnb>=0.3.3", "astunparse", "ghapi>=2.0.2", "watchdog", "asttokens",
22
+ dependencies = [ "fastcore>=2.2.28", "execnb>=0.3.3", "astunparse", "ghapi>=2.0.2", "watchdog", "asttokens",
23
23
  "setuptools", "build", "fastgit>=0.0.7", "pyyaml", "tomli; python_version < '3.11'", ]
24
24
 
25
25
  [project.optional-dependencies]
26
- dev = [ "ipywidgets", "nbdev-numpy", "nbdev-stdlib", "pandas", "matplotlib", "black", "svg.py", "nbclassic",
27
- "pysym2md>=0.0.6", "llms-txt", "sphinx", "plum-dispatch", ]
26
+ dev = [ "ipywidgets", "nbdev-numpy", "nbdev-stdlib", "pandas", "matplotlib", "black", "svg.py", "pysym2md>=0.0.6", "llms-txt", "sphinx", "plum-dispatch", ]
28
27
 
29
28
  [project.urls]
30
29
  Repository = "https://github.com/AnswerDotAI/nbdev"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes