execnb 0.1.18__tar.gz → 0.2.1__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.
@@ -1,18 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: execnb
3
- Version: 0.1.18
3
+ Version: 0.2.1
4
4
  Summary: A description of your project
5
- Home-page: https://github.com/AnswerDotAI/execnb/
6
- Author: Jeremy Howard
7
- Author-email: j@fast.ai
8
- License: Apache Software License 2.0
9
- Keywords: some keywords
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: Intended Audience :: Developers
5
+ Author-email: Jeremy Howard <j@fast.ai>
6
+ License: Apache-2.0
7
+ Project-URL: Repository, https://github.com/AnswerDotAI/execnb/
8
+ Project-URL: Documentation, https://AnswerDotAI.github.io/execnb/
9
+ Keywords: some,keywords
12
10
  Classifier: Natural Language :: English
13
- Classifier: Programming Language :: Python :: 3.7
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
16
15
  Requires-Python: >=3.7
17
16
  Description-Content-Type: text/markdown
18
17
  License-File: LICENSE
@@ -22,19 +21,7 @@ Provides-Extra: dev
22
21
  Requires-Dist: matplotlib; extra == "dev"
23
22
  Requires-Dist: Pillow; extra == "dev"
24
23
  Requires-Dist: mistletoe; extra == "dev"
25
- Dynamic: author
26
- Dynamic: author-email
27
- Dynamic: classifier
28
- Dynamic: description
29
- Dynamic: description-content-type
30
- Dynamic: home-page
31
- Dynamic: keywords
32
- Dynamic: license
33
24
  Dynamic: license-file
34
- Dynamic: provides-extra
35
- Dynamic: requires-dist
36
- Dynamic: requires-python
37
- Dynamic: summary
38
25
 
39
26
  # execnb
40
27
 
@@ -66,9 +53,9 @@ to run Jupyter code and capture notebook outputs, without running a
66
53
  Jupyter server (or even having it installed):
67
54
 
68
55
  ``` python
69
- from execnb.nbio import *
70
56
  from execnb.shell import *
71
57
  from fastcore.utils import *
58
+ from fastcore.nbio import *
72
59
  ```
73
60
 
74
61
  ``` python
@@ -79,7 +66,7 @@ s.run('1+1')
79
66
  [{'data': {'text/plain': ['2']},
80
67
  'metadata': {},
81
68
  'output_type': 'execute_result',
82
- 'execution_count': 1}]
69
+ 'execution_count': None}]
83
70
 
84
71
  To execute a notebook and save it with outputs filled in, use
85
72
  [`CaptureShell.execute`](https://AnswerDotAI.github.io/execnb/shell.html#captureshell.execute):
@@ -91,7 +78,7 @@ try:
91
78
  finally: Path('tmp.ipynb').unlink()
92
79
  ```
93
80
 
