nbdev 2.4.7__tar.gz → 2.4.8__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 (40) hide show
  1. {nbdev-2.4.7/nbdev.egg-info → nbdev-2.4.8}/PKG-INFO +2 -2
  2. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/__init__.py +1 -1
  3. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/_modidx.py +7 -0
  4. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/cli.py +1 -1
  5. nbdev-2.4.8/nbdev/diff.py +92 -0
  6. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/release.py +1 -1
  7. {nbdev-2.4.7 → nbdev-2.4.8/nbdev.egg-info}/PKG-INFO +2 -2
  8. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev.egg-info/SOURCES.txt +1 -0
  9. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev.egg-info/requires.txt +1 -1
  10. {nbdev-2.4.7 → nbdev-2.4.8}/settings.ini +2 -2
  11. {nbdev-2.4.7 → nbdev-2.4.8}/CONTRIBUTING.md +0 -0
  12. {nbdev-2.4.7 → nbdev-2.4.8}/LICENSE +0 -0
  13. {nbdev-2.4.7 → nbdev-2.4.8}/MANIFEST.in +0 -0
  14. {nbdev-2.4.7 → nbdev-2.4.8}/README.md +0 -0
  15. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/clean.py +0 -0
  16. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/config.py +0 -0
  17. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/doclinks.py +0 -0
  18. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/export.py +0 -0
  19. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/extract_attachments.py +0 -0
  20. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/frontmatter.py +0 -0
  21. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/imports.py +0 -0
  22. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/maker.py +0 -0
  23. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/merge.py +0 -0
  24. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/migrate.py +0 -0
  25. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/process.py +0 -0
  26. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/processors.py +0 -0
  27. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/qmd.py +0 -0
  28. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/quarto.py +0 -0
  29. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/serve.py +0 -0
  30. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/serve_drv.py +0 -0
  31. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/showdoc.py +0 -0
  32. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/sync.py +0 -0
  33. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev/test.py +0 -0
  34. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev.egg-info/dependency_links.txt +0 -0
  35. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev.egg-info/entry_points.txt +0 -0
  36. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev.egg-info/not-zip-safe +0 -0
  37. {nbdev-2.4.7 → nbdev-2.4.8}/nbdev.egg-info/top_level.txt +0 -0
  38. {nbdev-2.4.7 → nbdev-2.4.8}/pyproject.toml +0 -0
  39. {nbdev-2.4.7 → nbdev-2.4.8}/setup.cfg +0 -0
  40. {nbdev-2.4.7 → nbdev-2.4.8}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbdev
3
- Version: 2.4.7
3
+ Version: 2.4.8
4
4
  Summary: Create delightful software with Jupyter Notebooks
5
5
  Home-page: https://github.com/AnswerDotAI/nbdev
6
6
  Author: Jeremy Howard and Hamel Husain
@@ -20,7 +20,7 @@ Requires-Python: >=3.9
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
22
  Requires-Dist: packaging
23
- Requires-Dist: fastcore>=1.8.14
23
+ Requires-Dist: fastcore>=1.11.0
24
24
  Requires-Dist: execnb>=0.1.12
25
25
  Requires-Dist: astunparse
26
26
  Requires-Dist: ghapi>=1.0.3
@@ -1,4 +1,4 @@
1
- __version__ = "2.4.7"
1
+ __version__ = "2.4.8"
2
2
 
3
3
  from .doclinks import nbdev_export
4
4
  from .showdoc import show_doc
