Skip to content

Commit db8b14f

Browse files
committed
Update end-to-end walkthrough for JupyterCon 2023
1 parent 3f02663 commit db8b14f

File tree

5 files changed

+105
-75
lines changed

5 files changed

+105
-75
lines changed

nbs/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ html {
1010
font-family: Inter, SF Pro Display, -apple-system, sans-serif;
1111
}
1212

13+
h1, h2, h3 {
14+
font-weight: normal;
15+
}
16+
1317
body {
1418
background: var(--background);
1519
color: var(--foreground);
293 KB
Loading
-50.9 KB
Binary file not shown.
354 KB
Loading

nbs/tutorials/tutorial.ipynb

Lines changed: 101 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -64,30 +64,32 @@
6464
"4. nbdev\n",
6565
"5. Quarto\n",
6666
"\n",
67-
"If you haven't worked with Python before, we recommend getting started with the [Anaconda Individual Edition](https://www.anaconda.com/products/individual) and using the conda package manager."
67+
"If you haven't worked with Python before, we recommend getting started with the [Anaconda Individual Edition](https://www.anaconda.com/products/individual) and using the conda package manager.\n",
68+
"\n",
69+
"Note that you will only need to follow the steps in the installation section once per environment. If you create a new repo, you won't need to redo these."
6870
]
6971
},
7072
{
7173
"cell_type": "markdown",
7274
"metadata": {},
7375
"source": [
74-
"### Install Jupyter Notebook"
76+
"### Install Jupyter Lab"
7577
]
7678
},
7779
{
7880
"cell_type": "markdown",
7981
"metadata": {},
8082
"source": [
81-
"Launch a terminal and install Jupyter Notebook by entering:\n",
83+
"Launch a terminal and install Jupyter Lab by entering:\n",
8284
"\n",
8385
"```sh\n",
84-
"conda install notebook\n",
86+
"conda install -c conda-forge jupyterlab\n",
8587
"```\n",
8688
"\n",
8789
"...or\n",
8890
"\n",
8991
"```sh\n",
90-
"pip install notebook\n",
92+
"pip install jupyterlab\n",
9193
"```\n",
9294
"\n",
9395
"...if you're using the pip package manager.\n",
@@ -97,30 +99,17 @@
9799
"You can now launch Jupyter by entering:\n",
98100
"\n",
99101
"```sh\n",
100-
"jupyter notebook\n",
102+
"jupyter lab\n",
101103
"```\n",
102104
"\n",
103-
"This should open the Jupyter home page in a new browser tab:"
105+
"This should open Jupyter Lab in a new browser tab:"
104106
]
105107
},
106108
{
107109
"cell_type": "markdown",
108110
"metadata": {},
109111
"source": [
110-
"![](images/jupyter-home-page.png){.px-1 .py-2 fig-align=\"center\" .border .rounded .shadow-sm}"
111-
]
112-
},
113-
{
114-
"cell_type": "markdown",
115-
"metadata": {},
116-
"source": [
117-
"::: {.callout-tip collapse=\"true\"}\n",
118-
"\n",
119-
"#### Why not Jupyter Lab?\n",
120-
"\n",
121-
"As Jupyter power users we still prefer Jupyter Notebook (with [customizations](#install-collapsible-headings-and-toc2)) over more feature-full alternatives like Jupyter Lab, VSCode, or PyCharm. We find Jupyter Notebook simpler, faster, and more robust.\n",
122-
"\n",
123-
":::"
112+
"![](images/jupyter-welcome.png){fig-align=\"center\"}"
124113
]
125114
},
126115
{
@@ -134,18 +123,18 @@
134123
"cell_type": "markdown",
135124
"metadata": {},
136125
"source": [
137-
"The next step is to install nbdev itself. Jupyter Notebook comes with its own terminal, so we'll use that moving forward.\n",
126+
"The next step is to install nbdev itself. Jupyter Lab comes with its own terminal, so we'll use that moving forward.\n",
138127
"\n",
139-
"In the Jupyter home page (shown in the previous section), click the \"New\" dropdown on the right side, then \"Terminal\".\n",
128+
"In the Launcher, scroll down to the \"Other\" section, then click \"Terminal\". If the Launcher isn't opened, you can open it by clicking \"File\"\"New Launcher\".\n",
140129
"\n",
141-
"A browser tab should open with a blank terminal:"
130+
"A new tab should open with a blank terminal -- it might not look exactly the same, depending on how your shell is configured:"
142131
]
143132
},
144133
{
145134
"cell_type": "markdown",
146135
"metadata": {},
147136
"source": [
148-
"![](images/jupyter-blank-terminal.png){.pt-2 fig-align=\"center\" .border .rounded .shadow-sm}"
137+
"![](images/jupyter-blank-terminal.png){fig-align=\"center\"}"
149138
]
150139
},
151140
{
@@ -189,6 +178,36 @@
189178
"Your password may be requested at this point. Since nbdev is open source, you can read [the source code](https://github.com/fastai/nbdev/blob/master/nbdev/quarto.py) of this command to verify that it isn't doing anything malicious. Or, if you prefer, you may instead follow [Quarto's official installation instructions](https://quarto.org/docs/get-started/)."
190179
]
191180
},
181+
{
182+
"cell_type": "markdown",
183+
"metadata": {},
184+
"source": [
185+
"### Install Quarto Jupyter Lab extension"
186+
]
187+
},
188+
{
189+
"cell_type": "markdown",
190+
"metadata": {},
191+
"source": [
192+
"Quarto provides its own [Jupyter Lab extension](https://quarto.org/docs/tools/jupyter-lab-extension.html) that allows it to render Quarto markdown content.\n",
193+
"\n",
194+
"For example, here is their notebook demonstrating some of its features:\n",
195+
"\n",
196+
"![](https://user-images.githubusercontent.com/261654/230087634-d5027ebc-8508-43b4-81c9-c4b7d6cfa738.png)\n",
197+
"\n",
198+
"Install the extension by entering:\n",
199+
"\n",
200+
"```sh\n",
201+
"pip install jupyterlab-quarto\n",
202+
"```\n",
203+
"\n",
204+
"Note that the `jupyterlab-quarto` package is not currently available via conda.\n",
205+
"\n",
206+
"---\n",
207+
"\n",
208+
"You're all setup and ready to go! Installing these tools may take some time, but you'll only need to do it once. Next, we'll setup an nbdev repo for your specific project."
209+
]
210+
},
192211
{
193212
"cell_type": "markdown",
194213
"metadata": {},
@@ -216,9 +235,9 @@
216235
"source": [
217236
"Create an empty GitHub repo using the convenient link [github.com/new](https://github.com/new). If you get stuck, you might find GitHub's [_Create a repo_](https://docs.github.com/en/get-started/quickstart/create-a-repo) page helpful.\n",
218237
"\n",
219-
"Remember to add a description, since nbdev will use that later. Don't add a README file, .gitignore, or license file just yet.\n",
238+
"Remember to add a description, since nbdev will use that later. Don't add a README file, .gitignore, or license just yet.\n",
220239
"\n",
221-
"If you're using the web interface, it should look something like this before you click \"Create Repository\":"
240+
"If you're using the web interface, it should look something like this (with your own repository name and descrpition) before you click \"Create Repository\":"
222241
]
223242
},
224243
{
@@ -349,11 +368,38 @@
349368
"git add .\n",
350369
"git commit -m'Initial commit'\n",
351370
"git push\n",
352-
"```\n",
353-
"\n",
371+
"```"
372+
]
373+
},
374+
{
375+
"cell_type": "markdown",
376+
"metadata": {},
377+
"source": [
378+
"### Enable GitHub Pages"
379+
]
380+
},
381+
{
382+
"cell_type": "markdown",
383+
"metadata": {},
384+
"source": [
385+
"nbdev hosts your docs on GitHub Pages---an excellent (and free!) way to host websites. "
386+
]
387+
},
388+
{
389+
"cell_type": "markdown",
390+
"metadata": {},
391+
"source": [
392+
"::: {.callout-note}\n",
354393
"\n",
355-
"### Enable GitHub Pages\n",
394+
"nbdev uses GitHub Pages by default because its easily accessible. However, you can use any host you like. See [these docs](../explanations/docs.ipynb#deploying-your-docs-on-other-platforms) for more information.\n",
356395
"\n",
396+
":::"
397+
]
398+
},
399+
{
400+
"cell_type": "markdown",
401+
"metadata": {},
402+
"source": [
357403
"You need to enable GitHub Pages for your repo by clicking on the \"Settings\" tab near the top-right of your repo page, then \"Pages\" on the left, then setting the \"Branch\" to \"gh-pages\", and finally clicking \"Save\".\n",
358404
"\n",
359405
"It should look similar to this after you click \"Save\":\n",
@@ -400,7 +446,7 @@
400446
"cell_type": "markdown",
401447
"metadata": {},
402448
"source": [
403-
"If you see a red cross (❌), that means something failed. Click on the cross, then click *Details*, and you'll be able to see what failed. If you can't figure out what's wrong, search [the forum](https://forums.fast.ai/c/nbdev/48) in case someone else resolved the same issue, otherwise create a new post describing your issue in as much detail as you can, and we'll try our best to help you. Remember that including a link to an actual repo and/or GitHub Action is the best way for us to quickly identify what's wrong."
449+
"If you see a red cross (❌), that means something failed. Click on the cross, then click \"Details\", and you'll be able to see what failed. If you can't figure out what's wrong, search [the forum](https://forums.fast.ai/c/nbdev/48) in case someone else resolved the same issue, otherwise create a new post describing your issue in as much detail as you can, and we'll try our best to help you. Remember that including a link to an actual repo and/or GitHub Action is the best way for us to quickly identify what's wrong."
404450
]
405451
},
406452
{
@@ -423,13 +469,6 @@
423469
"We provide these basic workflows out-of-the-box, however, you can edit their corresponding YAML files in the `.github/workflows/` folder to your liking."
424470
]
425471
},
426-
{
427-
"cell_type": "markdown",
428-
"metadata": {},
429-
"source": [
430-
"Note that you'll need to enable GitHub Pages for your repo before you can access your docs website. We'll do that now."
431-
]
432-
},
433472
{
434473
"cell_type": "markdown",
435474
"metadata": {},
@@ -441,14 +480,7 @@
441480
"cell_type": "markdown",
442481
"metadata": {},
443482
"source": [
444-
"nbdev hosts your docs on GitHub Pages---an excellent (and free!) way to host websites. "
445-
]
446-
},
447-
{
448-
"cell_type": "markdown",
449-
"metadata": {},
450-
"source": [
451-
"Head back to GitHub Actions and you should see a new workflow run: \"pages build and deployment\". As the name says, this workflow deploys your website contents to GitHub Pages."
483+
"When you [enable GitHub Pages](#enable-github-pages) you should see a new workflow run: \"pages build and deployment\". As the name suggests, this workflow deploys your website contents to GitHub Pages."
452484
]
453485
},
454486
{
@@ -472,17 +504,6 @@
472504
"![](images/nbdev-hello-world-site-initial.png){fig-align=\"center\" .border .rounded .shadow-sm}"
473505
]
474506
},
475-
{
476-
"cell_type": "markdown",
477-
"metadata": {},
478-
"source": [
479-
"::: {.callout-note}\n",
480-
"\n",
481-
"nbdev uses GitHub Pages by default because its easily accessible. However, you can use any host you like. See [these docs](../explanations/docs.ipynb#deploying-your-docs-on-other-platforms) for more information on this.\n",
482-
"\n",
483-
":::"
484-
]
485-
},
486507
{
487508
"cell_type": "markdown",
488509
"metadata": {},
@@ -496,7 +517,7 @@
496517
"source": [
497518
"You now have a base nbdev repo with continuous integration and hosted documentation! Here's a recap of the steps you took:\n",
498519
"\n",
499-
"- Created a GitHub repo\n",
520+
"- Created a GitHub repo (with GitHub Pages enabled)\n",
500521
"- Initialised your repo with `nbdev_new`\n",
501522
"- Pushed to GitHub."
502523
]
@@ -541,7 +562,7 @@
541562
"source": [
542563
"::: {.callout-note}\n",
543564
"\n",
544-
"The [clean hook](#nbdev_clean-on-saving-notebooks-in-jupyter) currently only supports Jupyter Notebook and Jupyter Lab. If you're using another notebook editor, like VSCode or PyCharm, you might want to use [nbdev's pre-commit hooks](/tutorials/pre_commit.ipynb) as well.\n",
565+
"The [clean hook](#nbdev_clean-on-saving-notebooks-in-jupyter) currently only supports Jupyter Notebook and Jupyter Lab. If you're using VSCode, you can try the [experimental nbdev VSCode extension](https://github.com/fastai/nbdev-vscode). Otherwise, you might also want to try [nbdev's pre-commit hooks](/tutorials/pre_commit.ipynb).\n",
545566
"\n",
546567
":::"
547568
]
@@ -563,7 +584,7 @@
563584
"source": [
564585
"::: {.callout-tip}\n",
565586
"\n",
566-
"nbdev hooks works on _any_ git repo, even if it doesn't use the broader nbdev system.\n",
587+
"nbdev's git hooks work on _any_ git repo, even if it doesn't use the broader nbdev system.\n",
567588
"\n",
568589
":::"
569590
]
@@ -614,7 +635,7 @@
614635
"\n",
615636
"This is the recommended way to make a Python package importable from anywhere in your current environment:\n",
616637
"\n",
617-
"- `-e` -- short for \"editable\", lets you immediately use changes made to your package during development.\n",
638+
"- `-e` -- short for \"editable\", lets you immediately use changes made to your package without having to reinstall, which is convenient for development.\n",
618639
"- `.` -- refers to the current directory.\n",
619640
"- `[dev]` -- includes \"development\" requirements: other packages that your notebooks use solely for documentation or testing."
620641
]
@@ -690,7 +711,7 @@
690711
"cell_type": "markdown",
691712
"metadata": {},
692713
"source": [
693-
"Now, run `jupyter notebook`, and click `00_core.ipynb` (note: if you started this tutorial using `nbdev_new` then this file will be in the `nbs` folder). You don't *have* to start your notebook names with a number, but we find it helpful to show the order that your project should be read in -- even though it could have been created in a different order."
714+
"Now, open the `nbs/00_core.ipynb` file (generated by running `nbdev_new` earlier) in Jupyter. You don't *have* to start your notebook names with a number, but we find it helpful to show the order that your project should be read in -- even though it could have been created in a different order."
694715
]
695716
},
696717
{
@@ -836,8 +857,6 @@
836857
"\n",
837858
"---\n",
838859
"\n",
839-
"[source](https://github.com/fastai/nbdevblob/master/nbdev/tutorial.py#L7){target=\"_blank\" style=\"float:right; font-size:smaller\"}\n",
840-
"\n",
841860
"### say_hello\n",
842861
"\n",
843862
"> say_hello (to)\n",
@@ -922,7 +941,7 @@
922941
"metadata": {},
923942
"outputs": [],
924943
"source": [
925-
"assert say_hello(\"Hamel\")==\"Hello Hamel!\""
944+
"assert say_hello(\"Hamel\") == \"Hello Hamel!\""
926945
]
927946
},
928947
{
@@ -974,7 +993,7 @@
974993
{
975994
"data": {
976995
"image/svg+xml": [
977-
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"100\"><circle cx=\"50\" cy=\"50\" r=\"40\"/></svg>\n"
996+
"<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"100\"><circle cx=\"50\" cy=\"50\" r=\"40\"/></svg>"
978997
],
979998
"text/plain": [
980999
"<IPython.core.display.SVG object>"
@@ -1001,10 +1020,10 @@
10011020
"source": [
10021021
"Before commiting your changes to GitHub we recommend running `nbdev_prepare` in the terminal, which bundles the following commands:\n",
10031022
"\n",
1004-
"- `nbdev_export`: Builds the .py modules from Jupyter notebooks\n",
1023+
"- `nbdev_export`: Builds the `.py` modules from Jupyter notebooks\n",
10051024
"- `nbdev_test`: Tests your notebooks\n",
1006-
"- `nbdev_clean`: Cleans your notebooks to get rid of extreanous output for Github\n",
1007-
"- `nbdev_readme`: Updates README.md from your index notebook."
1025+
"- `nbdev_clean`: Cleans your notebooks to get rid of extreanous output for git\n",
1026+
"- `nbdev_readme`: Updates your repo's `README.md` file from your index notebook."
10081027
]
10091028
},
10101029
{
@@ -1018,14 +1037,14 @@
10181037
"cell_type": "markdown",
10191038
"metadata": {},
10201039
"source": [
1021-
"Now you're ready to create your documentation home page and README.md file; these are both generated automatically from index.ipynb. Open the Jupyter Notebook home page, then click on index.ipynb to open it."
1040+
"Now you're ready to personalize your documentation home page and `README.md` file; these are both generated automatically from index.ipynb. Open Jupyter, then click on `nbs/index.ipynb` to open it."
10221041
]
10231042
},
10241043
{
10251044
"cell_type": "markdown",
10261045
"metadata": {},
10271046
"source": [
1028-
"We recommend including a longer description about what your package does, how to install it, and how to use it (with a few examples which import and use your package). Remember, examples can be code cells with real outputs rather than plain markdown text."
1047+
"We recommend including a longer description about what your package does, how to install it, and how to use it (with a few examples which import and use your package). Remember, examples can be code cells with real outputs rather than plain markdown text -- they'll double as tests too!"
10291048
]
10301049
},
10311050
{
@@ -1043,7 +1062,7 @@
10431062
"\n",
10441063
"```sh\n",
10451064
"git add .\n",
1046-
"git commit -m'Add `say_hello`; update index' # Update this text with your own message\n",
1065+
"git commit -m 'Add `say_hello`; update index' # Update this text with your own message\n",
10471066
"git push\n",
10481067
"```\n",
10491068
"\n",
@@ -1066,12 +1085,12 @@
10661085
"- Installed hooks for git-friendly notebooks with `nbdev_install_hooks`\n",
10671086
"- Installed your package with `pip install -e '.[dev]'`\n",
10681087
"- Previewed your docs with `nbdev_preview`\n",
1069-
"- Added your own frontmatter, function, tests, and docs to 00_core.ipynb\n",
1088+
"- Added your own frontmatter, function, tests, and docs to `nbs/00_core.ipynb`\n",
10701089
"- Prepared your changes with `nbdev_prepare`\n",
1071-
"- Updated index.ipynb with your own information\n",
1090+
"- Updated `nbs/index.ipynb` with your own information\n",
10721091
"- Pushed to GitHub.\n",
10731092
"\n",
1074-
"Read on to learn about more advanced nbdev functionality. Also see our _Explanations_ in the sidebar on the left for deep-dives on specific topics."
1093+
"Read on to learn about more advanced nbdev functionality. Also see our [explanations](/explanations) for deep-dives on specific topics, as well as our other [tutorials](/tutorials)."
10751094
]
10761095
},
10771096
{
@@ -1531,6 +1550,13 @@
15311550
"display_name": "python3",
15321551
"language": "python",
15331552
"name": "python3"
1553+
},
1554+
"widgets": {
1555+
"application/vnd.jupyter.widget-state+json": {
1556+
"state": {},
1557+
"version_major": 2,
1558+
"version_minor": 0
1559+
}
15341560
}
15351561
},
15361562
"nbformat": 4,

0 commit comments

Comments
 (0)