|
97 | 97 | " self.exc,self.result,self.out,self.count = None,None,[],1\n", |
98 | 98 | " self.run_cell('%matplotlib inline')\n", |
99 | 99 | "\n", |
100 | | - " def enable_gui(self, gui=None): pass\n", |
| 100 | + " def set_path(self, path):\n", |
| 101 | + " \"Add `path` to python path\"\n", |
| 102 | + " self.run_cell(f\"import sys; sys.path.insert(0, {str(path)})\")\n", |
| 103 | + "\n", |
| 104 | + " def enable_gui(self, gui=None):\n", |
| 105 | + " \"Disable GUI (over-ridden; called by IPython)\"\n", |
| 106 | + " pass\n", |
101 | 107 | "\n", |
102 | 108 | " def _showtraceback(self, etype, evalue, stb: str):\n", |
103 | 109 | " self.out.append(_out_exc(etype, evalue, stb))\n", |
|
200 | 206 | " 'execution_count': 1},\n", |
201 | 207 | " {'name': 'stdout',\n", |
202 | 208 | " 'output_type': 'stream',\n", |
203 | | - " 'text': ['CPU times: user 2 us, sys: 0 ns, total: 2 us',\n", |
204 | | - " 'Wall time: 3.81 us']}]" |
| 209 | + " 'text': ['CPU times: user 3 us, sys: 1 us, total: 4 us',\n", |
| 210 | + " 'Wall time: 5.25 us']}]" |
205 | 211 | ] |
206 | 212 | }, |
207 | 213 | "execution_count": null, |
|
531 | 537 | "except Exception as e: print(f\"got exception: {e}\")" |
532 | 538 | ] |
533 | 539 | }, |
| 540 | + { |
| 541 | + "cell_type": "code", |
| 542 | + "execution_count": null, |
| 543 | + "metadata": {}, |
| 544 | + "outputs": [], |
| 545 | + "source": [ |
| 546 | + "nb = read_nb('../../testw/index.ipynb')" |
| 547 | + ] |
| 548 | + }, |
534 | 549 | { |
535 | 550 | "cell_type": "markdown", |
536 | 551 | "metadata": {}, |
|
626 | 641 | "):\n", |
627 | 642 | " \"Execute notebook from `src` and save with outputs to `dest\"\n", |
628 | 643 | " nb = read_nb(src)\n", |
| 644 | + " self.set_path(Path(src).parent.resolve())\n", |
629 | 645 | " if inject_path is not None: inject_code = Path(inject_path).read_text()\n", |
630 | 646 | " self.run_all(nb, exc_stop=exc_stop, preproc=preproc, postproc=postproc,\n", |
631 | 647 | " inject_code=inject_code, inject_idx=inject_idx)\n", |
632 | 648 | " if dest: write_nb(nb, dest)" |
633 | 649 | ] |
634 | 650 | }, |
| 651 | + { |
| 652 | + "cell_type": "code", |
| 653 | + "execution_count": null, |
| 654 | + "metadata": {}, |
| 655 | + "outputs": [], |
| 656 | + "source": [ |
| 657 | + "s.execute(clean, '../../testw/index.ipynb')" |
| 658 | + ] |
| 659 | + }, |
635 | 660 | { |
636 | 661 | "cell_type": "markdown", |
637 | 662 | "metadata": {}, |
|
0 commit comments