nbdev 3.0.10__tar.gz → 3.0.12__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 (38) hide show
  1. {nbdev-3.0.10/nbdev.egg-info → nbdev-3.0.12}/PKG-INFO +1 -1
  2. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/__init__.py +1 -1
  3. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/_modidx.py +2 -1
  4. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/clean.py +2 -2
  5. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/frontmatter.py +11 -1
  6. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/processors.py +3 -2
  7. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/test.py +9 -5
  8. {nbdev-3.0.10 → nbdev-3.0.12/nbdev.egg-info}/PKG-INFO +1 -1
  9. {nbdev-3.0.10 → nbdev-3.0.12}/CONTRIBUTING.md +0 -0
  10. {nbdev-3.0.10 → nbdev-3.0.12}/LICENSE +0 -0
  11. {nbdev-3.0.10 → nbdev-3.0.12}/MANIFEST.in +0 -0
  12. {nbdev-3.0.10 → nbdev-3.0.12}/README.md +0 -0
  13. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/cli.py +0 -0
  14. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/config.py +0 -0
  15. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/diff.py +0 -0
  16. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/doclinks.py +0 -0
  17. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/export.py +0 -0
  18. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/extract_attachments.py +0 -0
  19. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/imports.py +0 -0
  20. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/maker.py +0 -0
  21. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/merge.py +0 -0
  22. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/migrate.py +0 -0
  23. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/process.py +0 -0
  24. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/qmd.py +0 -0
  25. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/quarto.py +0 -0
  26. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/release.py +0 -0
  27. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/scrubmagics.py +0 -0
  28. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/serve.py +0 -0
  29. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/serve_drv.py +0 -0
  30. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/showdoc.py +0 -0
  31. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev/sync.py +0 -0
  32. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev.egg-info/SOURCES.txt +0 -0
  33. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev.egg-info/dependency_links.txt +0 -0
  34. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev.egg-info/entry_points.txt +0 -0
  35. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev.egg-info/requires.txt +0 -0
  36. {nbdev-3.0.10 → nbdev-3.0.12}/nbdev.egg-info/top_level.txt +0 -0
  37. {nbdev-3.0.10 → nbdev-3.0.12}/pyproject.toml +0 -0
  38. {nbdev-3.0.10 → nbdev-3.0.12}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbdev
3
- Version: 3.0.10
3
+ Version: 3.0.12
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
@@ -1,4 +1,4 @@
1
- __version__ = "3.0.10"
1
+ __version__ = "3.0.12"
2
2
 
3
3
  from .doclinks import nbdev_export
4
4
  from .showdoc import show_doc
@@ -113,7 +113,8 @@ d = { 'settings': { 'branch': 'main',
113
113
  'nbdev.frontmatter._dict2fm': ('api/frontmatter.html#_dict2fm', 'nbdev/frontmatter.py'),
114
114
  'nbdev.frontmatter._fm2dict': ('api/frontmatter.html#_fm2dict', 'nbdev/frontmatter.py'),
115
115
  'nbdev.frontmatter._insertfm': ('api/frontmatter.html#_insertfm', 'nbdev/frontmatter.py'),
116
- 'nbdev.frontmatter._md2dict': ('api/frontmatter.html#_md2dict', 'nbdev/frontmatter.py')},
116
+ 'nbdev.frontmatter._md2dict': ('api/frontmatter.html#_md2dict', 'nbdev/frontmatter.py'),
117
+ 'nbdev.frontmatter.nb_frontmatter': ('api/frontmatter.html#nb_frontmatter', 'nbdev/frontmatter.py')},
117
118
  'nbdev.imports': {},
