Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Dec 2, 2024
1 parent ee2433b commit 565c59d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mamba installed.)
## How to use

Use
[`CaptureShell`](https://fastai.github.io/execnb/shell.html#captureshell)
[`CaptureShell`](https://AnswerDotAI.github.io/execnb/shell.html#captureshell)
to run Jupyter code and capture notebook outputs, without running a
Jupyter server (or even having it installed):

Expand All @@ -44,7 +44,7 @@ s.run('1+1')
'execution_count': 1}]

To execute a notebook and save it with outputs filled in, use
[`CaptureShell.execute`](https://fastai.github.io/execnb/shell.html#captureshell.execute):
[`CaptureShell.execute`](https://AnswerDotAI.github.io/execnb/shell.html#captureshell.execute):

``` python
try:
Expand All @@ -56,7 +56,7 @@ finally: Path('tmp.ipynb').unlink()
[{'name': 'stdout', 'output_type': 'stream', 'text': ['1\n']}, {'data': {'text/plain': ['2']}, 'execution_count': 3, 'metadata': {}, 'output_type': 'execute_result'}]

You can also execute notebooks from the command line with
[`exec_nb`](https://fastai.github.io/execnb/shell.html#exec_nb):
[`exec_nb`](https://AnswerDotAI.github.io/execnb/shell.html#exec_nb):

``` python
!exec_nb --help
Expand Down
58 changes: 34 additions & 24 deletions nbs/02_shell.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@
"text/plain": [
"[{'name': 'stdout',\n",
" 'output_type': 'stream',\n",
" 'text': ['CPU times: user 1 us, sys: 0 ns, total: 1 us\\n',\n",
" 'Wall time: 4.05 us\\n'],\n",
" 'text': ['CPU times: user 2 us, sys: 1 us, total: 3 us\\n',\n",
" 'Wall time: 4.29 us\\n'],\n",
" 'execution_count': None},\n",
" {'data': {'text/plain': ['2']},\n",
" 'metadata': {},\n",
Expand Down Expand Up @@ -1025,7 +1025,7 @@
"File <ipython-input-1-a5c3817716b6>:1\n",
"----> 1 import time; time.sleep(1.1)\n",
"\n",
"Cell In[6], line 7, in run_cell.<locals>.handler(*args)\n",
"Cell In[143], line 7, in run_cell.<locals>.handler(*args)\n",
"----> 7 def handler(*args): raise TimeoutError()\n",
"\n",
"TimeoutError: \n",
Expand Down Expand Up @@ -1064,7 +1064,7 @@
"File <span class=\"ansi-green-fg\">&lt;ipython-input-1-a5c3817716b6&gt;:1</span>\n",
"<span class=\"ansi-green-fg\">----&gt; 1</span> <span class=\"ansi-bold\" style=\"color: rgb(0,135,0)\">import</span> <span class=\"ansi-bold\" style=\"color: rgb(0,0,255)\">time</span>; time<span style=\"color: rgb(98,98,98)\">.</span>sleep(<span style=\"color: rgb(98,98,98)\">1.1</span>)\n",
"\n",
"Cell <span class=\"ansi-green-fg\">In[6], line 7</span>, in <span class=\"ansi-cyan-fg\">run_cell.&lt;locals&gt;.handler</span><span class=\"ansi-blue-fg\">(*args)</span>\n",
"Cell <span class=\"ansi-green-fg\">In[143], line 7</span>, in <span class=\"ansi-cyan-fg\">run_cell.&lt;locals&gt;.handler</span><span class=\"ansi-blue-fg\">(*args)</span>\n",
"<span class=\"ansi-green-fg\">----&gt; 7</span> <span class=\"ansi-bold\" style=\"color: rgb(0,135,0)\">def</span> <span style=\"color: rgb(0,0,255)\">handler</span>(<span style=\"color: rgb(98,98,98)\">*</span>args): <span class=\"ansi-bold\" style=\"color: rgb(0,135,0)\">raise</span> <span class=\"ansi-bold\" style=\"color: rgb(215,95,95)\">TimeoutError</span>()\n",
"\n",
"<span class=\"ansi-red-fg\">TimeoutError</span>: \n",
Expand Down Expand Up @@ -1465,7 +1465,8 @@
"[{'data': {'text/plain': ['<IPython.core.display.Markdown object>'],\n",
" 'text/markdown': [\"This is *bold*. Here's a [link](https://www.fast.ai).\"]},\n",
" 'metadata': {},\n",
" 'output_type': 'execute_result'}]"
" 'output_type': 'execute_result',\n",
" 'execution_count': None}]"
]
},
"execution_count": null,
Expand Down Expand Up @@ -1520,11 +1521,13 @@
" 'File \\x1b[0;32m<ipython-input-1-1c97c1d317ab>:1\\x1b[0m\\n',\n",
" '\\x1b[0;32m----> 1\\x1b[0m \\x1b[38;5;28;01mraise\\x1b[39;00m \\x1b[38;5;167;01mException\\x1b[39;00m(\\x1b[38;5;124m\"\\x1b[39m\\x1b[38;5;124mOopsie!\\x1b[39m\\x1b[38;5;124m\"\\x1b[39m)\\n',\n",
" '\\n',\n",
" '\\x1b[0;31mException\\x1b[0m: Oopsie!\\n']},\n",
" '\\x1b[0;31mException\\x1b[0m: Oopsie!\\n'],\n",
" 'execution_count': None},\n",
" {'ename': 'Exception',\n",
" 'evalue': 'Oopsie!',\n",
" 'output_type': 'error',\n",
" 'traceback': 'Traceback (most recent call last):\\n File \"/Users/jhoward/miniconda3/lib/python3.11/site-packages/IPython/core/interactiveshell.py\", line 3577, in run_code\\n exec(code_obj, self.user_global_ns, self.user_ns)\\n File \"<ipython-input-1-1c97c1d317ab>\", line 1, in <module>\\n raise Exception(\"Oopsie!\")\\nException: Oopsie!\\n'}]"
" 'traceback': 'Traceback (most recent call last):\\n File \"/Users/jhoward/miniconda3/lib/python3.11/site-packages/IPython/core/interactiveshell.py\", line 3577, in run_code\\n exec(code_obj, self.user_global_ns, self.user_ns)\\n File \"<ipython-input-1-1c97c1d317ab>\", line 1, in <module>\\n raise Exception(\"Oopsie!\")\\nException: Oopsie!\\n',\n",
" 'execution_count': None}]"
]
},
"execution_count": null,
Expand Down Expand Up @@ -1613,10 +1616,14 @@
{
"data": {
"text/plain": [
"[{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n']},\n",
"[{'name': 'stdout',\n",
" 'output_type': 'stream',\n",
" 'text': ['1\\n'],\n",
" 'execution_count': None},\n",
" {'data': {'text/plain': ['2']},\n",
" 'metadata': {},\n",
" 'output_type': 'execute_result'}]"
" 'output_type': 'execute_result',\n",
" 'execution_count': None}]"
]
},
"execution_count": null,
Expand Down Expand Up @@ -1679,7 +1686,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"[{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n']}, {'data': {'text/plain': ['2']}, 'metadata': {}, 'output_type': 'execute_result'}]\n"
"[{'execution_count': None, 'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n']}, {'data': {'text/plain': ['2']}, 'execution_count': None, 'metadata': {}, 'output_type': 'execute_result'}]\n"
]
}
],
Expand Down Expand Up @@ -1741,11 +1748,11 @@
"\n",
"While Executing Cell #2:\n",
"Traceback (most recent call last):\n",
" File \"/var/folders/ss/34z569j921v58v8n1n_8z7h40000gn/T/ipykernel_18616/1421292703.py\", line 3, in <module>\n",
" File \"/var/folders/ss/34z569j921v58v8n1n_8z7h40000gn/T/ipykernel_6273/1421292703.py\", line 3, in <module>\n",
" s.execute('../tests/error.ipynb', exc_stop=True)\n",
" File \"/var/folders/ss/34z569j921v58v8n1n_8z7h40000gn/T/ipykernel_18616/3609882568.py\", line 18, in execute\n",
" File \"/var/folders/ss/34z569j921v58v8n1n_8z7h40000gn/T/ipykernel_6273/3609882568.py\", line 18, in execute\n",
" self.run_all(nb, exc_stop=exc_stop, preproc=preproc, postproc=postproc,\n",
" File \"/var/folders/ss/34z569j921v58v8n1n_8z7h40000gn/T/ipykernel_18616/3068237356.py\", line 19, in run_all\n",
" File \"/var/folders/ss/34z569j921v58v8n1n_8z7h40000gn/T/ipykernel_6273/3068237356.py\", line 19, in run_all\n",
" if self.exc and exc_stop: raise self.exc from None\n",
" ^^^^^^^^^^^^^^^^^^^^^^^^\n",
" File \"/Users/jhoward/miniconda3/lib/python3.11/site-packages/IPython/core/interactiveshell.py\", line 3577, in run_code\n",
Expand Down Expand Up @@ -1843,9 +1850,9 @@
"#|hide\n",
"# `display_data` flushes stdout and stderr - in that order\n",
"res = CaptureShell().run(\"import sys; sys.stderr.write('Error!'); print(1); display(1)\")\n",
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n']},\n",
" {'name': 'stderr', 'output_type': 'stream', 'text': ['Error!']},\n",
" {'data': {'text/plain': ['1']}, 'metadata': {}, 'output_type': 'display_data'}])"
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n'], 'execution_count': None},\n",
" {'name': 'stderr', 'output_type': 'stream', 'text': ['Error!'], 'execution_count': None},\n",
" {'data': {'text/plain': ['1']}, 'metadata': {}, 'output_type': 'display_data', 'execution_count': None}])"
]
},
{
Expand All @@ -1857,7 +1864,7 @@
"#|hide\n",
"# Consecutive writes to stdout are grouped\n",
"res = CaptureShell().run('print(1); print(2); print(3)')\n",
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n', '2\\n', '3\\n']}])"
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n', '2\\n', '3\\n'], 'execution_count': None}])"
]
},
{
Expand All @@ -1869,8 +1876,8 @@
"#|hide\n",
"# Consecutive writes to stdout are grouped despite an intermediate write to stderr, which is captured after\n",
"res = CaptureShell().run(\"import sys; print(1); print(2); sys.stderr.write('Error!'); print(3)\")\n",
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n', '2\\n', '3\\n']},\n",
" {'name': 'stderr', 'output_type': 'stream', 'text': ['Error!']}])"
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n', '2\\n', '3\\n'], 'execution_count': None},\n",
" {'name': 'stderr', 'output_type': 'stream', 'text': ['Error!'], 'execution_count': None}])"
]
},
{
Expand All @@ -1882,10 +1889,10 @@
"#|hide\n",
"# `execute_result` is always last\n",
"res = CaptureShell().run(\"import sys; sys.stderr.write('Error!'); print(1); display(1); 1\")\n",
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n']},\n",
" {'name': 'stderr', 'output_type': 'stream', 'text': ['Error!']},\n",
" {'data': {'text/plain': ['1']}, 'metadata': {}, 'output_type': 'display_data'},\n",
" {'data': {'text/plain': ['1']}, 'metadata': {}, 'output_type': 'execute_result'}])"
"test_eq(res, [{'name': 'stdout', 'output_type': 'stream', 'text': ['1\\n'], 'execution_count': None},\n",
" {'name': 'stderr', 'output_type': 'stream', 'text': ['Error!'], 'execution_count': None},\n",
" {'data': {'text/plain': ['1']}, 'metadata': {}, 'output_type': 'display_data', 'execution_count': None},\n",
" {'data': {'text/plain': ['1']}, 'metadata': {}, 'output_type': 'execute_result', 'execution_count': None}])"
]
},
{
Expand Down Expand Up @@ -1947,7 +1954,10 @@
" 'execution_count': None,\n",
" 'id': 'ea528db5',\n",
" 'metadata': {},\n",
" 'outputs': [{'name': 'stdout', 'output_type': 'stream', 'text': ['2\\n']}],\n",
" 'outputs': [{'name': 'stdout',\n",
" 'output_type': 'stream',\n",
" 'text': ['2\\n'],\n",
" 'execution_count': None}],\n",
" 'source': 'print(a)',\n",
" 'idx_': 1}]"
]
Expand Down
4 changes: 2 additions & 2 deletions nbs/nbdev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project:

website:
title: "execnb"
site-url: "https://fastai.github.io/execnb/"
site-url: "https://AnswerDotAI.github.io/execnb/"
description: "A description of your project"
repo-branch: master
repo-url: "https://github.com/fastai/execnb/"
repo-url: "https://github.com/AnswerDotAI/execnb/"

0 comments on commit 565c59d

Please sign in to comment.