execnb 0.1.14__tar.gz → 0.1.15__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.
- {execnb-0.1.14/execnb.egg-info → execnb-0.1.15}/PKG-INFO +3 -1
- {execnb-0.1.14 → execnb-0.1.15}/README.md +2 -0
- execnb-0.1.15/execnb/__init__.py +1 -0
- {execnb-0.1.14 → execnb-0.1.15}/execnb/shell.py +21 -16
- {execnb-0.1.14 → execnb-0.1.15/execnb.egg-info}/PKG-INFO +3 -1
- {execnb-0.1.14 → execnb-0.1.15}/settings.ini +1 -1
- execnb-0.1.14/execnb/__init__.py +0 -1
- {execnb-0.1.14 → execnb-0.1.15}/LICENSE +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/MANIFEST.in +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/execnb/_modidx.py +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/execnb/nbio.py +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/execnb.egg-info/SOURCES.txt +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/execnb.egg-info/dependency_links.txt +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/execnb.egg-info/entry_points.txt +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/execnb.egg-info/not-zip-safe +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/execnb.egg-info/requires.txt +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/execnb.egg-info/top_level.txt +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/pyproject.toml +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/setup.cfg +0 -0
- {execnb-0.1.14 → execnb-0.1.15}/setup.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: execnb
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.15
|
4
4
|
Summary: A description of your project
|
5
5
|
Home-page: https://github.com/AnswerDotAI/execnb/
|
6
6
|
Author: Jeremy Howard
|
@@ -102,6 +102,7 @@ You can also execute notebooks from the command line with
|
|
102
102
|
|
103
103
|
usage: exec_nb [-h] [--dest DEST] [--exc_stop] [--inject_code INJECT_CODE]
|
104
104
|
[--inject_path INJECT_PATH] [--inject_idx INJECT_IDX]
|
105
|
+
[--verbose]
|
105
106
|
src
|
106
107
|
|
107
108
|
Execute notebook from `src` and save with outputs to `dest`
|
@@ -116,3 +117,4 @@ You can also execute notebooks from the command line with
|
|
116
117
|
--inject_code INJECT_CODE Code to inject into a cell
|
117
118
|
--inject_path INJECT_PATH Path to file containing code to inject into a cell
|
118
119
|
--inject_idx INJECT_IDX Cell to replace with `inject_code` (default: 0)
|
120
|
+
--verbose Show stdout/stderr during execution (default: False)
|
@@ -64,6 +64,7 @@ You can also execute notebooks from the command line with
|
|
64
64
|
|
65
65
|
usage: exec_nb [-h] [--dest DEST] [--exc_stop] [--inject_code INJECT_CODE]
|
66
66
|
[--inject_path INJECT_PATH] [--inject_idx INJECT_IDX]
|
67
|
+
[--verbose]
|
67
68
|
src
|
68
69
|
|
69
70
|
Execute notebook from `src` and save with outputs to `dest`
|
@@ -78,3 +79,4 @@ You can also execute notebooks from the command line with
|
|
78
79
|
--inject_code INJECT_CODE Code to inject into a cell
|
79
80
|
--inject_path INJECT_PATH Path to file containing code to inject into a cell
|
80
81
|
--inject_idx INJECT_IDX Cell to replace with `inject_code` (default: 0)
|
82
|
+
--verbose Show stdout/stderr during execution (default: False)
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.1.15"
|
@@ -67,10 +67,10 @@ class CaptureShell(InteractiveShell):
|
|
67
67
|
self._run(f"set_matplotlib_formats('{mpl_format}')")
|
68
68
|
|
69
69
|
def _run(self, raw_cell, store_history=False, silent=False, shell_futures=True, cell_id=None,
|
70
|
-
stdout=True, stderr=True, display=True):
|
70
|
+
stdout=True, stderr=True, display=True, verbose=False):
|
71
71
|
# TODO what if there's a comment?
|
72
72
|
semic = raw_cell.rstrip().endswith(';')
|
73
|
-
with capture_output(display=display, stdout=stdout, stderr=stderr) as c:
|
73
|
+
with capture_output(display=display, stdout=stdout and not verbose, stderr=stderr and not verbose) as c:
|
74
74
|
result = super().run_cell(raw_cell, store_history, silent, shell_futures=shell_futures, cell_id=cell_id)
|
75
75
|
return AttrDict(result=result, stdout='' if semic else c.stdout, stderr=c.stderr,
|
76
76
|
display_objects=c.outputs, exception=result.error_in_exec, quiet=semic)
|
@@ -86,14 +86,14 @@ class CaptureShell(InteractiveShell):
|
|
86
86
|
# %% ../nbs/02_shell.ipynb
|
87
87
|
@patch
|
88
88
|
def run_cell(self:CaptureShell, raw_cell, store_history=False, silent=False, shell_futures=True, cell_id=None,
|
89
|
-
stdout=True, stderr=True, display=True, timeout=None):
|
89
|
+
stdout=True, stderr=True, display=True, timeout=None, verbose=False):
|
90
90
|
if not timeout: timeout = self.timeout
|
91
91
|
if timeout:
|
92
92
|
def handler(*args): raise TimeoutError()
|
93
93
|
signal.signal(signal.SIGALRM, handler)
|
94
94
|
signal.alarm(timeout)
|
95
95
|
try: return self._run(raw_cell, store_history, silent, shell_futures, cell_id=cell_id,
|
96
|
-
stdout=stdout, stderr=stderr, display=display)
|
96
|
+
stdout=stdout, stderr=stderr, display=display, verbose=verbose)
|
97
97
|
finally:
|
98
98
|
if timeout: signal.alarm(0)
|
99
99
|
|
@@ -144,9 +144,10 @@ def run(self:CaptureShell,
|
|
144
144
|
code:str, # Python/IPython code to run
|
145
145
|
stdout=True, # Capture stdout and save as output?
|
146
146
|
stderr=True, # Capture stderr and save as output?
|
147
|
-
|
147
|
+
timeout:Optional[int]=None, # Shell command will time out after {timeout} seconds
|
148
|
+
verbose:bool=False): # Show stdout/stderr during execution
|
148
149
|
"Run `code`, returning a list of all outputs in Jupyter notebook format"
|
149
|
-
res = self.run_cell(code, stdout=stdout, stderr=stderr, timeout=timeout)
|
150
|
+
res = self.run_cell(code, stdout=stdout, stderr=stderr, timeout=timeout, verbose=verbose)
|
150
151
|
self.result = res.result.result
|
151
152
|
self.exc = res.exception
|
152
153
|
return _out_nb(res, self.display_formatter)
|
@@ -157,8 +158,9 @@ async def run_async(self:CaptureShell,
|
|
157
158
|
code: str, # Python/IPython code to run
|
158
159
|
stdout=True, # Capture stdout and save as output?
|
159
160
|
stderr=True, # Capture stderr and save as output?
|
160
|
-
timeout:Optional[int]=None
|
161
|
-
|
161
|
+
timeout:Optional[int]=None, # Shell command will time out after {timeout} seconds
|
162
|
+
verbose:bool=False): # Show stdout/stderr during execution
|
163
|
+
return self.run(code, stdout=stdout, stderr=stderr, timeout=timeout, verbose=verbose)
|
162
164
|
|
163
165
|
# %% ../nbs/02_shell.ipynb
|
164
166
|
def _pre(s, xtra=''): return f"<pre {xtra}><code>{escape(s)}</code></pre>"
|
@@ -197,11 +199,11 @@ def render_outputs(outputs, ansi_renderer=_strip, include_imgs=True, pygments=Fa
|
|
197
199
|
|
198
200
|
# %% ../nbs/02_shell.ipynb
|
199
201
|
@patch
|
200
|
-
def cell(self:CaptureShell, cell, stdout=True, stderr=True):
|
202
|
+
def cell(self:CaptureShell, cell, stdout=True, stderr=True, verbose=False):
|
201
203
|
"Run `cell`, skipping if not code, and store outputs back in cell"
|
202
204
|
if cell.cell_type!='code': return
|
203
205
|
self._cell_idx = cell.idx_ + 1
|
204
|
-
outs = self.run(cell.source)
|
206
|
+
outs = self.run(cell.source, verbose=verbose)
|
205
207
|
if outs: cell.outputs = _dict2obj(outs)
|
206
208
|
|
207
209
|
# %% ../nbs/02_shell.ipynb
|
@@ -239,13 +241,14 @@ def run_all(self:CaptureShell,
|
|
239
241
|
preproc:callable=_false, # Called before each cell is executed
|
240
242
|
postproc:callable=_false, # Called after each cell is executed
|
241
243
|
inject_code:str|None=None, # Code to inject into a cell
|
242
|
-
inject_idx:int=0 # Cell to replace with `inject_code`
|
244
|
+
inject_idx:int=0, # Cell to replace with `inject_code`
|
245
|
+
verbose:bool=False # Show stdout/stderr during execution
|
243
246
|
):
|
244
247
|
"Run all cells in `nb`, stopping at first exception if `exc_stop`"
|
245
248
|
if inject_code is not None: nb.cells[inject_idx].source = inject_code
|
246
249
|
for cell in nb.cells:
|
247
250
|
if not preproc(cell):
|
248
|
-
self.cell(cell)
|
251
|
+
self.cell(cell, verbose=verbose)
|
249
252
|
postproc(cell)
|
250
253
|
if self.exc and exc_stop: raise self.exc from None
|
251
254
|
|
@@ -259,7 +262,8 @@ def execute(self:CaptureShell,
|
|
259
262
|
postproc:callable=_false, # Called after each cell is executed
|
260
263
|
inject_code:str|None=None, # Code to inject into a cell
|
261
264
|
inject_path:str|Path|None=None, # Path to file containing code to inject into a cell
|
262
|
-
inject_idx:int=0 # Cell to replace with `inject_code`
|
265
|
+
inject_idx:int=0, # Cell to replace with `inject_code`
|
266
|
+
verbose:bool=False # Show stdout/stderr during execution
|
263
267
|
):
|
264
268
|
"Execute notebook from `src` and save with outputs to `dest"
|
265
269
|
nb = read_nb(src)
|
@@ -267,7 +271,7 @@ def execute(self:CaptureShell,
|
|
267
271
|
self.set_path(Path(src).parent.resolve())
|
268
272
|
if inject_path is not None: inject_code = Path(inject_path).read_text()
|
269
273
|
self.run_all(nb, exc_stop=exc_stop, preproc=preproc, postproc=postproc,
|
270
|
-
inject_code=inject_code, inject_idx=inject_idx)
|
274
|
+
inject_code=inject_code, inject_idx=inject_idx, verbose=verbose)
|
271
275
|
if dest: write_nb(nb, dest)
|
272
276
|
|
273
277
|
# %% ../nbs/02_shell.ipynb
|
@@ -290,11 +294,12 @@ def exec_nb(
|
|
290
294
|
exc_stop:bool=False, # Stop on exceptions?
|
291
295
|
inject_code:str=None, # Code to inject into a cell
|
292
296
|
inject_path:str=None, # Path to file containing code to inject into a cell
|
293
|
-
inject_idx:int=0 # Cell to replace with `inject_code`
|
297
|
+
inject_idx:int=0, # Cell to replace with `inject_code`
|
298
|
+
verbose:bool=False # Show stdout/stderr during execution
|
294
299
|
):
|
295
300
|
"Execute notebook from `src` and save with outputs to `dest`"
|
296
301
|
CaptureShell().execute(src, dest, exc_stop=exc_stop, inject_code=inject_code,
|
297
|
-
inject_path=inject_path, inject_idx=inject_idx)
|
302
|
+
inject_path=inject_path, inject_idx=inject_idx, verbose=verbose)
|
298
303
|
|
299
304
|
# %% ../nbs/02_shell.ipynb
|
300
305
|
class SmartCompleter(IPCompleter):
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: execnb
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.15
|
4
4
|
Summary: A description of your project
|
5
5
|
Home-page: https://github.com/AnswerDotAI/execnb/
|
6
6
|
Author: Jeremy Howard
|
@@ -102,6 +102,7 @@ You can also execute notebooks from the command line with
|
|
102
102
|
|
103
103
|
usage: exec_nb [-h] [--dest DEST] [--exc_stop] [--inject_code INJECT_CODE]
|
104
104
|
[--inject_path INJECT_PATH] [--inject_idx INJECT_IDX]
|
105
|
+
[--verbose]
|
105
106
|
src
|
106
107
|
|
107
108
|
Execute notebook from `src` and save with outputs to `dest`
|
@@ -116,3 +117,4 @@ You can also execute notebooks from the command line with
|
|
116
117
|
--inject_code INJECT_CODE Code to inject into a cell
|
117
118
|
--inject_path INJECT_PATH Path to file containing code to inject into a cell
|
118
119
|
--inject_idx INJECT_IDX Cell to replace with `inject_code` (default: 0)
|
120
|
+
--verbose Show stdout/stderr during execution (default: False)
|
execnb-0.1.14/execnb/__init__.py
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = "0.1.14"
|
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
|