bookshelf_producer.notebook#
bookshelf_producer.notebook
#
Functions to run/manage notebooks
get_available_versions(name, include_private=False)
#
Get a list of available versions of a book
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Package name | required |
include_private | bool | If True, also include private versions | False |
Returns:
Type | Description |
---|---|
tuple[str, ...] | List of versions |
Source code in packages/bookshelf-producer/src/bookshelf_producer/notebook.py
load_nb_metadata(name, version=None, nb_directory=None)
#
Load notebook metadata
Attempts to search nb_directory
for a metadata YAML file. This YAML file contains information about the dataset that is being processed. See NotebookMetadata for a description of the available options.
The assumed filename format for versioned data is {name}_{version}.yaml
where name matches the notebook name and the name as specified in the NotebookMetadata
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Filename to load. Should match the notebook name (not checked) | required |
version | str | Version of the metadata to load. If none is provided, the last version will be used | None |
nb_directory | str | None | If a non-absolute path is provided, it is assumed to be relative to nb_directory | None |
Raises:
Type | Description |
---|---|
UnknownVersion | A matching version is not in the configuration |
Returns:
Type | Description |
---|---|
NotebookMetadata | Metadata about the notebook including the target package and version |
Source code in packages/bookshelf-producer/src/bookshelf_producer/notebook.py
run_notebook(name, nb_directory=None, output_directory=None, force=False, version=None)
#
Run a notebook to generate a new Book
The jupytext .py
version of the notebook is used.
The template file and configuration is copied to the output directory. The template .py
file is then used to create a notebook which is run using papermill
. The local_bookshelf
parameter is also set to the output directory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name | str | Name of the notebook | required |
nb_directory | str | Directory containing the notebooks. This defaults to the | None |
output_directory | str | Where the output directory will be created. This defaults to | None |
force | bool | If True, override the existing data in the output directory | False |
version | str | Version to extract | None |
Returns:
Type | Description |
---|---|
LocalBook | The generated book |
Source code in packages/bookshelf-producer/src/bookshelf_producer/notebook.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
|