94
- [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\n']}, {'data': {'text/plain': ['2']}, 'execution_count': 3, 'metadata': {}, 'output_type': 'execute_result'}]
81
+ [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\n']}, {'data': {'text/plain': ['2']}, 'execution_count': None, 'metadata': {}, 'output_type': 'execute_result'}]
95
82
 
96
83
  You can also execute notebooks from the command line with
97
84
  [`exec_nb`](https://AnswerDotAI.github.io/execnb/shell.html#exec_nb):
@@ -101,8 +88,7 @@ You can also execute notebooks from the command line with
101
88
  ```
102
89
 
103
90
  usage: exec_nb [-h] [--dest DEST] [--exc_stop] [--inject_code INJECT_CODE]
104
- [--inject_path INJECT_PATH] [--inject_idx INJECT_IDX]
105
- [--verbose]
91
+ [--inject_path INJECT_PATH] [--inject_idx INJECT_IDX] [--verbose]
106
92
  src
107
93
 
108
94
  Execute notebook from `src` and save with outputs to `dest`
@@ -110,11 +96,12 @@ You can also execute notebooks from the command line with
110
96
  positional arguments:
111
97
  src Notebook path to read from
112
98
 
113
- optional arguments:
99
+ options:
114
100
  -h, --help show this help message and exit
115
101
  --dest DEST Notebook path to write to (default: )
116
102
  --exc_stop Stop on exceptions? (default: False)
117
103
  --inject_code INJECT_CODE Code to inject into a cell
118
104
  --inject_path INJECT_PATH Path to file containing code to inject into a cell
119
105
  --inject_idx INJECT_IDX Cell to replace with `inject_code` (default: 0)
120
- --verbose Show stdout/stderr during execution (default: False)
106
+ --verbose Show stdout/stderr during execution (default:
107
+ False)
@@ -28,9 +28,9 @@ to run Jupyter code and capture notebook outputs, without running a
28
28
  Jupyter server (or even having it installed):
29
29
 
30
30
  ``` python
31
- from execnb.nbio import *
32
31
  from execnb.shell import *
33
32
  from fastcore.utils import *
33
+ from fastcore.nbio import *
34
34
  ```
35
35
 
36
36
  ``` python
@@ -41,7 +41,7 @@ s.run('1+1')
41
41
  [{'data': {'text/plain': ['2']},
42
42
  'metadata': {},
43
43
  'output_type': 'execute_result',
44
- 'execution_count': 1}]
44
+ 'execution_count': None}]
45
45
 
46
46
  To execute a notebook and save it with outputs filled in, use
47
47
  [`CaptureShell.execute`](https://AnswerDotAI.github.io/execnb/shell.html#captureshell.execute):
@@ -53,7 +53,7 @@ try:
53
53
  finally: Path('tmp.ipynb').unlink()
54
54
  ```
55
55
 
56
- [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\n']}, {'data': {'text/plain': ['2']}, 'execution_count': 3, 'metadata': {}, 'output_type': 'execute_result'}]
56
+ [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\n']}, {'data': {'text/plain': ['2']}, 'execution_count': None, 'metadata': {}, 'output_type': 'execute_result'}]
57
57
 
58
58
  You can also execute notebooks from the command line with
59
59
  [`exec_nb`](https://AnswerDotAI.github.io/execnb/shell.html#exec_nb):
@@ -63,8 +63,7 @@ You can also execute notebooks from the command line with
63
63
  ```
64
64
 
65
65
  usage: exec_nb [-h] [--dest DEST] [--exc_stop] [--inject_code INJECT_CODE]
66
- [--inject_path INJECT_PATH] [--inject_idx INJECT_IDX]
67
- [--verbose]
66
+ [--inject_path INJECT_PATH] [--inject_idx INJECT_IDX] [--verbose]
68
67
  src
69
68
 
70
69
  Execute notebook from `src` and save with outputs to `dest`
@@ -72,11 +71,12 @@ You can also execute notebooks from the command line with
72
71
  positional arguments:
73
72
  src Notebook path to read from
74
73
 
75
- optional arguments:
74
+ options:
76
75
  -h, --help show this help message and exit
77
76
  --dest DEST Notebook path to write to (default: )
78
77
  --exc_stop Stop on exceptions? (default: False)
79
78
  --inject_code INJECT_CODE Code to inject into a cell
80
79
  --inject_path INJECT_PATH Path to file containing code to inject into a cell
81
80
  --inject_idx INJECT_IDX Cell to replace with `inject_code` (default: 0)
82
- --verbose Show stdout/stderr during execution (default: False)
81
+ --verbose Show stdout/stderr during execution (default:
82
+ False)
@@ -0,0 +1 @@
1
+ __version__ = "0.2.1"
@@ -1,26 +1,11 @@
1
1
  # Autogenerated by nbdev
2
2
 
3
3
  d = { 'settings': { 'branch': 'main',
4
- 'doc_baseurl': '/execnb/',
4
+ 'doc_baseurl': '/execnb',
5
5
  'doc_host': 'https://AnswerDotAI.github.io',
6
- 'git_url': 'https://github.com/AnswerDotAI/execnb/',
6
+ 'git_url': 'https://github.com/AnswerDotAI/execnb',
7
7
  'lib_path': 'execnb'},
8
- 'syms': { 'execnb.nbio': { 'execnb.nbio.NbCell': ('nbio.html#nbcell', 'execnb/nbio.py'),
9
- 'execnb.nbio.NbCell.__eq__': ('nbio.html#nbcell.__eq__', 'execnb/nbio.py'),
10
- 'execnb.nbio.NbCell.__hash__': ('nbio.html#nbcell.__hash__', 'execnb/nbio.py'),
11
- 'execnb.nbio.NbCell.__init__': ('nbio.html#nbcell.__init__', 'execnb/nbio.py'),
12
- 'execnb.nbio.NbCell.parsed_': ('nbio.html#nbcell.parsed_', 'execnb/nbio.py'),
13
- 'execnb.nbio.NbCell.set_source': ('nbio.html#nbcell.set_source', 'execnb/nbio.py'),
14
- 'execnb.nbio._dict2obj': ('nbio.html#_dict2obj', 'execnb/nbio.py'),
15
- 'execnb.nbio._read_json': ('nbio.html#_read_json', 'execnb/nbio.py'),
16
- 'execnb.nbio.dict2nb': ('nbio.html#dict2nb', 'execnb/nbio.py'),
17
- 'execnb.nbio.mk_cell': ('nbio.html#mk_cell', 'execnb/nbio.py'),
18
- 'execnb.nbio.nb2dict': ('nbio.html#nb2dict', 'execnb/nbio.py'),
19
- 'execnb.nbio.nb2str': ('nbio.html#nb2str', 'execnb/nbio.py'),
20
- 'execnb.nbio.new_nb': ('nbio.html#new_nb', 'execnb/nbio.py'),
21
- 'execnb.nbio.read_nb': ('nbio.html#read_nb', 'execnb/nbio.py'),
22
- 'execnb.nbio.write_nb': ('nbio.html#write_nb', 'execnb/nbio.py')},
23
- 'execnb.shell': { 'execnb.shell.CaptureShell': ('shell.html#captureshell', 'execnb/shell.py'),
8
+ 'syms': { 'execnb.shell': { 'execnb.shell.CaptureShell': ('shell.html#captureshell', 'execnb/shell.py'),
24
9
  'execnb.shell.CaptureShell.__init__': ('shell.html#captureshell.__init__', 'execnb/shell.py'),
25
10
  'execnb.shell.CaptureShell._run': ('shell.html#captureshell._run', 'execnb/shell.py'),
26
11
  'execnb.shell.CaptureShell.cell': ('shell.html#captureshell.cell', 'execnb/shell.py'),
@@ -1,10 +1,12 @@
1
1
  """A shell for running notebook code without a notebook server"""
2
2
 
3
- # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/02_shell.ipynb.
3
+ # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/00_shell.ipynb.
4
4
 
5
- # %% ../nbs/02_shell.ipynb 2
6
- from __future__ import annotations
5
+ # %% auto #0
6
+ __all__ = ['CaptureShell', 'format_exc', 'NbResult', 'render_outputs', 'find_output', 'out_exec', 'out_stream', 'out_error',
7
+ 'exec_nb', 'SmartCompleter']
7
8
 
9
+ # %% ../nbs/00_shell.ipynb #535003cf
8
10
  from fastcore.utils import *
9
11
  from fastcore.script import call_parse
10
12
  from fastcore.ansi import ansi2html, strip_ansi
@@ -29,15 +31,11 @@ try: from matplotlib_inline.backend_inline import set_matplotlib_formats
29
31
  except ImportError: set_matplotlib_formats = None
30
32
 
31
33
 
32
- from .nbio import *
33
- from .nbio import _dict2obj
34
-
34
+ from fastcore.nbio import *
35
+ from fastcore.nbio import _dict2obj
35
36
 
36
- # %% auto 0
37
- __all__ = ['CaptureShell', 'format_exc', 'NbResult', 'render_outputs', 'find_output', 'out_exec', 'out_stream', 'out_error',
38
- 'exec_nb', 'SmartCompleter']
39
37
 
40
- # %% ../nbs/02_shell.ipynb
38
+ # %% ../nbs/00_shell.ipynb #6913382c
41
39
  class _CustDisplayHook(DisplayHook):
42
40
  def write_output_prompt(self): pass
43
41
  def write_format_data(self, data, md_dict): pass
@@ -49,7 +47,7 @@ def __repr__(self: ExecutionInfo): return f'cell: {self.raw_cell}; id: {self.cel
49
47
  @patch
50
48
  def __repr__(self: ExecutionResult): return f'result: {self.result}; err: {self.error_in_exec}; info: <{self.info}>'
51
49
 
52
- # %% ../nbs/02_shell.ipynb
50
+ # %% ../nbs/00_shell.ipynb #e3fb2bee
53
51
  class CaptureShell(InteractiveShell):
54
52
  displayhook_class = _CustDisplayHook
55
53
 
@@ -84,7 +82,7 @@ class CaptureShell(InteractiveShell):
84
82
 
85
83
  def enable_gui(self, gui=None): pass
86
84
 
87
- # %% ../nbs/02_shell.ipynb
85
+ # %% ../nbs/00_shell.ipynb #93adf867
88
86
  @patch
89
87
  def run_cell(self:CaptureShell, raw_cell, store_history=False, silent=False, shell_futures=True, cell_id=None,
90
88
  stdout=True, stderr=True, display=True, timeout=None, verbose=False):
@@ -98,15 +96,15 @@ def run_cell(self:CaptureShell, raw_cell, store_history=False, silent=False, she
98
96
  finally:
99
97
  if timeout: signal.alarm(0)
100
98
 
101
- # %% ../nbs/02_shell.ipynb
99
+ # %% ../nbs/00_shell.ipynb #a1eb7703
102
100
  def format_exc(e):
103
101
  "Format exception `e` as a string list"
104
102
  return traceback.format_exception(type(e), e, e.__traceback__)
105
103
 
106
- # %% ../nbs/02_shell.ipynb
104
+ # %% ../nbs/00_shell.ipynb #8ba0ae59
107
105
  class NbResult(list): pass
108
106
 
109
- # %% ../nbs/02_shell.ipynb
107
+ # %% ../nbs/00_shell.ipynb #26bf9161
110
108
  def _out_stream(text, name): return dict(name=name, output_type='stream', text=text.splitlines(True))
111
109
  def _out_exc(e):
112
110
  ename = type(e).__name__
@@ -139,7 +137,7 @@ def _out_nb(o, fmt):
139
137
  if p["output_type"]=="execute_result": p['execution_count'] = o['execution_count']
140
138
  return res
141
139
 
142
- # %% ../nbs/02_shell.ipynb
140
+ # %% ../nbs/00_shell.ipynb #242f732f
143
141
  @patch
144
142
  def run(self:CaptureShell,
145
143
  code:str, # Python/IPython code to run
@@ -153,7 +151,7 @@ def run(self:CaptureShell,
153
151
  self.exc = res.exception
154
152
  return _out_nb(res, self.display_formatter)
155
153
 
156
- # %% ../nbs/02_shell.ipynb
154
+ # %% ../nbs/00_shell.ipynb #eaa11df9
157
155
  @patch
158
156
  async def run_async(self:CaptureShell,
159
157
  code: str, # Python/IPython code to run
@@ -163,7 +161,7 @@ async def run_async(self:CaptureShell,
163
161
  verbose:bool=False): # Show stdout/stderr during execution
164
162
  return self.run(code, stdout=stdout, stderr=stderr, timeout=timeout, verbose=verbose)
165
163
 
166
- # %% ../nbs/02_shell.ipynb
164
+ # %% ../nbs/00_shell.ipynb #f698a432
167
165
  def _pre(s, xtra=''): return f"<pre {xtra}><code>{escape(s)}</code></pre>"
168
166
  def _strip(s): return strip_ansi(escape(s))
169
167
 
@@ -198,7 +196,7 @@ def render_outputs(outputs, ansi_renderer=_strip, include_imgs=True, pygments=Fa
198
196
 
199
197
  return '\n'.join(map(render_output, outputs))
200
198
 
201
- # %% ../nbs/02_shell.ipynb
199
+ # %% ../nbs/00_shell.ipynb #c6176b9e
202
200
  @patch
203
201
  def cell(self:CaptureShell, cell, stdout=True, stderr=True, verbose=False):
204
202
  "Run `cell`, skipping if not code, and store outputs back in cell"
@@ -207,32 +205,32 @@ def cell(self:CaptureShell, cell, stdout=True, stderr=True, verbose=False):
207
205
  outs = self.run(cell.source, verbose=verbose)
208
206
  if outs: cell.outputs = _dict2obj(outs)
209
207
 
210
- # %% ../nbs/02_shell.ipynb
208
+ # %% ../nbs/00_shell.ipynb #008c0cef
211
209
  def find_output(outp, # Output from `run`
212
210
  ot='execute_result' # Output_type to find
213
211
  ):
214
212
  "Find first output of type `ot` in `CaptureShell.run` output"
215
213
  return first(o for o in outp if o['output_type']==ot)
216
214
 
217
- # %% ../nbs/02_shell.ipynb
215
+ # %% ../nbs/00_shell.ipynb #6e677414
218
216
  def out_exec(outp):
219
217
  "Get data from execution result in `outp`."
220
218
  out = find_output(outp)
221
219
  if out: return '\n'.join(first(out['data'].values()))
222
220
 
223
- # %% ../nbs/02_shell.ipynb
221
+ # %% ../nbs/00_shell.ipynb #c7352a2b
224
222
  def out_stream(outp):
225
223
  "Get text from stream in `outp`."
226
224
  out = find_output(outp, 'stream')
227
225
  if out: return ('\n'.join(out['text'])).strip()
228
226
 
229
- # %% ../nbs/02_shell.ipynb
227
+ # %% ../nbs/00_shell.ipynb #7d52326c
230
228
  def out_error(outp):
231
229
  "Get traceback from error in `outp`."
232
230
  out = find_output(outp, 'error')
233
231
  if out: return '\n'.join(out['traceback'])
234
232
 
235
- # %% ../nbs/02_shell.ipynb
233
+ # %% ../nbs/00_shell.ipynb #60a25f27
236
234
  def _false(o): return False
237
235
 
238
236
  @patch
@@ -253,7 +251,7 @@ def run_all(self:CaptureShell,
253
251
  postproc(cell)
254
252
  if self.exc and exc_stop: raise self.exc from None
255
253
 
256
- # %% ../nbs/02_shell.ipynb
254
+ # %% ../nbs/00_shell.ipynb #70808010
257
255
  @patch
258
256
  def execute(self:CaptureShell,
259
257
  src:str|Path, # Notebook path to read from
@@ -275,7 +273,7 @@ def execute(self:CaptureShell,
275
273
  inject_code=inject_code, inject_idx=inject_idx, verbose=verbose)
276
274
  if dest: write_nb(nb, dest)
277
275
 
278
- # %% ../nbs/02_shell.ipynb
276
+ # %% ../nbs/00_shell.ipynb #694161cb
279
277
  @patch
280
278
  def prettytb(self:CaptureShell,
281
279
  fname:str|Path=None): # filename to print alongside the traceback
@@ -287,7 +285,7 @@ def prettytb(self:CaptureShell,
287
285
  fname_str = f' in {fname}' if fname else ''
288
286
  return f"{type(self.exc).__name__}{fname_str}:\n{_fence}\n{cell_str}\n"
289
287
 
290
- # %% ../nbs/02_shell.ipynb
288
+ # %% ../nbs/00_shell.ipynb #1227c8b1
291
289
  @call_parse
292
290
  def exec_nb(
293
291
  src:str, # Notebook path to read from
@@ -302,7 +300,7 @@ def exec_nb(
302
300
  CaptureShell().execute(src, dest, exc_stop=exc_stop, inject_code=inject_code,
303
301
  inject_path=inject_path, inject_idx=inject_idx, verbose=verbose)
304
302
 
305
- # %% ../nbs/02_shell.ipynb
303
+ # %% ../nbs/00_shell.ipynb #c44963a0
306
304
  class SmartCompleter(IPCompleter):
307
305
  def __init__(self, shell, namespace=None, jedi=False):
308
306
  if namespace is None: namespace = shell.user_ns
@@ -322,7 +320,7 @@ class SmartCompleter(IPCompleter):
322
320
  if res and res[0][-1]=='=': res = [o for o in res if o[-1]=='=']
323
321
  return res
324
322
 
325
- # %% ../nbs/02_shell.ipynb
323
+ # %% ../nbs/00_shell.ipynb #7d7c852c
326
324
  @patch
327
325
  def complete(self:CaptureShell, c):
328
326
  if not hasattr(self, '_completer'): self._completer = SmartCompleter(self)
@@ -1,18 +1,17 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: execnb
3
- Version: 0.1.18
3
+ Version: 0.2.1
4
4
  Summary: A description of your project
5
- Home-page: https://github.com/AnswerDotAI/execnb/
6
- Author: Jeremy Howard
7
- Author-email: j@fast.ai
8
- License: Apache Software License 2.0
9
- Keywords: some keywords
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: Intended Audience :: Developers
5
+ Author-email: Jeremy Howard <j@fast.ai>
6
+ License: Apache-2.0
7
+ Project-URL: Repository, https://github.com/AnswerDotAI/execnb/
8
+ Project-URL: Documentation, https://AnswerDotAI.github.io/execnb/
9
+ Keywords: some,keywords
12
10
  Classifier: Natural Language :: English
13
- Classifier: Programming Language :: Python :: 3.7
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: License :: OSI Approved :: Apache Software License
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Development Status :: 2 - Pre-Alpha
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
16
15
  Requires-Python: >=3.7
17
16
  Description-Content-Type: text/markdown
18
17
  License-File: LICENSE
@@ -22,19 +21,7 @@ Provides-Extra: dev
22
21
  Requires-Dist: matplotlib; extra == "dev"
23
22
  Requires-Dist: Pillow; extra == "dev"
24
23
  Requires-Dist: mistletoe; extra == "dev"
25
- Dynamic: author
26
- Dynamic: author-email
27
- Dynamic: classifier
28
- Dynamic: description
29
- Dynamic: description-content-type
30
- Dynamic: home-page
31
- Dynamic: keywords
32
- Dynamic: license
33
24
  Dynamic: license-file
34
- Dynamic: provides-extra
35
- Dynamic: requires-dist
36
- Dynamic: requires-python
37
- Dynamic: summary
38
25
 
39
26
  # execnb
40
27
 
@@ -66,9 +53,9 @@ to run Jupyter code and capture notebook outputs, without running a
66
53
  Jupyter server (or even having it installed):
67
54
 
68
55
  ``` python
69
- from execnb.nbio import *
70
56
  from execnb.shell import *
71
57
  from fastcore.utils import *
58
+ from fastcore.nbio import *
72
59
  ```
73
60
 
74
61
  ``` python
@@ -79,7 +66,7 @@ s.run('1+1')
79
66
  [{'data': {'text/plain': ['2']},
80
67
  'metadata': {},
81
68
  'output_type': 'execute_result',
82
- 'execution_count': 1}]
69
+ 'execution_count': None}]
83
70
 
84
71
  To execute a notebook and save it with outputs filled in, use
85
72
  [`CaptureShell.execute`](https://AnswerDotAI.github.io/execnb/shell.html#captureshell.execute):
@@ -91,7 +78,7 @@ try:
91
78
  finally: Path('tmp.ipynb').unlink()
92
79
  ```
93
80
 
94
- [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\n']}, {'data': {'text/plain': ['2']}, 'execution_count': 3, 'metadata': {}, 'output_type': 'execute_result'}]
81
+ [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\n']}, {'data': {'text/plain': ['2']}, 'execution_count': None, 'metadata': {}, 'output_type': 'execute_result'}]
95
82
 
96
83
  You can also execute notebooks from the command line with
97
84
  [`exec_nb`](https://AnswerDotAI.github.io/execnb/shell.html#exec_nb):
@@ -101,8 +88,7 @@ You can also execute notebooks from the command line with
101
88
  ```
102
89
 
103
90
  usage: exec_nb [-h] [--dest DEST] [--exc_stop] [--inject_code INJECT_CODE]
104
- [--inject_path INJECT_PATH] [--inject_idx INJECT_IDX]
105
- [--verbose]
91
+ [--inject_path INJECT_PATH] [--inject_idx INJECT_IDX] [--verbose]
106
92
  src
107
93
 
108
94
  Execute notebook from `src` and save with outputs to `dest`
@@ -110,11 +96,12 @@ You can also execute notebooks from the command line with
110
96
  positional arguments:
111
97
  src Notebook path to read from
112
98
 
113
- optional arguments:
99
+ options:
114
100
  -h, --help show this help message and exit
115
101
  --dest DEST Notebook path to write to (default: )
116
102
  --exc_stop Stop on exceptions? (default: False)
117
103
  --inject_code INJECT_CODE Code to inject into a cell
118
104
  --inject_path INJECT_PATH Path to file containing code to inject into a cell
119
105
  --inject_idx INJECT_IDX Cell to replace with `inject_code` (default: 0)
120
- --verbose Show stdout/stderr during execution (default: False)
106
+ --verbose Show stdout/stderr during execution (default:
107
+ False)
@@ -2,16 +2,12 @@ LICENSE
2
2
  MANIFEST.in
3
3
  README.md
4
4
  pyproject.toml
5
- settings.ini
6
- setup.py
7
5
  execnb/__init__.py
8
6
  execnb/_modidx.py
9
- execnb/nbio.py
10
7
  execnb/shell.py
11
8
  execnb.egg-info/PKG-INFO
12
9
  execnb.egg-info/SOURCES.txt
13
10
  execnb.egg-info/dependency_links.txt
14
11
  execnb.egg-info/entry_points.txt
15
- execnb.egg-info/not-zip-safe
16
12
  execnb.egg-info/requires.txt
17
13
  execnb.egg-info/top_level.txt
@@ -0,0 +1,42 @@
1
+ [build-system]
2
+ requires = ["setuptools>=64"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "execnb"
7
+ dynamic = ["version"]
8
+ description = "A description of your project"
9
+ readme = "README.md"
10
+ requires-python = ">=3.7"
11
+ license = {text = "Apache-2.0"}
12
+ authors = [{name = "Jeremy Howard", email = "j@fast.ai"}]
13
+ keywords = ['some', 'keywords']
14
+ classifiers = ["Natural Language :: English", "Intended Audience :: Developers", "Development Status :: 2 - Pre-Alpha", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only"]
15
+ dependencies = ['fastcore>=1.10.4', 'ipython']
16
+
17
+ [project.urls]
18
+ Repository = "https://github.com/AnswerDotAI/execnb/"
19
+ Documentation = "https://AnswerDotAI.github.io/execnb/"
20
+
21
+ [project.entry-points.nbdev]
22
+ execnb = "execnb._modidx:d"
23
+
24
+ [project.optional-dependencies]
25
+ dev = ['matplotlib', 'Pillow', 'mistletoe']
26
+
27
+
28
+ [project.scripts]
29
+ exec_nb = "execnb.shell:exec_nb"
30
+
31
+ [tool.setuptools.dynamic]
32
+ version = {attr = "execnb.__version__"}
33
+
34
+ [tool.setuptools.packages.find]
35
+ include = ["execnb"]
36
+
37
+ [tool.nbdev]
38
+ allowed_metadata_keys = ['solveit_dialog_mode', 'solveit_ver']
39
+ allowed_cell_metadata_keys = ["solveit_ai"]
40
+ recursive = false
41
+ jupyter_hooks = true
42
+ custom_sidebar = false
@@ -1 +0,0 @@
1
- __version__ = "0.1.18"
@@ -1,104 +0,0 @@
1
- """Reading and writing Jupyter notebooks"""
2
-
3
- # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_nbio.ipynb.
4
-
5
- # %% auto 0
6
- __all__ = ['NbCell', 'dict2nb', 'read_nb', 'mk_cell', 'new_nb', 'nb2dict', 'nb2str', 'write_nb']
7
-
8
- # %% ../nbs/01_nbio.ipynb
9
- from fastcore.basics import *
10
- from fastcore.xtras import rtoken_hex
11
- from fastcore.imports import *
12
-
13
- import ast,functools
14
- from pprint import pformat,pprint
15
- from json import loads,dumps
16
-
17
- # %% ../nbs/01_nbio.ipynb
18
- def _read_json(self, encoding=None, errors=None):
19
- return loads(Path(self).read_text(encoding=encoding, errors=errors))
20
-
21
- # %% ../nbs/01_nbio.ipynb
22
- class NbCell(AttrDict):
23
- def __init__(self, idx, cell):
24
- super().__init__(cell)
25
- self.idx_ = idx
26
- if 'id' not in self: self.id = rtoken_hex(4)
27
- if 'source' in self: self.set_source(self.source)
28
-
29
- def set_source(self, source):
30
- self.source = ''.join(source)
31
- if '_parsed_' in self: del(self['_parsed_'])
32
-
33
- def parsed_(self):
34
- if self.cell_type!='code' or self.source.strip()[:1] in ['%', '!']: return
35
- if '_parsed_' not in self:
36
- try: self._parsed_ = ast.parse(self.source).body
37
- # you can assign the result of ! to a variable in a notebook cell
38
- # which will result in a syntax error if parsed with the ast module.
39
- except SyntaxError: return
40
- return self._parsed_
41
-
42
- def __hash__(self): return hash(self.source) + hash(self.cell_type)
43
- def __eq__(self,o): return self.source==o.source and self.cell_type==o.cell_type
44
-
45
- # %% ../nbs/01_nbio.ipynb
46
- def _dict2obj(d, list_func=list, dict_func=AttrDict):
47
- "Convert (possibly nested) dicts (or lists of dicts) to `AttrDict`"
48
- if isinstance(d, list): return list(map(_dict2obj, d))
49
- if not isinstance(d, dict): return d
50
- return dict_func(**{k:_dict2obj(v) for k,v in d.items()})
51
-
52
- def dict2nb(js=None, **kwargs):
53
- "Convert dict `js` to an `AttrDict`, "
54
- nb = _dict2obj(js or kwargs)
55
- nb.cells = [NbCell(*o) for o in enumerate(nb.cells)]
56
- return nb
57
-
58
- # %% ../nbs/01_nbio.ipynb
59
- def read_nb(path):
60
- "Return notebook at `path`"
61
- res = dict2nb(_read_json(path, encoding='utf-8'))
62
- res['path_'] = str(path)
63
- return res
64
-
65
- # %% ../nbs/01_nbio.ipynb
66
- def mk_cell(text, # `source` attr in cell
67
- cell_type='code', # `cell_type` attr in cell
68
- **kwargs): # any other attrs to add to cell
69
- "Create an `NbCell` containing `text`"
70
- assert cell_type in {'code', 'markdown', 'raw'}
71
- if 'metadata' not in kwargs: kwargs['metadata']={}
72
- if cell_type == 'code':
73
- kwargs['outputs']=[]
74
- kwargs['execution_count']=0
75
- return NbCell(0, dict(cell_type=cell_type, source=text, directives_={}, **kwargs))
76
-
77
- # %% ../nbs/01_nbio.ipynb
78
- def new_nb(cells=None, meta=None, nbformat=4, nbformat_minor=5):
79
- "Returns an empty new notebook"
80
- cells = [o if isinstance(o,dict) else mk_cell(o) for o in cells]
81
- return dict2nb(cells=cells or [],metadata=meta or {},nbformat=nbformat,nbformat_minor=nbformat_minor)
82
-
83
- # %% ../nbs/01_nbio.ipynb
84
- def nb2dict(d, k=None):
85
- "Convert parsed notebook to `dict`"
86
- if k=='source': return d.splitlines(keepends=True)
87
- if isinstance(d, list): return list(map(nb2dict,d))
88
- if not isinstance(d, dict): return d
89
- return dict(**{k:nb2dict(v,k) for k,v in d.items() if k[-1] != '_'})
90
-
91
- # %% ../nbs/01_nbio.ipynb
92
- def nb2str(nb):
93
- "Convert `nb` to a `str`"
94
- if isinstance(nb, (AttrDict,list)): nb = nb2dict(nb)
95
- return dumps(nb, sort_keys=True, indent=1, ensure_ascii=False) + "\n"
96
-
97
- # %% ../nbs/01_nbio.ipynb
98
- def write_nb(nb, path):
99
- "Write `nb` to `path`"
100
- new = nb2str(nb)
101
- path = Path(path)
102
- old = Path(path).read_text(encoding='utf-8') if path.exists() else None
103
- if new!=old:
104
- with open(path, 'w', encoding='utf-8') as f: f.write(new)
@@ -1 +0,0 @@
1
-
@@ -1,11 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=64.0"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name="execnb"
7
- requires-python=">=3.7"
8
- dynamic = [ "keywords", "description", "version", "dependencies", "optional-dependencies", "readme", "license", "authors", "classifiers", "entry-points", "scripts", "urls"]
9
-
10
- [tool.uv]
11
- cache-keys = [{ file = "pyproject.toml" }, { file = "settings.ini" }, { file = "setup.py" }]
@@ -1,45 +0,0 @@
1
- [DEFAULT]
2
- host = github
3
- lib_name = execnb
4
- repo = execnb
5
- description = A description of your project
6
- copyright = Put your copyright info here
7
- keywords = some keywords
8
- user = AnswerDotAI
9
- author = Jeremy Howard
10
- author_email = j@fast.ai
11
- branch = main
12
- version = 0.1.18
13
- min_python = 3.7
14
- requirements = fastcore>=1.10.4 ipython
15
- dev_requirements = matplotlib Pillow mistletoe
16
- console_scripts = exec_nb=execnb.shell:exec_nb
17
- audience = Developers
18
- language = English
19
- custom_sidebar = False
20
- license = apache2
21
- status = 2
22
- nbs_path = nbs
23
- doc_path = _docs
24
- recursive = False
25
- tst_flags = notest
26
- doc_host = https://AnswerDotAI.github.io
27
- doc_baseurl = /execnb/
28
- git_url = https://github.com/AnswerDotAI/execnb/
29
- lib_path = execnb
30
- title = execnb
31
- black_formatting = False
32
- readme_nb = index.ipynb
33
- allowed_metadata_keys =
34
- allowed_cell_metadata_keys =
35
- conda_user = fastai
36
- preview_port = 3000
37
- preview_host = localhost
38
- jupyter_hooks = True
39
- clean_ids = True
40
- clear_all = False
41
- put_version_in_init = True
42
- cell_number = False
43
- skip_procs =
44
- update_pyproject = True
45
-
execnb-0.1.18/setup.py DELETED
@@ -1,55 +0,0 @@
1
- from pkg_resources import parse_version
2
- from configparser import ConfigParser
3
- import setuptools
4
- assert parse_version(setuptools.__version__)>=parse_version('36.2')
5
-
6
- # note: all settings are in settings.ini; edit there, not here
7
- config = ConfigParser(delimiters=['='])
8
- config.read('settings.ini')
9
- cfg = config['DEFAULT']
10
-
11
- cfg_keys = 'version description keywords author author_email'.split()
12
- expected = cfg_keys + "lib_name user branch license status min_python audience language".split()
13
- for o in expected: assert o in cfg, "missing expected setting: {}".format(o)
14
- setup_cfg = {o:cfg[o] for o in cfg_keys}
15
-
16
- licenses = {
17
- 'apache2': ('Apache Software License 2.0','OSI Approved :: Apache Software License'),
18
- 'mit': ('MIT License', 'OSI Approved :: MIT License'),
19
- 'gpl2': ('GNU General Public License v2', 'OSI Approved :: GNU General Public License v2 (GPLv2)'),
20
- 'gpl3': ('GNU General Public License v3', 'OSI Approved :: GNU General Public License v3 (GPLv3)'),
21
- 'bsd3': ('BSD License', 'OSI Approved :: BSD License'),
22
- }
23
- statuses = [ '1 - Planning', '2 - Pre-Alpha', '3 - Alpha',
24
- '4 - Beta', '5 - Production/Stable', '6 - Mature', '7 - Inactive' ]
25
- py_versions = '2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8'.split()
26
-
27
- requirements = cfg.get('requirements','').split()
28
- min_python = cfg['min_python']
29
- lic = licenses.get(cfg['license'].lower(), (cfg['license'], None))
30
- dev_requirements = (cfg.get('dev_requirements') or '').split()
31
-
32
- setuptools.setup(
33
- name = cfg['lib_name'],
34
- license = lic[0],
35
- classifiers = [
36
- 'Development Status :: ' + statuses[int(cfg['status'])],
37
- 'Intended Audience :: ' + cfg['audience'].title(),
38
- 'Natural Language :: ' + cfg['language'].title(),
39
- ] + ['Programming Language :: Python :: '+o for o in py_versions[py_versions.index(min_python):]] + (['License :: ' + lic[1] ] if lic[1] else []),
40
- url = cfg['git_url'],
41
- packages = setuptools.find_packages(),
42
- include_package_data = True,
43
- install_requires = requirements,
44
- extras_require={ 'dev': dev_requirements },
45
- dependency_links = cfg.get('dep_links','').split(),
46
- python_requires = '>=' + cfg['min_python'],
47
- long_description = open('README.md', encoding="utf8").read(),
48
- long_description_content_type = 'text/markdown',
49
- zip_safe = False,
50
- entry_points = {
51
- 'console_scripts': cfg.get('console_scripts','').split(),
52
- 'nbdev': [f'{cfg.get("lib_path")}={cfg.get("lib_path")}._modidx:d']
53
- },
54
- **setup_cfg)
55
-
File without changes
File without changes
File without changes