Skip to content

Commit 5acf04e

Browse files
committed
fixes #1647
1 parent 08c0aae commit 5acf04e

5 files changed

Lines changed: 23 additions & 8 deletions

File tree

‎nbdev/doclinks.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,15 @@ def nbglob_cli(
129129
symlinks:bool=False, # Follow symlinks?
130130
file_glob:str='*.ipynb', # Only include files matching glob
131131
file_re:str=None, # Only include files matching regex
132+
path_glob:str=None, # Only include files whose full paths match glob (wildcards match separators)
133+
path_re:str=None, # Only include files whose full paths match regex
132134
folder_re:str=None, # Only enter folders matching regex
133135
skip_file_glob:str=None, # Skip files matching glob
134136
skip_file_re:str='^[_.]', # Skip files matching regex
135137
skip_folder_re:str = '^[_.]'): # Skip folders matching regex
136138
"Find all files in a directory matching an extension given a config key."
137-
return nbglob(path, symlinks=symlinks, file_glob=file_glob, file_re=file_re, folder_re=folder_re,
139+
return nbglob(path, symlinks=symlinks, file_glob=file_glob, file_re=file_re,
140+
path_glob=path_glob, path_re=path_re, folder_re=folder_re,
138141
skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, skip_folder_re=skip_folder_re)
139142

140143
# %% ../nbs/api/05_doclinks.ipynb #5e6fbe08

‎nbdev/test.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def _keep_file(
143143
@call_parse(pos=['path'])
144144
@delegates(nbglob_cli)
145145
def nbdev_test(
146-
path:str=None, # A notebook name or glob to test
146+
path:str=None, # A notebook, directory, or full-path glob to test
147147
flags:str='', # Space separated list of test flags to run that are normally ignored
148148
n_workers:int=None, # Number of workers
149149
timing:bool=False, # Time each notebook to see which are slow
@@ -157,6 +157,7 @@ def nbdev_test(
157157
**kwargs
158158
):
159159
"Test in parallel notebooks matching `path`, passing along `flags`"
160+
if path and not Path(path).exists(): kwargs['path_glob'],path = os.path.abspath(path),Path.cwd()
160161
cfg = get_config(Path(path).resolve() if path else None)
161162
cell_timeout,cell_timing_min = ifnone(cell_timeout, cfg.cell_timeout),ifnone(cell_timing_min, cfg.get('cell_timing_min'))
162163
skip_flags = cfg.tst_flags

‎nbs/api/05_doclinks.ipynb‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,12 +346,15 @@
346346
" symlinks:bool=False, # Follow symlinks?\n",
347347
" file_glob:str='*.ipynb', # Only include files matching glob\n",
348348
" file_re:str=None, # Only include files matching regex\n",
349+
" path_glob:str=None, # Only include files whose full paths match glob (wildcards match separators)\n",
350+
" path_re:str=None, # Only include files whose full paths match regex\n",
349351
" folder_re:str=None, # Only enter folders matching regex\n",
350352
" skip_file_glob:str=None, # Skip files matching glob\n",
351353
" skip_file_re:str='^[_.]', # Skip files matching regex\n",
352354
" skip_folder_re:str = '^[_.]'): # Skip folders matching regex\n",
353355
" \"Find all files in a directory matching an extension given a config key.\"\n",
354-
" return nbglob(path, symlinks=symlinks, file_glob=file_glob, file_re=file_re, folder_re=folder_re,\n",
356+
" return nbglob(path, symlinks=symlinks, file_glob=file_glob, file_re=file_re,\n",
357+
" path_glob=path_glob, path_re=path_re, folder_re=folder_re,\n",
355358
" skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, skip_folder_re=skip_folder_re)"
356359
]
357360
},

‎nbs/api/12_test.ipynb‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@
344344
"@call_parse(pos=['path'])\n",
345345
"@delegates(nbglob_cli)\n",
346346
"def nbdev_test(\n",
347-
" path:str=None, # A notebook name or glob to test\n",
347+
" path:str=None, # A notebook, directory, or full-path glob to test\n",
348348
" flags:str='', # Space separated list of test flags to run that are normally ignored\n",
349349
" n_workers:int=None, # Number of workers\n",
350350
" timing:bool=False, # Time each notebook to see which are slow\n",
@@ -358,6 +358,7 @@
358358
" **kwargs\n",
359359
"):\n",
360360
" \"Test in parallel notebooks matching `path`, passing along `flags`\"\n",
361+
" if path and not Path(path).exists(): kwargs['path_glob'],path = os.path.abspath(path),Path.cwd()\n",
361362
" cfg = get_config(Path(path).resolve() if path else None)\n",
362363
" cell_timeout,cell_timing_min = ifnone(cell_timeout, cfg.cell_timeout),ifnone(cell_timing_min, cfg.get('cell_timing_min'))\n",
363364
" skip_flags = cfg.tst_flags\n",
@@ -436,7 +437,15 @@
436437
"\n",
437438
"```\n",
438439
"nbdev-test ../../tests --file-re '.*test.ipynb' --do-print\n",
439-
"```"
440+
"```\n",
441+
"\n",
442+
"An omitted path uses the configured `nbs_path`. An existing file or directory is used directly. A path that does not exist is treated as a full-path glob filter over the working directory's tree. Quote patterns to prevent shell expansion:\n",
443+
"\n",
444+
"```sh\n",
445+
"nbdev-test 'nbs/api/*test*.ipynb'\n",
446+
"```\n",
447+
"\n",
448+
"The glob uses `fnmatch`: `*` matches directory separators and `**` has no special meaning. Use `--path-re` for regex filtering on full paths. `--file-re` matches filenames only."
440449
]
441450
},
442451
{

‎pyproject.toml‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ classifiers = [
1919
"License :: OSI Approved :: Apache Software License",
2020
]
2121
dynamic = ["version"]
22-
dependencies = [ "fastcore>=2.2.23", "execnb>=0.3.3", "astunparse", "ghapi>=2.0.2", "watchdog", "asttokens",
22+
dependencies = [ "fastcore>=2.2.28", "execnb>=0.3.3", "astunparse", "ghapi>=2.0.2", "watchdog", "asttokens",
2323
"setuptools", "build", "fastgit>=0.0.7", "pyyaml", "tomli; python_version < '3.11'", ]
2424

2525
[project.optional-dependencies]
26-
dev = [ "ipywidgets", "nbdev-numpy", "nbdev-stdlib", "pandas", "matplotlib", "black", "svg.py", "nbclassic",
27-
"pysym2md>=0.0.6", "llms-txt", "sphinx", "plum-dispatch", ]
26+
dev = [ "ipywidgets", "nbdev-numpy", "nbdev-stdlib", "pandas", "matplotlib", "black", "svg.py", "pysym2md>=0.0.6", "llms-txt", "sphinx", "plum-dispatch", ]
2827

2928
[project.urls]
3029
Repository = "https://github.com/AnswerDotAI/nbdev"

0 commit comments

Comments
 (0)