nbprocess_trust
nbprocess_trust (fname:str=None, force_all:bool=False)
Trust notebooks matching fname
Type | Default | Details | |
---|---|---|---|
fname | str | None | A notebook name or glob to trust |
force_all | bool | False | Trust even notebooks that havent changed |
To avoid pointless conflicts while working with jupyter notebooks (with different execution counts or cell metadata), it is recommended to clean the notebooks before committing anything (done automatically if you install the git hooks with nbprocess_install_git_hooks
). The following functions are used to do that.
nbprocess_trust (fname:str=None, force_all:bool=False)
Trust notebooks matching fname
Type | Default | Details | |
---|---|---|---|
fname | str | None | A notebook name or glob to trust |
force_all | bool | False | Trust even notebooks that havent changed |
clean_nb (nb, clear_all=False)
Clean nb
from superfluous metadata
tst = {'cell_type': 'code', 'execution_count': 26,
'metadata': {'hide_input': True, 'meta': 23},
'outputs': [{'execution_count': 2,
'data': {
'application/vnd.google.colaboratory.intrinsic+json': {'type': 'string'},
'plain/text': ['sample output',]
}, 'output': 'super'}],
'source': 'awesome_code'}
nb = {'metadata': {'kernelspec': 'some_spec', 'jekyll': 'some_meta', 'meta': 37}, 'cells': [tst]}
clean_nb(nb)
test_eq(nb['cells'][0], {'cell_type': 'code', 'execution_count': None,
'metadata': {'hide_input': True},
'outputs': [{'execution_count': None,
'data': { 'plain/text': ['sample output',]},
'output': 'super'}],
'source': 'awesome_code'})
test_eq(nb['metadata'], {'kernelspec': 'some_spec', 'jekyll': 'some_meta'})
process_write (warn_msg, proc_nb, f_in, f_out=None, disp=False)
nbprocess_clean (fname:str=None, clear_all:bool=False, disp:bool=False, stdin:bool=False)
Clean all notebooks in fname
to avoid merge conflicts
Type | Default | Details | |
---|---|---|---|
fname | str | None | A notebook name or glob to convert |
clear_all | bool | False | Clean all metadata and outputs |
disp | bool | False | Print the cleaned outputs |
stdin | bool | False | Read input stream and not nb folder |
By default (fname
left to None
), the all the notebooks in lib_folder
are cleaned. You can opt in to fully clean the notebook by removing every bit of metadata and the cell outputs by passing clear_all=True
.
nbprocess_install_hooks ()
Install git hooks to clean/trust notebooks automatically