Giter VIP home page Giter VIP logo

jupyter-nb-templater's Introduction

contributions welcome

Tool preview

A command line tool to generate a Python script, which programmatically generates Jupyter notebooks, using a Jupyter notebook as a template starting point.

Particularly useful for projects where you need to generate many similar Jupyter notebooks in different directories, which differ only by a few lines e.g. the file which they import.

The intention of this script is to speed up the process of programmatically generating Jupyter notebooks, by providing a script template, which you can further customise downstream.

Requirements

  • Python 3.X
  • nbformat

Installation

First clone the repo

$  git clone https://github.com/ismailuddin/jupyter-nb-templater.git

Then install using

$  python setup.py install

Usage

To generate a Python script to programmatically generate a Jupyter notebook, first run nb-templater on the template Jupyter notebook file:

$  nb-templater -f input.ipynb -o output_script.py [ -n output.ipynb ]

Arguments

-f Input filename of the Jupyter notebook to use as a template

-o Output filename of the Python script used to generate the notebook

-n (Optional) The output filename of the Jupyter notebook generated by the script

Once the script has been generated, you can edit this file to customise the cells. For example, you may have a variable name in a cell of the notebook, which you substitute with an argument you provide to the script.

The generated Jupyter notebooks will not have been 'executed' by default. Using a shell script, you can execute this scripts from the command line with the following command:

$  jupyter nbconvert --execute --inplace "input.ipynb"

Covered in a bit more detail in my blog post.

Example outputs

The examples/ directory contains an example of the input Jupyter notebook file, and the output files generated by the scripts.

Limitations

  • Only supports converting notebook cells that either markdown or code.

jupyter-nb-templater's People

Contributors

ismailuddin avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.