Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions nbdev/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ def nbdev_create_config(
path.mkdir(exist_ok=True, parents=True)

# Infer from git if not provided
inf = _fetch_from_git()
inf,ucfg = _fetch_from_git(),_user_config()
repo = repo or inf.get('repo') or path.resolve().name
user = user or inf.get('user', '')
user = user or inf.get('user') or ucfg.get('user', '')
if not user: raise ValueError("Could not infer `user` from git. Please pass --user explicitly.")
author = author or inf.get('author', '')
author = author or inf.get('author') or ucfg.get('author', '')
if not author: raise ValueError("Could not infer `author` from git. Please pass --author explicitly.")
author_email = author_email or inf.get('author_email', '')
author_email = author_email or inf.get('author_email') or ucfg.get('author_email', '')
if not author_email: raise ValueError("Could not infer `author_email` from git. Please pass --author-email explicitly.")
branch = branch or inf.get('branch', 'main')
description = description or inf.get('description', '')
Expand Down Expand Up @@ -171,7 +171,7 @@ def _find_nbdev_pyproject(path=None):
# %% ../nbs/api/01_config.ipynb #3dac70e0
nbdev_defaults = dict(nbs_path='nbs', doc_path='_docs', tst_flags='notest', recursive=True, readme_nb='index.ipynb',
clean_ids=True, clear_all=False, put_version_in_init=True, jupyter_hooks=False, custom_sidebar=False, branch='main',
doc_procs=[], export_procs=[], exec_profile=True)
doc_procs=[], export_procs=[], exec_profile=True, cell_timeout=600)

_path_keys = 'lib_path', 'nbs_path', 'doc_path'

Expand Down
2 changes: 1 addition & 1 deletion nbdev/skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@

A behavior change means revising the lesson cells it touches: prose, displayed output, and assertions move together. Where you revised or added an assertion, check it fails against the old code and passes against the new. Many changes need no new cell at all - never add one merely to witness a change. Re-read the touched section as a reader would, against the conventions above. Style damage breaks no test and no export, so the harm only shows on the docs page.

