Skip to main content

EasyJupyter allows you to effortlessly integrate your Jupyter Notebook code into any Python project or other notebooks.

Project description

EasyJupyter

EasyJupyter allows you to effortlessly integrate your Jupyter Notebook code into any Python project or other notebooks. It intelligently transforms your notebooks into standard Python modules, allowing you to import functions, classes, and variables as if they were regular .py files. This seamless process, managed by a background caching mechanism, lets you leverage the interactive development environment of notebooks for rapid prototyping and analysis, while ensuring your code is modular and reusable.

This is particularly useful for AI/Data science projects. For example, if you are building out a Transformer architecture, you could code and write notes for each layer of the model in its own notebook, and then seamlessly import them into your main project or another notebook.

Key Benefits:

  • Native GitHub Rendering: Keep your code in notebooks so plots and markdown render natively on GitHub.
  • Zero Clutter: Generated cache files are stored in a hidden .easyJupyter_cache directory, keeping your workspace clean.
  • Custom ignore syntax to ignore exploratory cells, or lines of code.

How It Works: When EasyJupyter is first imported within a project, it initiates a single, detached background daemon for that specific project. This daemon is tied to your project's root (specifically, the generated .easyJupyter_cache/watcher.pid file) and monitors only the notebooks within it. This per-project design ensures that different projects can have their own daemons completely isolated and do not interfere with each other. If the daemon for a project is not already running, it will be started automatically the next time you import EasyJupyter within that project's environment.

Table of Contents

Ignore Notebook Commands

Use these commands inside notebooks to control what gets compiled into the cache.

  • Markdown Cells: Ignored by default.
  • Ignore An Entire Cell:
    • Add # @i-c to the very top of the cell.
  • Ignore One Line In A Cell:
    • Add # @i-l above the line you want to ignore.

Getting Started

Installation

pip install easyjupyter

Usage

In your project's entry point (e.g., main.py) and in any Jupyter Notebooks where you want the daemon to be active or when importing from other notebooks, import the library at the very top of the file:

import EasyJupyter # Import at the very top of the file
from my_notebook import Class, Function_name
  • Importing EasyJupyter in many files is not a problem, as only one daemon can run at a time per project, you could import it in all your files if you want.

[!important] Never edit the cache files directly, only edit the notebooks!

If your project has nested folders. Create a easyJupyterConfig file in the root of your project!

# cd into your project root
touch easyJupyterConfig

[!NOTE]

  • Check out example_nested_project. Note run main.py from inside ./example_nested_project, also for VSC's Pylance to kick in, open a new VSC window with ./example_nested_project as root, and follow VSC Pylance Intellisense Setup below.

  • You should use Notebook automatic reloading if you are simultaneously working with many notebooks that import each other. Add following to a cell at the top of notebooks!

    # @i-c
    %load_ext autoreload
    %autoreload 2
    

Arguments

  • Always run easyjupyter --<argument> from somewhere in a project, where the daemon lives.

Sync All Notebooks

  • Sync all notebooks to the cache, run:
    • Do this only if your cache is empty and you have existing notebooks, not every time you update a notebook.

      easyjupyter --sync
      

Cache Cleanup

  • If you rename, move, or delete a notebook, the old cache file will remain in the hidden cache directory. To clean up the cache, run:

    easyjupyter --clean
    

Watch Daemon Logs

  • If you incorrectly use EasyJupyter in a notebook (e.g., redundant ignore comments), warnings will be embedded directly into the generated cache file. These warnings will be printed to the console (or notebook output) whenever the cached module is imported and executed, even when importing from another notebook. However, if you want to view the live warnings as the daemon runs, run:

    easyjupyter --watch
    

Stop Daemon

  • The daemon process will terminate by itself, however, if you need to gracefully stop the background daemon process, run:

    easyjupyter --stop
    

VSC Pylance Intellisense Setup

VS Code's Pylance intellisense will not natively work with notebooks, or the hidden cache files generated for the notebooks. But you can tell it where to look for the cache files. Run one of the following commands in the root of your project:

  1. If you don't have a .vscode/settings.json file yet, run:

    mkdir -p .vscode && echo '{
        "python.analysis.extraPaths": [
            "./.easyJupyter_cache"
        ]
    }' > .vscode/settings.json
    
  2. If you already have a .vscode/settings.json file, add the following inside the {} brackets:

    "python.analysis.extraPaths": [
        "./.easyJupyter_cache"
    ]
    
  3. Make sure that in VSC you are selecting the environment that has EasyJupyter installed. For notebooks, VSC will prompt you to select the environment when you run a cell in a notebook. For .py files, you can manually select the environment in the bottom right corner of VSC.

Resolving Errors

If any issues occur with the watcher daemon, manually run it with: python -m EasyJupyter.watcher (note that this spawns the daemon in the foreground for debugging). If the daemon is already running in the background, you will need to delete the .easyJupyter_cache/watcher.pid file first.

You can always check the background daemon logs inside .easyJupyter_cache/watcher.log.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easyjupyter-0.1.6.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easyjupyter-0.1.6-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file easyjupyter-0.1.6.tar.gz.

File metadata

  • Download URL: easyjupyter-0.1.6.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for easyjupyter-0.1.6.tar.gz
Algorithm Hash digest
SHA256 b6cd5883ba082576fdca0cbc75a9c4c3163cf04bbbbf1b2ee2746d54982aaa34
MD5 88a34c55656a4888973d8f78ccded9fd
BLAKE2b-256 4807d2a6c199095e512b5a092e897298cac16993dccf50b1a6a17ce0c041f33b

See more details on using hashes here.

Provenance

The following attestation bundles were made for easyjupyter-0.1.6.tar.gz:

Publisher: release.yaml on t20e/EasyJupyter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file easyjupyter-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: easyjupyter-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for easyjupyter-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e2a386a7bd1f3c07af4966c4e4c4e11e33619865089502035491c91e3f13b3cc
MD5 cc3d9e008051a6076fd58b2c974a2d1c
BLAKE2b-256 8d131d73fe2e8206b04dfb57935034d3aa1cb864829f428017fcfd69620533fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for easyjupyter-0.1.6-py3-none-any.whl:

Publisher: release.yaml on t20e/EasyJupyter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page