@@ -49,6 +49,13 @@ d = { 'settings': { 'branch': 'main',
49
49
  'nbdev.config.update_proj': ('api/config.html#update_proj', 'nbdev/config.py'),
50
50
  'nbdev.config.update_version': ('api/config.html#update_version', 'nbdev/config.py'),
51
51
  'nbdev.config.write_cells': ('api/config.html#write_cells', 'nbdev/config.py')},
52
+ 'nbdev.diff': { 'nbdev.diff._cell_changes': ('api/diff.html#_cell_changes', 'nbdev/diff.py'),
53
+ 'nbdev.diff._nb_srcdict': ('api/diff.html#_nb_srcdict', 'nbdev/diff.py'),
54
+ 'nbdev.diff.cell_diffs': ('api/diff.html#cell_diffs', 'nbdev/diff.py'),
55
+ 'nbdev.diff.changed_cells': ('api/diff.html#changed_cells', 'nbdev/diff.py'),
56
+ 'nbdev.diff.nbs_pair': ('api/diff.html#nbs_pair', 'nbdev/diff.py'),
57
+ 'nbdev.diff.read_nb_from_git': ('api/diff.html#read_nb_from_git', 'nbdev/diff.py'),
58
+ 'nbdev.diff.source_diff': ('api/diff.html#source_diff', 'nbdev/diff.py')},
52
59
  'nbdev.doclinks': { 'nbdev.doclinks.NbdevLookup': ('api/doclinks.html#nbdevlookup', 'nbdev/doclinks.py'),
53
60
  'nbdev.doclinks.NbdevLookup.__getitem__': ( 'api/doclinks.html#nbdevlookup.__getitem__',
54
61
  'nbdev/doclinks.py'),
@@ -188,7 +188,7 @@ def watch_export(nbs:str=None, # Nb directory to watch for changes
188
188
  run(f'nbdev_export')
189
189
  def _export(e,lib=lib):
190
190
  p = e.src_path
191
- if (not '.ipynb_checkpoints' in p and p.endswith('.ipynb') and not Path(p).name.startswith('.~')):
191
+ if (not '.ipynb_checkpoints' in p and p.endswith('.ipynb') and not Path(p).name.startswith(('tmp','.~'))):
192
192
  if e.event_type == 'modified':
193
193
  time.sleep(0.1)
194
194
  try: run(f'nb_export --lib_path {lib} "{p}"')
@@ -0,0 +1,92 @@
1
+ """Get ipynb diffs by cell"""
2
+
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/19_diff.ipynb.
4
+
5
+ # %% auto 0
6
+ __all__ = ['read_nb_from_git', 'nbs_pair', 'changed_cells', 'source_diff', 'cell_diffs']
7
+
8
+ # %% ../nbs/api/19_diff.ipynb
9
+ import json
10
+ from fastcore.utils import *
11
+ from fastcore.meta import delegates
12
+ from difflib import unified_diff
13
+ from fastgit import Git
14
+ from execnb.nbio import *
15
+
16
+ # %% ../nbs/api/19_diff.ipynb
17
+ def read_nb_from_git(
18
+ g:Git, # The git object
19
+ path, # The path to the notebook (absolute or relative to git root)
20
+ ref=None # The git ref to read from (e.g. HEAD); None for working dir
21
+ )->AttrDict: # The notebook
22
+ "Read notebook from git ref (e.g. HEAD) at path, or working dir if ref is None"
23
+ path = Path(path)
24
+ if path.is_absolute(): path = path.relative_to(g.top())
25
+ if ref is None: return read_nb(g.top()/path)
26
+ raw = g.show(f'{ref}:{path}', split=False)
27
+ return dict2nb(json.loads(raw))
28
+
29
+ # %% ../nbs/api/19_diff.ipynb
30
+ def _nb_srcdict(g:Git, nb_path, ref=None, f=noop):
31
+ "Dict of id->source"
32
+ nb = read_nb_from_git(g, nb_path, ref)
33
+ return {c['id']: f(c) for c in nb.cells}
34
+
35
+ # %% ../nbs/api/19_diff.ipynb
36
+ def nbs_pair(
37
+ nb_path, # Path to the notebook
38
+ ref_a='HEAD', # First git ref (None for working dir)
39
+ ref_b=None, # Second git ref (None for working dir)
40
+ f=noop # Function to call on contents
41
+ ): # Tuple of two notebooks
42
+ "NBs at two refs; None means working dir. By default provides HEAD and working dir"
43
+ nb_path = Path(nb_path).resolve()
44
+ g = Git(nb_path.parent)
45
+ return _nb_srcdict(g, nb_path, ref_a, f), _nb_srcdict(g, nb_path, ref_b, f)
46
+
47
+ # %% ../nbs/api/19_diff.ipynb
48
+ def _cell_changes(
49
+ nb_path, # Path to the notebook
50
+ fn, # function to call to get dict values
51
+ ref_a='HEAD', # First git ref (None for working dir)
52
+ ref_b=None, # Second git ref (None for working dir)
53
+ adds=True, # Include cells in b but not in a
54
+ changes=True, # Include cells with different content
55
+ dels=False, # Include cells in a but not in b
56
+ metadata=False, # Consider cell metadata when comparing
57
+ outputs=False # Consider cell outputs when comparing
58
+ ): # Dict of results
59
+ "Apply fn(cell_id, old_content, new_content) to changed cells between two refs"
60
+ def cell_content(c):
61
+ res = c.get('source', '')
62
+ if metadata: res += '\n# metadata: ' + json.dumps(c.get('metadata', {}), sort_keys=True)
63
+ if outputs: res += '\n# outputs: ' + json.dumps(c.get('outputs', []), sort_keys=True)
64
+ return res
65
+ old,new = nbs_pair(nb_path, ref_a, ref_b, f=cell_content)
66
+ res = {}
67
+ if adds: res |= {cid: fn(cid, '', new[cid]) for cid in new if cid not in old}
68
+ if changes: res |= {cid: fn(cid, old[cid], new[cid]) for cid in new if cid in old and new[cid] != old[cid]}
69
+ if dels: res |= {cid: fn(cid, old[cid], '') for cid in old if cid not in new}
70
+ return res
71
+
72
+ # %% ../nbs/api/19_diff.ipynb
73
+ @delegates(_cell_changes)
74
+ def changed_cells(nb_path, **kwargs):
75
+ "Return set of cell IDs for changed/added/deleted cells between two refs"
76
+ def f(cid,o,n): return cid
77
+ return set(_cell_changes(nb_path, f, **kwargs).keys())
78
+
79
+ # %% ../nbs/api/19_diff.ipynb
80
+ def source_diff(
81
+ old_source, # Original source string
82
+ new_source # New source string
83
+ ): # Unified diff string
84
+ "Return unified diff string for source change"
85
+ return '\n'.join(unified_diff(old_source.splitlines(), new_source.splitlines(), lineterm=''))
86
+
87
+ # %% ../nbs/api/19_diff.ipynb
88
+ @delegates(_cell_changes)
89
+ def cell_diffs(nb_path, **kwargs):
90
+ "{cell_id:diff} for changed/added/deleted cells between two refs"
91
+ def f(cid,o,n): return source_diff(o,n)
92
+ return _cell_changes(nb_path, f, **kwargs)
@@ -63,7 +63,7 @@ class Release:
63
63
 
64
64
  def _issues(self, label):
65
65
  return self.gh.issues.list_for_repo(state='closed', sort='created', filter='all', since=self.commit_date, labels=label)
66
- def _issue_groups(self): return parallel(self._issues, self.groups.keys(), progress=False)
66
+ def _issue_groups(self): return parallel(self._issues, self.groups.keys(), progress=False, threadpool=True)
67
67
 
68
68
  # %% ../nbs/api/18_release.ipynb
69
69
  @patch
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbdev
3
- Version: 2.4.7
3
+ Version: 2.4.8
4
4
  Summary: Create delightful software with Jupyter Notebooks
5
5
  Home-page: https://github.com/AnswerDotAI/nbdev
6
6
  Author: Jeremy Howard and Hamel Husain
@@ -20,7 +20,7 @@ Requires-Python: >=3.9
20
20
  Description-Content-Type: text/markdown
21
21
  License-File: LICENSE
22
22
  Requires-Dist: packaging
23
- Requires-Dist: fastcore>=1.8.14
23
+ Requires-Dist: fastcore>=1.11.0
24
24
  Requires-Dist: execnb>=0.1.12
25
25
  Requires-Dist: astunparse
26
26
  Requires-Dist: ghapi>=1.0.3
@@ -10,6 +10,7 @@ nbdev/_modidx.py
10
10
  nbdev/clean.py
11
11
  nbdev/cli.py
12
12
  nbdev/config.py
13
+ nbdev/diff.py
13
14
  nbdev/doclinks.py
14
15
  nbdev/export.py
15
16
  nbdev/extract_attachments.py
@@ -1,5 +1,5 @@
1
1
  packaging
2
- fastcore>=1.8.14
2
+ fastcore>=1.11.0
3
3
  execnb>=0.1.12
4
4
  astunparse
5
5
  ghapi>=1.0.3
@@ -9,13 +9,13 @@ author = Jeremy Howard and Hamel Husain
9
9
  author_email = j@fast.ai
10
10
  branch = main
11
11
  min_python = 3.9
12
- version = 2.4.7
12
+ version = 2.4.8
13
13
  audience = Developers
14
14
  language = English
15
15
  custom_sidebar = True
16
16
  license = apache2
17
17
  status = 5
18
- requirements = fastcore>=1.8.14 execnb>=0.1.12 astunparse ghapi>=1.0.3 watchdog asttokens setuptools build
18
+ requirements = fastcore>=1.11.0 execnb>=0.1.12 astunparse ghapi>=1.0.3 watchdog asttokens setuptools build
19
19
  pip_requirements = PyYAML
20
20
  conda_requirements = pyyaml
21
21
  conda_user = fastai
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