Top Related Projects
Create delightful software with Jupyter Notebooks
Jupyter Interactive Notebook
JupyterLab computational environment.
VS Code Jupyter extension
📘 The interactive computing suite for you! ✨
Quick Overview
nbdev is a powerful library for creating Python packages and documentation using Jupyter Notebooks. It allows developers to write, test, and document code in a single environment, streamlining the development process and promoting literate programming practices.
Pros
- Seamless integration of code, tests, and documentation in Jupyter Notebooks
- Automatic generation of Python modules and documentation from notebooks
- Built-in support for continuous integration and version control
- Encourages best practices in software development and documentation
Cons
- Learning curve for developers not familiar with Jupyter Notebooks
- May require adjustments to existing development workflows
- Limited customization options for generated documentation
- Potential performance overhead when working with large projects
Code Examples
- Creating a new nbdev project:
from nbdev.cli import nbdev_new
nbdev_new("my_project")
- Exporting notebooks to Python modules:
from nbdev.export import notebook2script
notebook2script()
- Building documentation:
from nbdev.cli import nbdev_build_docs
nbdev_build_docs()
- Running tests:
from nbdev.test import test_nb
test_nb("my_notebook.ipynb")
Getting Started
To get started with nbdev, follow these steps:
- Install nbdev:
pip install nbdev
- Create a new project:
nbdev_new my_project
cd my_project
-
Edit the
settings.ini
file to configure your project. -
Create and edit Jupyter Notebooks in the
nbs/
directory. -
Export notebooks to Python modules:
nbdev_build_lib
- Build documentation:
nbdev_build_docs
- Commit changes and push to GitHub to trigger CI/CD.
Competitor Comparisons
Create delightful software with Jupyter Notebooks
Pros of nbdev
- More active development and recent updates
- Larger community and contributor base
- Better documentation and examples
Cons of nbdev
- Potentially more complex setup and configuration
- May have more features than needed for smaller projects
- Steeper learning curve for new users
Code Comparison
nbdev:
from nbdev import *
setup_git_hooks()
nbdev_build_lib()
nbdev_clean_nbs()
nbdev_test_nbs()
nbdev>:
from nbdev_core import *
nbdev_export()
nbdev_test()
nbdev_docs()
Both repositories are related to the nbdev project, which is a tool for developing Python libraries using Jupyter Notebooks. The main difference appears to be that nbdev> is a fork or alternative version of the original nbdev project. The code comparison shows slight differences in function names and available commands, with nbdev offering more specific functions while nbdev> seems to have more generalized commands. Overall, nbdev appears to be the more established and actively maintained project, while nbdev> might offer a simplified or alternative approach to the same concept.
Jupyter Interactive Notebook
Pros of notebook
- Well-established, widely adopted interactive computing environment
- Extensive ecosystem of extensions and integrations
- Supports multiple programming languages beyond Python
Cons of notebook
- Limited version control and collaboration features
- Can lead to non-reproducible workflows and "hidden state" issues
- Lacks built-in tools for creating Python packages from notebooks
Code comparison
notebook:
from notebook import notebookapp
notebookapp.main()
nbdev:
from nbdev.cli import nbdev_build_lib
nbdev_build_lib()
The notebook code snippet shows how to launch the Jupyter Notebook application, while the nbdev code demonstrates how to build a Python library from notebooks.
nbdev focuses on creating Python packages from Jupyter notebooks, offering features like automated documentation generation and two-way sync between notebooks and source code. It's designed to streamline the development process for data scientists and researchers who work primarily in notebooks.
notebook, on the other hand, provides a more general-purpose interactive computing environment that's not specifically tailored for package development. It offers a flexible platform for exploratory data analysis, visualization, and prototyping across various programming languages.
JupyterLab computational environment.
Pros of JupyterLab
- More comprehensive and feature-rich IDE-like environment
- Supports multiple file types and programming languages
- Highly extensible with a wide range of plugins and extensions
Cons of JupyterLab
- Steeper learning curve for beginners
- Heavier resource usage, especially for large projects
- Less integrated with version control and software development workflows
Code Comparison
JupyterLab (Python cell in a notebook):
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()
nbdev (Python code in a notebook cell):
#| export
import numpy as np
import matplotlib.pyplot as plt
def plot_sine_wave():
x = np.linspace(0, 10, 100)
y = np.sin(x)
plt.plot(x, y)
plt.show()
JupyterLab focuses on providing an interactive environment for data exploration and visualization, while nbdev emphasizes literate programming and seamless integration between notebooks and Python modules. The code examples illustrate how JupyterLab is typically used for direct data manipulation and visualization, whereas nbdev encourages creating reusable functions that can be easily exported to Python modules.
VS Code Jupyter extension
Pros of vscode-jupyter
- Seamless integration with Visual Studio Code, providing a familiar IDE experience
- Rich set of features for interactive Python development and data science workflows
- Extensive language support beyond Python, including R and Julia
Cons of vscode-jupyter
- Heavier resource usage due to the full VS Code environment
- Steeper learning curve for users not familiar with VS Code
- Less focus on literate programming and documentation generation
Code Comparison
vscode-jupyter:
# Interactive Python code execution in VS Code
%matplotlib inline
import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.show()
nbdev:
# #hide
from nbdev.showdoc import *
# #export
def plot_data(data):
"""Plot the given data"""
plt.plot(data)
plt.show()
The vscode-jupyter example shows interactive plotting within VS Code, while the nbdev example demonstrates its focus on documentation and code export. nbdev uses special comments for hiding cells and exporting functions, emphasizing its literate programming approach.
📘 The interactive computing suite for you! ✨
Pros of nteract
- More comprehensive interactive computing environment with support for multiple languages
- Offers a desktop application for a standalone experience
- Provides a rich set of components for building interactive interfaces
Cons of nteract
- Larger and more complex project, potentially harder to contribute to
- Less focused on literate programming and documentation generation
- May have a steeper learning curve for new users
Code Comparison
nteract example (JavaScript):
import { ContentRef } from "@nteract/types";
import { actions } from "@nteract/core";
const contentRef: ContentRef = "some-content-ref";
dispatch(actions.fetchContent({ contentRef }));
nbdev example (Python):
from nbdev.showdoc import show_doc
from nbdev.export import notebook2script
show_doc(notebook2script)
notebook2script('00_export.ipynb', 'nbdev/export.py')
nteract focuses on building interactive interfaces and managing notebook state, while nbdev emphasizes literate programming and code generation from notebooks. nteract's codebase is primarily JavaScript/TypeScript, whereas nbdev is Python-based. nteract offers a more comprehensive environment for interactive computing across languages, while nbdev specializes in Python development workflows and documentation generation.
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Getting Started
nbdev
is a notebook-driven development platform. Simply write
notebooks with lightweight markup and get high-quality documentation,
tests, continuous integration, and packaging for free!
nbdev
makes debugging and refactoring your code much easier than in
traditional programming environments since you always have live objects
at your fingertips. nbdev
also promotes software engineering best
practices because tests and documentation are first class.
- Documentation is automatically generated using
Quarto and hosted on GitHub
Pages. Docs support LaTeX, are searchable,
and are automatically hyperlinked (including out-of-the-box support
for many packages via
nbdev-index
) - Publish packages to PyPI and conda as well as tools to simplify
package releases. Python best practices are automatically followed,
for example, only exported objects are included in
__all__
- Two-way sync between notebooks and plaintext source code allowing you to use your IDE for code navigation or quick edits
- Tests written as ordinary notebook cells are run in parallel with a single command
- Continuous integration out-of-the-box with GitHub Actions that run your tests and rebuild your docs
- Git-friendly notebooks with Jupyter/Git hooks that clean unwanted metadata and render merge conflicts in a human-readable format
- ⦠and much more!
Install
nbdev works on macOS, Linux, and most Unix-style operating systems. It works on Windows under WSL, but not under cmd or Powershell.
You can install nbdev with pip:
pip install nbdev
⦠or with conda (or mamba):
conda install -c fastai nbdev
Note that nbdev
must be installed into the same Python environment
that you use for both Jupyter and your project.
How to use nbdev
The best way to learn how to use nbdev is to complete either the written walkthrough or video walkthrough:
Alternatively, thereâs a shortened version of the video
walkthrough with coding sections sped up
using the unsilence
Python library â itâs 27 minutes faster, but a bit
harder to follow.
You can also run nbdev_help
from the terminal to see the full list of
available commands:
!nbdev_help
nbdev_bump_version Increment version in settings.ini by one
nbdev_changelog Create a CHANGELOG.md file from closed and labeled GitHub issues
nbdev_clean Clean all notebooks in `fname` to avoid merge conflicts
nbdev_conda Create a `meta.yaml` file ready to be built into a package, and optionally build and upload it
nbdev_create_config Create a config file.
nbdev_docs Create Quarto docs and README.md
nbdev_export Export notebooks in `path` to Python modules
nbdev_filter A notebook filter for Quarto
nbdev_fix Create working notebook from conflicted notebook `nbname`
nbdev_help Show help for all console scripts
nbdev_install Install Quarto and the current library
nbdev_install_hooks Install Jupyter and git hooks to automatically clean, trust, and fix merge conflicts in notebooks
nbdev_install_quarto Install latest Quarto on macOS or Linux, prints instructions for Windows
nbdev_merge Git merge driver for notebooks
nbdev_migrate Convert all markdown and notebook files in `path` from v1 to v2
nbdev_new Create an nbdev project.
nbdev_prepare Export, test, and clean notebooks, and render README if needed
nbdev_preview Preview docs locally
nbdev_proc_nbs Process notebooks in `path` for docs rendering
nbdev_pypi Create and upload Python package to PyPI
nbdev_readme Create README.md from readme_nb (index.ipynb by default)
nbdev_release_both Release both conda and PyPI packages
nbdev_release_gh Calls `nbdev_changelog`, lets you edit the result, then pushes to git and calls `nbdev_release_git`
nbdev_release_git Tag and create a release in GitHub for the current version
nbdev_requirements Writes a `requirements.txt` file to `directory` based on settings.ini.
nbdev_sidebar Create sidebar.yml
nbdev_test Test in parallel notebooks matching `path`, passing along `flags`
nbdev_trust Trust notebooks matching `fname`
nbdev_update Propagate change in modules matching `fname` to notebooks that created them
nbdev_update_license Allows you to update the license of your project.
FAQ
Q: What is the warning âFound a cell containing mix of imports and computations. Please use separate cellsâ?
A: You should not have cells that are not exported, and contain a mix
of import
statements along with other code. For instance, donât do
this in a single cell:
import some_module
some_module.something()
Instead, split this into two cells, one which does import some_module
,
and the other which does some_module.something()
.
The reason for this is that when we create your documentation website,
we ensure that all of the signatures for functions you document are up
to date, by running the imports, exported cells, and
show_doc
functions
in your notebooks. When you mix imports with other code, that other code
will be run too, which can cause errors (or at least slowdowns) when
creating your website.
Q: Why is nbdev asking for root access? How do I install Quarto without root access?
A: When you setup your first project, nbdev will attempt to automatically download and install Quarto for you. This is the program that we use to create your documentation website.
Quartoâs standard installation process requires root access, and nbdev will therefore ask for your root password during installation. For most people, this will work fine and everything will be handled automatically â if so, you can skip over the rest of this section, which talks about installing without root access.
If you need to install Quarto without root access on Linux, first cd
to wherever you want to store it, then download
Quarto, and type:
dpkg -x quarto*.deb .
mv opt/quarto ./
rmdir opt
mkdir -p ~/.local/bin
ln -s "$(pwd)"/quarto/bin/quarto ~/.local/bin
To use this non-root version of Quarto, youâll need ~/.local/bin
in
your PATH
environment
variable.
(Alternatively, change the ln -s
step to place the symlink somewhere
else in your path.)
Q: Someone told me not to use notebooks for âseriousâ software development!
A: Watch this video. Donât worry, we
still get this too, despite having used nbdev
for a wide range of
âvery seriousâ software projects over the last three years, including
deep learning libraries, API
clients, Python language
extensions, terminal user
interfaces, and more!
Contributing
If you want to contribute to nbdev
, be sure to review the
contributions
guidelines.
This project adheres to fastaiâs code of
conduct.
By participating, you are expected to uphold this code. In general, we
strive to abide by generally accepted best practices in open-source
software development.
Make sure you have nbdev
âs git hooks installed by running
nbdev_install_hooks
in the cloned repository.
Copyright
Copyright © 2019 onward fast.ai, Inc. Licensed under the Apache License, Version 2.0 (the âLicenseâ); you may not use this projectâs files except in compliance with the License. A copy of the License is provided in the LICENSE file in this repository.
Top Related Projects
Create delightful software with Jupyter Notebooks
Jupyter Interactive Notebook
JupyterLab computational environment.
VS Code Jupyter extension
📘 The interactive computing suite for you! ✨
Convert
designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot