Skip to main content

tutobooks

Note: All code credit to Francois Chollet, I simply bundled this into a pip package because I wanted to use it for more than keras.io

Taken from keras-io/scripts.

Installation

You can install from GitHub or PyPi:

pip install tutobooks

or

pip install git+https://github.com/lukewood/tutobooks

or

git clone https://github.com/lukewood/tutoboks
cd tutobooks
python setup.py develop

Overview

A tutobook is a tutorial available simultaneously as a notebook, as a Python script, and as a nicely rendered webpage.

Its source-of-truth (for manual edition and version control) is its Python script form, but you can also create one by starting from a notebook and converting it with the command nb2py.

Text cells are stored in markdown-formatted comment blocks. the first line (starting with " * 3) may optionally contain a special annotation, one of:

  • invisible: do not render this block.
  • shell: execute this block while prefixing each line with !.

The script form should start with a header with the following fields:

Title:
Author: (could be `Authors`: as well, and may contain markdown links)
Date created: (date in yyyy/mm/dd format)
Last modified: (date in yyyy/mm/dd format)
Description: (one-line text description)

You would typically start from an existing notebook.

Save it to disk (let's say as path_to_your_nb.ipynb).

Then run:

tutobooks nb2py path_to_your_nb.ipynb your_example.py

This will create the file your_example.py. Open it, fill in the headers, and generally edit it so that it looks nice.

You can then preview what it looks like when converted back again to ipynb by running:

python tutobooks py2nb your_example.py preview.ipynb

Open the generated preview.ipynb and make sure it looks like what you expect. If not, keep editing your_example.py until it does.

Usage

Conversion to markdown:

tutobooks nb2md mypath.ipynb mypath.md

Conversion to python:

tutobooks nb2py mypath.ipynb mypath.py

Conversion to markdown from python:

tutobooks py2md mypath.py mypath.md

Credits

Francois Chollet wrote almost all of the code for this (see keras.io repo), I just packaged it up into a PyPi package with proper CLI parsing and some tweaking to make the usage more generic.

Metadata

Release files for tutobooks 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tutobooks 0.1.0
File Size Uploaded
tutobooks-0.1.0.tar.gz 12.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tutobooks 0.1.0
File Interpreter ABI Platform
tutobooks-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 25.1 kB

Release files / tutobooks-0.1.0.tar.gz

Download URL tutobooks-0.1.0.tar.gz
Size 12.5 kB
Tags Source
SHA-256 checksum
How to use checksums
9360ebe0a1ae3c033cb5830cd5a3182a3c5ec227477dffcc782b9a57cd2accab
BLAKE2b-256 checksum
How to use checksums
035a645a2b025a2fa56ef8cbe2619f49302c76c0ae0e546218415e95215cbd71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13

Release files / tutobooks-0.1.0-py3-none-any.whl

Download URL tutobooks-0.1.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aa12910901f6242fc88889a6693a828bccaee7b07ea3744eaa5d27f022052de2
BLAKE2b-256 checksum
How to use checksums
d28e0bdf9e0ebe520651a1858035779bc2122be336f1b16b21af23a86fb231ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page