import nblite.cli as this_module
cli
Helper functions
derive_cli_meta
-> Callable derive_cli_meta(source_func: FunctionType)
A decorator factory that transfers docstring and argument annotations from a source functio and turns
them into a typer annotations for the target function.
Arguments: - source_func
: The function from which to derive the docstring and argument annotations.
Define CLIs
entrypoint
bool) entrypoint(ctx: typer.Context, version:
main
main()
nbl export
cli_export
cli_export(str,None], Option(help="Path to the root folder of the nblite project.")],
root_path: Annotated[Union[str,None], Option(help="Path to the nblite.toml config file. Will be used instead of the config file in the root folder if provided.")],
config_path: Annotated[Union[str,None], Option(help=" The export pipeline to use. E.g. 'nbs->pts,pts->lib'.")],
export_pipeline: Annotated[Union[str],None], Option(help="If provided, only the notebooks specified in the paths will be exported.")]
nb_paths: Annotated[Union[List[ )
Export notebooks in an nblite project, as specified in the nblite.toml config file.
If the root_path
is not provided, nblite will search for a nblite.toml file in the current directory and all parent directories, and use the directory containing the nblite.toml file as the root folder.
nbl to-md
cli_to_md
cli_to_md(nb_path, out_path, nb_format)
nbl readme
cli_readme
cli_readme(root_path)
nbl convert
cli_convert
cli_convert(nb_path, dest_path, nb_format, dest_format)
nbl init
cli_init
cli_init(str,None], Option(help="The name of the module to create")],
module_name: Annotated[Union[str,None], Option(help="The root path of the project")],
root_path: Annotated[Union[bool, Option(help="Use default values for module name and root path")]
use_defaults: Annotated[ )
Initialize a new nblite project.
nbl new
cli_new
cli_new(str, Argument(help="The notebook to create.")],
nb_path: Annotated[str,None], Option("-n", "--name", help="The name of the exported module. Defaults to the notebook path relative to the code location root.")],
mod_name: Annotated[Union[str,None], Option("-t", "--title", help="The display title of the notebook. Defaults to the notebook path stem.")],
nb_title: Annotated[Union[str,None], Option("-r", "--root", help="The root path of the project. If not provided, the project root will be determined by searching for a nblite.toml file.")]
root_path: Annotated[Union[ )
Create a new notebook in a code location.
nbl clean
cli_clean
cli_clean(str], None], Argument(help="Specify the jupyter notebooks to clean. If omitted, all ipynb files in the project's code locations will be cleaned.")],
nb_paths: Annotated[Union[List[bool, Option(help="Remove the outputs from the notebook.")],
remove_outputs: Annotated[bool, Option(help="Remove the metadata from the notebook.")],
remove_cell_metadata: Annotated[bool, Option(help="Remove the top-level metadata from the notebook.")],
remove_top_metadata: Annotated[str,None], Option("-r", "--root", help="The root path of the project. If not provided, the project root will be determined by searching for a nblite.toml file.")],
root_path: Annotated[Union[bool, Option("--exclude-dunders", help="Exclude notebooks with that begin with a dunder (double underscore '__') in their filenames or in any of their parent folders. ")],
exclude_dunders: Annotated[bool, Option("--exclude-periods", help="Exclude notebooks with that begin with a period in their filenames or in their parent folders.")]
exclude_periods: Annotated[ )
Clean notebooks in an nblite project by removing outputs and metadata.
If nb_path
is not provided, all notebooks in the project will be cleaned.
nbl fill
cli_fill
cli_fill(str], None], Argument(help="Specify the jupyter notebooks to fill. If omitted, all ipynb files in the project's code locations will be filled.")],
nb_paths: Annotated[Union[List[bool, Option("-r", "--remove-prev-outputs", help="Remove the pre-existing outputs from the notebooks.")],
remove_prev_outputs: Annotated[bool, Option("-m", "--remove-metadata", help="Remove the metadata from notebook cells.")],
remove_cell_metadata: Annotated[str,None], Option("-r", "--root", help="The root path of the project. If not provided, the project root will be determined by searching for a nblite.toml file.")],
root_path: Annotated[Union[int,None], Option("-t", "--timeout", help="The timeout for the cell execution.")],
cell_exec_timeout: Annotated[Union[bool, Option("-i", "--include-dunders", help="Include notebooks with that begin with a dunder (double underscore '__') in their filenames or in any of their parent folders. ")],
include_dunders: Annotated[bool, Option("-p", "--include-periods", help="Include notebooks that begin with a period in their filenames or in their parent folders.")],
include_periods: Annotated[bool, Option(help="Dry run the command.")],
dry_run: Annotated[int, Option("-n", "--n-workers", help="The number of workers to use.")],
n_workers: Annotated[bool, Option("--allow-export-during", help="Allow export during the command.")],
allow_export_during: Annotated[bool, Option("-f", "--fill-unchanged", help="Fill the notebook even if the source has not changed.")]
fill_unchanged: Annotated[ )
Clean notebooks in an nblite project by removing outputs and metadata.
If nb_path
is not provided, all notebooks in the project will be cleaned.
nbl test
cli_test
cli_test(str], None], Argument(help="Specify the jupyter notebooks to fill. If omitted, all ipynb files in the project's code locations will be filled.")],
nb_paths: Annotated[Union[List[str,None], Option("-r", "--root", help="The root path of the project. If not provided, the project root will be determined by searching for a nblite.toml file.")],
root_path: Annotated[Union[int,None], Option("-t", "--timeout", help="The timeout for the cell execution.")],
cell_exec_timeout: Annotated[Union[bool, Option("-i", "--include-dunders", help="Include notebooks with that begin with a dunder (double underscore '__') in their filenames or in any of their parent folders. ")],
include_dunders: Annotated[bool, Option("-p", "--include-periods", help="Include notebooks that begin with a period in their filenames or in their parent folders.")]
include_periods: Annotated[ )
Alias for nbl fill --dry-run
. Used to test that all cells in the notebooks can be executed without errors.
nbl validate-staging
cli_validate_staging
cli_validate_staging(str,None], Option("-r", "--root", help="The root path of the project. If not provided, the project root will be determined by searching for a nblite.toml file.")]
root_path: Annotated[Union[ )
Validate the staging of the project.
The staging is valid if all notebooks are clean and the twins of all notebooks that are staged have no unstaged changes.
The command will exit with code 1 if the staging is invalid.
nbl install-hooks
cli_install_hooks
cli_install_hooks(str,None], Option("-r", "--root", help="The root path of the project. If not provided, the project root will be determined by searching for a nblite.toml file.")]
root_path: Annotated[Union[ )
Install the git hooks for the project.
nbl git-add
cli_git_add
cli_git_add(str], Argument(help="The file paths to add to the staging area.", autocompletion=_get_nbs)],
file_paths: Annotated[List[str], Option("--", help="Extra arguments to pass to git add.")]
extra_args: Annotated[List[ )
Like git add
, but also runs nbl export
, cleans any notebooks that are passed, and stages their twins.
nbl clear
cli_clear_downstream
cli_clear_downstream(str], Argument(help="The code location to clear downstream from.")],
code_location: Annotated[Optional[all: Annotated[bool, Option(help="Clear all downstream notebooks.")]
)
Clear a code location or all code locations downstream from the top-level code location.
nbl prepare
cli_prepare
cli_prepare(str,None], Option("-r", "--root", help="The root path of the project. If not provided, the project root will be determined by searching for a nblite.toml file.")],
root_path: Annotated[Union[int,None], Option("-t", "--timeout", help="The timeout for the cell execution.")],
cell_exec_timeout: Annotated[Union[bool, Option("-i", "--include-dunders", help="Include notebooks with that begin with a dunder (double underscore '__') in their filenames or in any of their parent folders. ")],
include_dunders: Annotated[bool, Option("-p", "--include-periods", help="Include notebooks that begin with a period in their filenames or in their parent folders.")],
include_periods: Annotated[bool, Option(help="Dry run the command.")],
dry_run: Annotated[int, Option("-n", "--n-workers", help="The number of workers to use.")],
n_workers: Annotated[bool, Option("--allow-export-during", help="Allow export during the command.")],
allow_export_during: Annotated[bool, Option("-f", "--fill-unchanged", help="Fill the notebook even if the source has not changed.")]
fill_unchanged: Annotated[ )
Export, clean, and fill the notebooks in the project.
nbl render-docs
cli_render_docs
cli_render_docs(str,None], Option("-r", "--root", help="The root path of the project. If not provided, the project root will be determined by searching for a nblite.toml file.")],
root_path: Annotated[Union[str], Option("-d", "--docs-cl", help="The code location to render the documentation for. If not provided, the code location will be retrieved from the nblite.toml file.")],
docs_cl: Annotated[Optional[str], Option("-o", "--output-folder", help="The folder to output the documentation to. Default is '_docs'.")]
output_folder: Annotated[Optional[ )
Render the documentation for the project using Quarto.
nbl preview-docs
cli_render_docs
cli_render_docs(str,None], Option("-r", "--root", help="The root path of the project. If not provided, the project root will be determined by searching for a nblite.toml file.")],
root_path: Annotated[Union[str], Option("-d", "--docs-cl", help="The code location to render the documentation for. If not provided, the code location will be retrieved from the nblite.toml file.")]
docs_cl: Annotated[Optional[ )
Preview the documentation for the project using Quarto.