nbdev 3.3.17__tar.gz → 3.3.18__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.18}/PKG-INFO +1 -1
  2. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/__init__.py +1 -1
  3. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/_modidx.py +2 -0
  4. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/test.py +32 -13
  5. {nbdev-3.3.17 → nbdev-3.3.18/nbdev.egg-info}/PKG-INFO +1 -1
  6. {nbdev-3.3.17 → nbdev-3.3.18}/CONTRIBUTING.md +0 -0
  7. {nbdev-3.3.17 → nbdev-3.3.18}/LICENSE +0 -0
  8. {nbdev-3.3.17 → nbdev-3.3.18}/README.md +0 -0
  9. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/clean.py +0 -0
  10. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/cli.py +0 -0
  11. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/config.py +0 -0
  12. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/diff.py +0 -0
  13. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/doclinks.py +0 -0
  14. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/export.py +0 -0
  15. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/extract_attachments.py +0 -0
  16. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/frontmatter.py +0 -0
  17. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/imports.py +0 -0
  18. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/maker.py +0 -0
  19. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/merge.py +0 -0
  20. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/migrate.py +0 -0
  21. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/moddocs.py +0 -0
  22. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/process.py +0 -0
  23. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/processors.py +0 -0
  24. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/qmd.py +0 -0
  25. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/quarto.py +0 -0
  26. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/release.py +0 -0
  27. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/scrubmagics.py +0 -0
  28. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/serve.py +0 -0
  29. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/serve_drv.py +0 -0
  30. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/showdoc.py +0 -0
  31. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/skill.py +0 -0
  32. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev/sync.py +0 -0
  33. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev.egg-info/SOURCES.txt +0 -0
  34. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev.egg-info/dependency_links.txt +0 -0
  35. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev.egg-info/entry_points.txt +0 -0
  36. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev.egg-info/requires.txt +0 -0
  37. {nbdev-3.3.17 → nbdev-3.3.18}/nbdev.egg-info/top_level.txt +0 -0
  38. {nbdev-3.3.17 → nbdev-3.3.18}/pyproject.toml +0 -0
  39. {nbdev-3.3.17 → nbdev-3.3.18}/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.18
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
@@ -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.18"
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')}}}
@@ -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
@@ -76,16 +99,10 @@ def test_nb(
76
99
  prev_test = os.environ.get('IN_TEST')
77
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:
@@ -154,10 +171,12 @@ def nbdev_test(
154
171
  else: kw = {'method':'spawn'} if sys.platform=='darwin' else {}
155
172
  wd_pth = cfg.nbs_path
156
173
  with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()):
174
+ setup = cfg.get('test_setup')
175
+ if setup: import_obj(setup)([c for f in files for c in nb_test_cells(f, skip_flags, force_flags)])
157
176
  try:
158
177
  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)
178
+ basepath=cfg.config_path, pause=pause, do_print=do_print, verbose=verbose, save=save,
179
+ cell_timeout=cell_timeout or None, cell_timing_min=cell_timing_min, **kw)
161
180
  except KeyboardInterrupt:
162
181
  sys.stderr.write('\nnbdev-test interrupted; in-flight notebook stacks shown above\n')
163
182
  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.18
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
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
File without changes
File without changes
File without changes