Skip to content

Commit 4537ae5

Browse files
committed
warn if no default_exp
1 parent c8340a4 commit 4537ae5

19 files changed

+113
-422
lines changed

nbdev/doclinks.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ def nbdev_export(
150150
if os.environ.get('IN_TEST',0): return
151151
files = nbglob(path=path, recursive=recursive, file_re=file_re,
152152
folder_re=folder_re, skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, symlinks=symlinks)
153-
for f in files:
154-
nb_export(f)
153+
for f in files: nb_export(f)
155154
add_init(get_config().path('lib_path'))
156155
build_modidx()
157156

nbdev/export.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ def create_modules(path, dest, procs=None, debug=False, mod_maker=ModuleMaker):
4747
nb.process()
4848
for mod,cells in exp.modules.items():
4949
all_cells = exp.in_all[mod]
50-
name = exp.default_exp if mod=='#' else mod
50+
name = getattr(exp, 'default_exp', None) if mod=='#' else mod
51+
if not name:
52+
warn("Could not find `#|default_exp` cell. Note nbdev2 no longer supports nbdev1 syntax. Run `nbdev_migrate` to upgrade.\n"
53+
"See https://nbdev.fast.ai/getting_started.html for more information.")
54+
return
5155
mm = mod_maker(dest=dest, name=name, nb_path=path, is_new=mod=='#')
5256
mm.make(cells, all_cells)
5357

nbdev/process.py

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,13 @@
2020
from collections import defaultdict
2121

2222
# %% ../nbs/03_process.ipynb 6
23-
#from https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/jupyter/notebook.py
24-
langs = defaultdict(lambda: '#',
25-
r = "#",
26-
python = "#",
27-
julia = "#",
28-
scala = "//",
29-
matlab = "%",
30-
csharp = "//",
31-
fsharp = "//",
32-
c = ["/*", "*/"],
33-
css = ["/*", "*/"],
34-
sas = ["*", ";"],
35-
powershell = "#",
36-
bash = "#",
37-
sql = "--",
38-
mysql = "--",
39-
psql = "--",
40-
lua = "--",
41-
cpp = "//",
42-
cc = "//",
43-
stan = "#",
44-
octave = "#",
45-
fortran = "!",
46-
fortran95 = "!",
47-
awk = "#",
48-
gawk = "#",
49-
stata = "*",
50-
java = "//",
51-
groovy = "//",
52-
sed = "#",
53-
perl = "#",
54-
ruby = "#",
55-
tikz = "%",
56-
javascript = "//",
57-
js = "//",
58-
d3 = "//",
59-
node = "//",
60-
sass = "//",
61-
coffee = "#",
62-
go = "//",
63-
asy = "//",
64-
haskell = "--",
65-
dot = "//",
66-
apl = "⍝"
67-
)
23+
# from https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/jupyter/notebook.py
24+
langs = defaultdict(
25+
lambda: '#', r = "#", python = "#", julia = "#", scala = "//", matlab = "%", csharp = "//", fsharp = "//",
26+
c = ["/*","*/"], css = ["/*","*/"], sas = ["*",";"], powershell = "#", bash = "#", sql = "--", mysql = "--", psql = "--",
27+
lua = "--", cpp = "//", cc = "//", stan = "#", octave = "#", fortran = "!", fortran95 = "!", awk = "#", gawk = "#", stata = "*",
28+
java = "//", groovy = "//", sed = "#", perl = "#", ruby = "#", tikz = "%", javascript = "//", js = "//", d3 = "//", node = "//",
29+
sass = "//", coffee = "#", go = "//", asy = "//", haskell = "--", dot = "//", apl = "⍝")
6830

6931
# %% ../nbs/03_process.ipynb 7
7032
def nb_lang(nb): return nested_attr(nb, 'metadata.kernelspec.language', 'python')

nbs/03_process.ipynb

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -84,52 +84,13 @@
8484
"outputs": [],
8585
"source": [
8686
"#|export\n",
87-
"\n",
88-
"#from https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/jupyter/notebook.py\n",
89-
"langs = defaultdict(lambda: '#', \n",
90-
" r = \"#\",\n",
91-
" python = \"#\",\n",
92-
" julia = \"#\",\n",
93-
" scala = \"//\",\n",
94-
" matlab = \"%\",\n",
95-
" csharp = \"//\",\n",
96-
" fsharp = \"//\",\n",
97-
" c = [\"/*\", \"*/\"],\n",
98-
" css = [\"/*\", \"*/\"],\n",
99-
" sas = [\"*\", \";\"],\n",
100-
" powershell = \"#\",\n",
101-
" bash = \"#\",\n",
102-
" sql = \"--\",\n",
103-
" mysql = \"--\",\n",
104-
" psql = \"--\",\n",
105-
" lua = \"--\",\n",
106-
" cpp = \"//\",\n",
107-
" cc = \"//\",\n",
108-
" stan = \"#\",\n",
109-
" octave = \"#\",\n",
110-
" fortran = \"!\",\n",
111-
" fortran95 = \"!\",\n",
112-
" awk = \"#\",\n",
113-
" gawk = \"#\",\n",
114-
" stata = \"*\",\n",
115-
" java = \"//\",\n",
116-
" groovy = \"//\",\n",
117-
" sed = \"#\",\n",
118-
" perl = \"#\",\n",
119-
" ruby = \"#\",\n",
120-
" tikz = \"%\",\n",
121-
" javascript = \"//\",\n",
122-
" js = \"//\",\n",
123-
" d3 = \"//\",\n",
124-
" node = \"//\",\n",
125-
" sass = \"//\",\n",
126-
" coffee = \"#\",\n",
127-
" go = \"//\",\n",
128-
" asy = \"//\",\n",
129-
" haskell = \"--\",\n",
130-
" dot = \"//\",\n",
131-
" apl = \"\"\n",
132-
")"
87+
"# from https://github.com/quarto-dev/quarto-cli/blob/main/src/resources/jupyter/notebook.py\n",
88+
"langs = defaultdict(\n",
89+
" lambda: '#', r = \"#\", python = \"#\", julia = \"#\", scala = \"//\", matlab = \"%\", csharp = \"//\", fsharp = \"//\",\n",
90+
" c = [\"/*\",\"*/\"], css = [\"/*\",\"*/\"], sas = [\"*\",\";\"], powershell = \"#\", bash = \"#\", sql = \"--\", mysql = \"--\", psql = \"--\",\n",
91+
" lua = \"--\", cpp = \"//\", cc = \"//\", stan = \"#\", octave = \"#\", fortran = \"!\", fortran95 = \"!\", awk = \"#\", gawk = \"#\", stata = \"*\",\n",
92+
" java = \"//\", groovy = \"//\", sed = \"#\", perl = \"#\", ruby = \"#\", tikz = \"%\", javascript = \"//\", js = \"//\", d3 = \"//\", node = \"//\",\n",
93+
" sass = \"//\", coffee = \"#\", go = \"//\", asy = \"//\", haskell = \"--\", dot = \"//\", apl = \"\")"
13394
]
13495
},
13596
{

nbs/04a_export.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@
139139
" nb.process()\n",
140140
" for mod,cells in exp.modules.items():\n",
141141
" all_cells = exp.in_all[mod]\n",
142-
" name = exp.default_exp if mod=='#' else mod\n",
142+
" name = getattr(exp, 'default_exp', None) if mod=='#' else mod\n",
143+
" if not name:\n",
144+
" warn(\"Could not find `#|default_exp` cell. Note nbdev2 no longer supports nbdev1 syntax. Run `nbdev_migrate` to upgrade.\\n\"\n",
145+
" \"See https://nbdev.fast.ai/getting_started.html for more information.\")\n",
146+
" return\n",
143147
" mm = mod_maker(dest=dest, name=name, nb_path=path, is_new=mod=='#')\n",
144148
" mm.make(cells, all_cells)"
145149
]

