Skip to content

Commit

Permalink
Merge pull request #1445 from fastai/skip-procs
Browse files Browse the repository at this point in the history
add `skip_procs` to `settings.ini`
  • Loading branch information
jph00 authored Sep 13, 2024
2 parents d768248 + 1a48c72 commit 7401c11
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 45 deletions.
1 change: 1 addition & 0 deletions nbdev/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def _apply_defaults(
clear_all:bool_arg=False, # Remove all cell metadata and cell outputs?
cell_number:bool_arg=True, # Add cell number to the exported file
put_version_in_init:bool_arg=True, # Add the version to the main __init__.py in nbdev_export
skip_procs:str='', # A list of processors that you want to skip
):
"Apply default settings where missing in `cfg`."
if getattr(cfg,'repo',None) is None:
Expand Down
3 changes: 2 additions & 1 deletion nbdev/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ def base_procs(self):

def procs(self):
"Processors for export"
return self.base_procs() + self.xtra_procs()
skip_procs = get_config().get('skip_procs', '').split()
return L(self.base_procs()).filter(lambda x: x.__name__ not in skip_procs) + self.xtra_procs()

def nb_proc(self, nb):
"Get an `NBProcessor` with these processors"
Expand Down
12 changes: 2 additions & 10 deletions nbs/api/01_config.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
" clear_all:bool_arg=False, # Remove all cell metadata and cell outputs?\n",
" cell_number:bool_arg=True, # Add cell number to the exported file\n",
" put_version_in_init:bool_arg=True, # Add the version to the main __init__.py in nbdev_export\n",
" skip_procs:str='', # A list of processors that you want to skip\n",
"):\n",
" \"Apply default settings where missing in `cfg`.\"\n",
" if getattr(cfg,'repo',None) is None:\n",
Expand Down Expand Up @@ -195,16 +196,7 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/dienhoa/miniconda3/envs/se/lib/python3.9/site-packages/ghapi/core.py:102: UserWarning: Neither GITHUB_TOKEN nor GITHUB_JWT_TOKEN found: running as unauthenticated\n",
" else: warn('Neither GITHUB_TOKEN nor GITHUB_JWT_TOKEN found: running as unauthenticated')\n"
]
}
],
"outputs": [],
"source": [
"#|hide\n",
"if os.getenv('GITHUB_ACTIONS') != 'true': # GITHUB_TOKEN in actions has limited scope.\n",
Expand Down
3 changes: 2 additions & 1 deletion nbs/api/10_processors.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,8 @@
"\n",
" def procs(self):\n",
" \"Processors for export\"\n",
" return self.base_procs() + self.xtra_procs()\n",
" skip_procs = get_config().get('skip_procs', '').split()\n",
" return L(self.base_procs()).filter(lambda x: x.__name__ not in skip_procs) + self.xtra_procs()\n",
" \n",
" def nb_proc(self, nb):\n",
" \"Get an `NBProcessor` with these processors\"\n",
Expand Down
70 changes: 37 additions & 33 deletions nbs/explanations/config.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
"text": [
"[DEFAULT]\r\n",
"lib_name = nbdev\r\n",
"repo = nbdev\r\n",
"description = Create delightful software with Jupyter Notebooks\r\n",
"copyright = 2020 onwards, Jeremy Howard\r\n",
"keywords = nbdev fastai jupyter notebook export\r\n",
"user = fastai\r\n",
"author = Jeremy Howard and Hamel Husain\r\n",
"author_email = [email protected]\r\n",
"branch = master\r\n",
"min_python = 3.7\r\n"
"branch = master\r\n"
]
}
],
Expand All @@ -75,39 +75,43 @@
"text/markdown": [
"| | **Type** | **Default** | **Details** |\n",
"| -- | -------- | ----------- | ----------- |\n",
"| user | str | | Repo username |\n",
"| author | str | | Package author's name |\n",
"| author_email | str | | Package author's email address |\n",
"| description | str | | Short summary of the package |\n",
"| repo | str | None | Repo name |\n",
"| branch | str | None | Repo default branch |\n",
"| user | str | None | Repo username |\n",
"| author | str | None | Package author's name |\n",
"| author_email | str | None | Package author's email address |\n",
"| description | str | None | Short summary of the package |\n",
"| path | str | . | Path to create config file |\n",
"| cfg_name | str | settings.ini | Name of config file to create |\n",
"| lib_name | str | None | Package name, defaults to local repo folder name passed to `apply_defaults` |\n",
"| branch | str | master | Repo default branch passed to `apply_defaults` |\n",
"| git_url | str | https://github.com/%(user)s/%(lib_name)s | Repo URL passed to `apply_defaults` |\n",
"| custom_sidebar | bool_arg | False | Use a custom sidebar.yml? passed to `apply_defaults` |\n",
"| nbs_path | str | . | Path to notebooks passed to `apply_defaults` |\n",
"| lib_path | str | %(lib_name)s | Path to package root passed to `apply_defaults` |\n",
"| doc_path | str | _docs | Path to rendered docs passed to `apply_defaults` |\n",
"| tst_flags | str | | Test flags passed to `apply_defaults` |\n",
"| version | str | 0.0.1 | Version of this release passed to `apply_defaults` |\n",
"| doc_host | str | https://%(user)s.github.io | Hostname for docs passed to `apply_defaults` |\n",
"| doc_baseurl | str | /%(lib_name)s | Base URL for docs passed to `apply_defaults` |\n",
"| keywords | str | nbdev jupyter notebook python | Package keywords passed to `apply_defaults` |\n",
"| license | str | apache2 | License for the package passed to `apply_defaults` |\n",
"| copyright | str | None | Copyright for the package, defaults to '`current_year` onwards, `author`' passed to `apply_defaults` |\n",
"| status | str | 3 | Development status PyPI classifier passed to `apply_defaults` |\n",
"| min_python | str | 3.7 | Minimum Python version PyPI classifier passed to `apply_defaults` |\n",
"| audience | str | Developers | Intended audience PyPI classifier passed to `apply_defaults` |\n",
"| language | str | English | Language PyPI classifier passed to `apply_defaults` |\n",
"| recursive | bool_arg | False | Include subfolders in notebook globs? passed to `apply_defaults` |\n",
"| black_formatting | bool_arg | False | Format libraries with black? passed to `apply_defaults` |\n",
"| readme_nb | str | index.ipynb | Notebook to export as repo readme passed to `apply_defaults` |\n",
"| title | str | %(lib_name)s | Quarto website title passed to `apply_defaults` |\n",
"| allowed_metadata_keys | str | | Preserve the list of keys in the main notebook metadata passed to `apply_defaults` |\n",
"| allowed_cell_metadata_keys | str | | Preserve the list of keys in cell level metadata passed to `apply_defaults` |\n",
"| jupyter_hooks | bool | True | Run Jupyter hooks? passed to `apply_defaults` |\n",
"| clean_ids | bool | True | Remove ids from plaintext reprs? passed to `apply_defaults` |\n",
"| custom_quarto_yml | bool | False | Use a custom _quarto.yml? passed to `apply_defaults` |"
"| lib_name | str | %(repo)s | Package name |\n",
"| git_url | str | https://github.com/%(user)s/%(repo)s | Repo URL |\n",
"| custom_sidebar | bool_arg | False | Use a custom sidebar.yml? |\n",
"| nbs_path | Path | nbs | Path to notebooks |\n",
"| lib_path | Path | None | Path to package root (default: `repo` with `-` replaced by `_`) |\n",
"| doc_path | Path | _docs | Path to rendered docs |\n",
"| tst_flags | str | notest | Test flags |\n",
"| version | str | 0.0.1 | Version of this release |\n",
"| doc_host | str | https://%(user)s.github.io | Hostname for docs |\n",
"| doc_baseurl | str | /%(repo)s | Base URL for docs |\n",
"| keywords | str | nbdev jupyter notebook python | Package keywords |\n",
"| license | str | apache2 | License for the package |\n",
"| copyright | str | None | Copyright for the package, defaults to '`current_year` onwards, `author`' |\n",
"| status | str | 3 | Development status PyPI classifier |\n",
"| min_python | str | 3.7 | Minimum Python version PyPI classifier |\n",
"| audience | str | Developers | Intended audience PyPI classifier |\n",
"| language | str | English | Language PyPI classifier |\n",
"| recursive | bool_arg | True | Include subfolders in notebook globs? |\n",
"| black_formatting | bool_arg | False | Format libraries with black? |\n",
"| readme_nb | str | index.ipynb | Notebook to export as repo readme |\n",
"| title | str | %(lib_name)s | Quarto website title |\n",
"| allowed_metadata_keys | str | | Preserve the list of keys in the main notebook metadata |\n",
"| allowed_cell_metadata_keys | str | | Preserve the list of keys in cell level metadata |\n",
"| jupyter_hooks | bool_arg | False | Run Jupyter hooks? |\n",
"| clean_ids | bool_arg | True | Remove ids from plaintext reprs? |\n",
"| clear_all | bool_arg | False | Remove all cell metadata and cell outputs? |\n",
"| cell_number | bool_arg | True | Add cell number to the exported file |\n",
"| put_version_in_init | bool_arg | True | Add the version to the main __init__.py in nbdev_export |\n",
"| skip_procs | str | | A list of processors that you want to skip |"
],
"text/plain": [
"<nbdev.showdoc.DocmentTbl>"
Expand Down

0 comments on commit 7401c11

Please sign in to comment.