Run notebooks with `nbdev-test --cell-timeout 60 --cell-timing-min 2 <nb>`. The default cell timeout is 600s, so a stalled cell (a dead server, an unbounded network wait) sits silently for ten minutes; the short timeout fails loudly naming the stuck cell, and the timing report names any cell slower than 2s, which is how a notebook that quietly stopped replaying its recorded HTTP gets noticed. A genuinely slow notebook gets a higher bound stated per run, not a removed one.
Run notebooks with `nbdev-test <nb>`.
"""
5 changes: 3 additions & 2 deletions nbdev/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,13 @@ def nbdev_test(
ignore_fname:str='.notest', # Filename that will result in siblings being ignored
verbose:bool=False, # Print stdout/stderr from notebook cells?
save:bool=False, # Write outputs back to notebooks on success?
cell_timeout:int=600, # Seconds before each cell times out (0: no limit)
cell_timing_min:float=None, # Print cells slower than this many seconds (None: no timing output)
cell_timeout:int=None, # Seconds before each cell times out (0: no limit; default `cell_timeout` config, 600)
cell_timing_min:float=None, # Print cells slower than this many seconds (default `cell_timing_min` config, else none)
**kwargs
):
"Test in parallel notebooks matching `path`, passing along `flags`"
cfg = get_config(Path(path).resolve() if path else None)
cell_timeout,cell_timing_min = ifnone(cell_timeout, cfg.cell_timeout),ifnone(cell_timing_min, cfg.get('cell_timing_min'))
skip_flags = cfg.tst_flags
if isinstance(skip_flags, str): skip_flags = skip_flags.split()
force_flags = flags.split()
Expand Down
12 changes: 6 additions & 6 deletions nbs/api/01_config.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,13 @@
" path.mkdir(exist_ok=True, parents=True)\n",
" \n",
" # Infer from git if not provided\n",
" inf = _fetch_from_git()\n",
" inf,ucfg = _fetch_from_git(),_user_config()\n",
" repo = repo or inf.get('repo') or path.resolve().name\n",
" user = user or inf.get('user', '')\n",
" user = user or inf.get('user') or ucfg.get('user', '')\n",
" if not user: raise ValueError(\"Could not infer `user` from git. Please pass --user explicitly.\")\n",
" author = author or inf.get('author', '')\n",
" author = author or inf.get('author') or ucfg.get('author', '')\n",
" if not author: raise ValueError(\"Could not infer `author` from git. Please pass --author explicitly.\")\n",
" author_email = author_email or inf.get('author_email', '')\n",
" author_email = author_email or inf.get('author_email') or ucfg.get('author_email', '')\n",
" if not author_email: raise ValueError(\"Could not infer `author_email` from git. Please pass --author-email explicitly.\")\n",
" branch = branch or inf.get('branch', 'main')\n",
" description = description or inf.get('description', '')\n",
Expand Down Expand Up @@ -356,7 +356,7 @@
"#| export\n",
"nbdev_defaults = dict(nbs_path='nbs', doc_path='_docs', tst_flags='notest', recursive=True, readme_nb='index.ipynb',\n",
" clean_ids=True, clear_all=False, put_version_in_init=True, jupyter_hooks=False, custom_sidebar=False, branch='main',\n",
" doc_procs=[], export_procs=[], exec_profile=True)\n",
" doc_procs=[], export_procs=[], exec_profile=True, cell_timeout=600)\n",
"\n",
"_path_keys = 'lib_path', 'nbs_path', 'doc_path'"
]
Expand Down Expand Up @@ -558,7 +558,7 @@
"id": "78056483",
"metadata": {},
"source": [
"You can customize nbdev for all your projects by creating a `~/.config/nbdev/config.toml` file (or following the [XDG specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)). For example, you could globally disable nbdev's Jupyter hooks with `jupyter_hooks = false`."
"You can customize nbdev for all your projects by creating a `~/.config/nbdev/config.toml` file (or following the [XDG specification](https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html)). Any `[tool.nbdev]` key can go there, with the project's own setting winning: for example, `jupyter_hooks = false` globally disables nbdev's Jupyter hooks, and `cell_timeout = 60` gives `nbdev-test` a default cell timeout. `nbdev-create-config` also reads `user`, `author`, and `author_email` from it when neither the arguments nor the git remote supply them."
]
},
{
Expand Down
7 changes: 4 additions & 3 deletions nbs/api/12_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"id": "bae187da",
"metadata": {},
"source": [
"Pass `cell_timing_min` to identify slow cells without flooding ordinary test output. Each cell over the threshold prints its notebook name, stable cell id, and elapsed seconds; `--cell-timing-min=0.1` is a useful first pass."
"Pass `cell_timing_min` to identify slow cells without flooding ordinary test output. Each cell over the threshold prints its notebook name, stable cell id, and elapsed seconds; `--cell-timing-min=0.1` is a useful first pass. Both `cell_timeout` and `cell_timing_min` fall back to the config keys of the same name when not passed, so a preferred bound can live in `~/.config/nbdev/config.toml` or a project's `[tool.nbdev]` table."
]
},
{
Expand Down Expand Up @@ -295,12 +295,13 @@
" ignore_fname:str='.notest', # Filename that will result in siblings being ignored\n",
" verbose:bool=False, # Print stdout/stderr from notebook cells?\n",
" save:bool=False, # Write outputs back to notebooks on success?\n",
" cell_timeout:int=600, # Seconds before each cell times out (0: no limit)\n",
" cell_timing_min:float=None, # Print cells slower than this many seconds (None: no timing output)\n",
" cell_timeout:int=None, # Seconds before each cell times out (0: no limit; default `cell_timeout` config, 600)\n",
" cell_timing_min:float=None, # Print cells slower than this many seconds (default `cell_timing_min` config, else none)\n",
" **kwargs\n",
"):\n",
" \"Test in parallel notebooks matching `path`, passing along `flags`\"\n",
" cfg = get_config(Path(path).resolve() if path else None)\n",
" cell_timeout,cell_timing_min = ifnone(cell_timeout, cfg.cell_timeout),ifnone(cell_timing_min, cfg.get('cell_timing_min'))\n",
" skip_flags = cfg.tst_flags\n",
" if isinstance(skip_flags, str): skip_flags = skip_flags.split()\n",
" force_flags = flags.split()\n",
Expand Down
Loading