nbs/04b_doclinks.ipynb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,7 @@
441441
" if os.environ.get('IN_TEST',0): return\n",
442442
" files = nbglob(path=path, recursive=recursive, file_re=file_re, \n",
443443
" folder_re=folder_re, skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, symlinks=symlinks)\n",
444-
" for f in files:\n",
445-
" nb_export(f)\n",
444+
" for f in files: nb_export(f)\n",
446445
" add_init(get_config().path('lib_path'))\n",
447446
" build_modidx()"
448447
]

nbs/tutorial.ipynb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -981,10 +981,6 @@
981981
}
982982
],
983983
"metadata": {
984-
"jekyll": {
985-
"keywords": "fastai",
986-
"toc": "false"
987-
},
988984
"jupytext": {
989985
"split_at_heading": true
990986
},

tests/00_some.thing.ipynb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@
3333
"display_name": "Python 3 (ipykernel)",
3434
"language": "python",
3535
"name": "python3"
36-
},
37-
"language_info": {
38-
"codemirror_mode": {
39-
"name": "ipython",
40-
"version": 3
41-
},
42-
"file_extension": ".py",
43-
"mimetype": "text/x-python",
44-
"name": "python",
45-
"nbconvert_exporter": "python",
46-
"pygments_lexer": "ipython3",
47-
"version": "3.9.7"
4836
}
4937
},
5038
"nbformat": 4,

tests/01_everything.ipynb

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@
293293
},
294294
{
295295
"cell_type": "code",
296-
"execution_count": 1,
296+
"execution_count": null,
297297
"metadata": {},
298298
"outputs": [
299299
{
@@ -310,7 +310,7 @@
310310
},
311311
{
312312
"cell_type": "code",
313-
"execution_count": 1,
313+
"execution_count": null,
314314
"metadata": {},
315315
"outputs": [
316316
{
@@ -339,31 +339,6 @@
339339
"display_name": "Python 3 (ipykernel)",
340340
"language": "python",
341341
"name": "python3"
342-
},
343-
"language_info": {
344-
"codemirror_mode": {
345-
"name": "ipython",
346-
"version": 3
347-
},
348-
"file_extension": ".py",
349-
"mimetype": "text/x-python",
350-
"name": "python",
351-
"nbconvert_exporter": "python",
352-
"pygments_lexer": "ipython3",
353-
"version": "3.9.13"
354-
},
355-
"toc": {
356-
"base_numbering": 1,
357-
"nav_menu": {},
358-
"number_sections": false,
359-
"sideBar": true,
360-
"skip_h1_title": false,
361-
"title_cell": "Table of Contents",
362-
"title_sidebar": "Contents",
363-
"toc_cell": false,
364-
"toc_position": {},
365-
"toc_section_display": true,
366-
"toc_window_display": false
367342
}
368343
},
369344
"nbformat": 4,

0 commit comments

Comments
 (0)