118
119
  'nbdev.maker': { 'nbdev.maker.ModuleMaker': ('api/maker.html#modulemaker', 'nbdev/maker.py'),
119
120
  'nbdev.maker.ModuleMaker.__init__': ('api/maker.html#modulemaker.__init__', 'nbdev/maker.py'),
@@ -205,7 +205,7 @@ def nbdev_install_hooks():
205
205
  hook_path = repo_path/'.git'/'hooks'
206
206
  fn = hook_path/'post-merge'
207
207
  hook_path.mkdir(parents=True, exist_ok=True)
208
- fn.write_text("#!/bin/bash\nnbdev_trust")
208
+ fn.write_text("#!/bin/bash\nnbdev-trust")
209
209
  os.chmod(fn, os.stat(fn).st_mode | stat.S_IEXEC)
210
210
 
211
211
  cmd = 'git config --local include.path ../.gitconfig'
@@ -219,7 +219,7 @@ def nbdev_install_hooks():
219
219
  #
220
220
  [merge "nbdev-merge"]
221
221
  name = resolve conflicts with nbdev_fix
222
- driver = nbdev_merge %O %A %B %P
222
+ driver = nbdev-merge %O %A %B %P
223
223
  ''')
224
224
  run(cmd)
225
225
 
@@ -3,7 +3,7 @@
3
3
  # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/09_frontmatter.ipynb.
4
4
 
5
5
  # %% auto #0
6
- __all__ = ['FrontmatterProc']
6
+ __all__ = ['nb_frontmatter', 'FrontmatterProc']
7
7
 
8
8
  # %% ../nbs/api/09_frontmatter.ipynb #2398f5ef-06d3-4890-8a54-7cf4f81f3894
9
9
  from .imports import *
@@ -22,6 +22,7 @@ _RE_FM_BASE=r'''^---\s*
22
22
  _re_fm_nb = re.compile(_RE_FM_BASE+'$', flags=re.DOTALL)
23
23
  _re_fm_md = re.compile(_RE_FM_BASE, flags=re.DOTALL)
24
24
 
25
+ # %% ../nbs/api/09_frontmatter.ipynb #1725f3b9
25
26
  def _fm2dict(s:str, nb=True):
26
27
  "Load YAML frontmatter into a `dict`"
27
28
  re_fm = _re_fm_nb if nb else _re_fm_md
@@ -42,6 +43,15 @@ def _md2dict(s:str):
42
43
  except Exception as e: warn(f'Failed to create YAML dict for:\n{r}\n\n{e}\n')
43
44
  return res
44
45
 
46
+ # %% ../nbs/api/09_frontmatter.ipynb #4ba11b21
47
+ def nb_frontmatter(nb):
48
+ "Get frontmatter dict from `nb` without modifying cells"
49
+ raw = first(c for c in nb.cells if c.cell_type=='raw')
50
+ md = first(c for c in nb.cells if c.cell_type=='markdown')
51
+ res = _md2dict(md.source) if md else {}
52
+ if raw: res.update(_fm2dict(raw.source))
53
+ return res
54
+
45
55
  # %% ../nbs/api/09_frontmatter.ipynb #1b5d9d32
46
56
  def _dict2fm(d): return f'---\n{yaml.dump(d)}\n---\n\n'
47
57
  def _insertfm(nb, fm): nb.cells.insert(0, mk_cell(_dict2fm(fm), 'raw'))
@@ -47,8 +47,9 @@ class insert_warning(Processor):
47
47
  _def_types = (ast.FunctionDef,ast.AsyncFunctionDef,ast.ClassDef)
48
48
  def _def_names(cell, shown):
49
49
  cellp = cell.parsed_()
50
- return [showdoc_nm(o) for o in concat(cellp)
51
- if isinstance(o,_def_types) and o.name not in shown and (o.name[0]!='_' or o.name[:2]=='__')] if cellp else []
50
+ nms = [showdoc_nm(o) for o in concat(cellp)
51
+ if isinstance(o,_def_types) and o.name not in shown and (o.name[0]!='_' or o.name[:2]=='__')] if cellp else []
52
+ return [n for nm in nms for n in (nm if isinstance(nm, list) else [nm])]
52
53
 
53
54
  def _get_nm(tree):
54
55
  i = tree.value.args[0]
@@ -17,7 +17,7 @@ from fastcore.meta import delegates
17
17
  from .config import *
18
18
  from .doclinks import *
19
19
  from .process import NBProcessor, nb_lang
20
- from .frontmatter import FrontmatterProc
20
+ from .frontmatter import nb_frontmatter
21
21
 
22
22
  from execnb.nbio import *
23
23
  from execnb.shell import *
@@ -29,13 +29,14 @@ def test_nb(fn, # file name of notebook to test
29
29
  do_print=False, # print completion?
30
30
  showerr=True, # print errors to stderr?
31
31
  basepath=None, # path to add to sys.path
32
- verbose=False): # stream stdout/stderr from cells to console?
32
+ verbose=False, # stream stdout/stderr from cells to console?
33
+ save=False): # write outputs back to notebook on success?
33
34
  "Execute tests in notebook in `fn` except those with `skip_flags`"
34
35
  if basepath: sys.path.insert(0, str(basepath))
35
36
  if not IN_NOTEBOOK: os.environ["IN_TEST"] = '1'
36
37
  flags=set(L(skip_flags)) - set(L(force_flags))
37
- nb = NBProcessor(fn, procs=FrontmatterProc, process=True).nb
38
- fm = getattr(nb, 'frontmatter_', {})
38
+ nb = NBProcessor(fn, rm_directives=False, process=True).nb
39
+ fm = nb_frontmatter(nb)
39
40
  if str2bool(fm.get('skip_exec', False)) or nb_lang(nb) != 'python': return True, 0
40
41
 
41
42
  def _no_eval(cell):
@@ -51,6 +52,7 @@ def test_nb(fn, # file name of notebook to test
51
52
  try:
52
53
  with working_directory(fn.parent):
53
54
  k.run_all(nb, exc_stop=True, preproc=_no_eval, verbose=verbose)
55
+ if save: write_nb(nb, fn)
54
56
  res = True
55
57
  except:
56
58
  if showerr: sys.stderr.write(k.prettytb(fname=fn)+'\n')
@@ -78,9 +80,11 @@ def nbdev_test(
78
80
  pause:float=0.01, # Pause time (in seconds) between notebooks to avoid race conditions
79
81
  ignore_fname:str='.notest', # Filename that will result in siblings being ignored
80
82
  verbose:bool=False, # Print stdout/stderr from notebook cells?
83
+ save:bool=False, # Write outputs back to notebooks on success?
81
84
  **kwargs):
82
85
  "Test in parallel notebooks matching `path`, passing along `flags`"
83
86
  skip_flags = get_config().tst_flags
87
+ if isinstance(skip_flags, str): skip_flags = skip_flags.split()
84
88
  force_flags = flags.split()
85
89
  files = nbglob(path, as_path=True, **kwargs)
86
90
  files = [f.absolute() for f in sorted(files) if _keep_file(f, ignore_fname)]
@@ -92,7 +96,7 @@ def nbdev_test(
92
96
  wd_pth = get_config().nbs_path
93
97
  with working_directory(wd_pth if (wd_pth and wd_pth.exists()) else os.getcwd()):
94
98
  results = parallel(test_nb, files, skip_flags=skip_flags, force_flags=force_flags, n_workers=n_workers,
95
- basepath=get_config().config_path, pause=pause, do_print=do_print, verbose=verbose, **kw)
99
+ basepath=get_config().config_path, pause=pause, do_print=do_print, verbose=verbose, save=save, **kw)
96
100
  passed,times = zip(*results)
97
101
  if all(passed): print("Success.")
98
102
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbdev
3
- Version: 3.0.10
3
+ Version: 3.0.12
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