API Reference
juplit
juplit.tasks
Core notebook workflow tasks for juplit.
These functions back both the poe task targets and the juplit CLI commands.
They can also be imported and called directly from Python.
sync_notebooks()
Sync .py and .ipynb files for all paired percent-format notebooks.
Walks the configured notebook_src_dirs (from [tool.juplit] in
pyproject.toml) and calls jupytext --sync on every .py file that has
a jupytext percent-format header pairing it with an .ipynb.
Prints a summary of updated, unchanged, and skipped files.
Raises SystemExit(1) if jupytext reports any errors.
Source code in juplit/tasks.py
generate_notebooks()
Generate .ipynb files from .py percent-format files.
Calls jupytext --to notebook on every paired .py file found in the
configured notebook_src_dirs. Use this after cloning a repo where only
the .py sources are committed.
Prints a summary of created/updated, unchanged, and skipped files.
Raises SystemExit(1) if jupytext reports any errors.
Source code in juplit/tasks.py
clean_notebooks()
Sync then delete all .ipynb files from the source directories.
First calls sync_notebooks() to flush any unsaved changes from the
.ipynb files back into their paired .py sources, then removes every
.ipynb found under notebook_src_dirs. Keeps the working directory
clean for AI agents and CI environments that only need the .py sources.
Prints a summary of removed files.
Source code in juplit/tasks.py
juplit.testing
test() helper — separates exportable logic from inline tests.
test()
Return True when the calling module is run directly or under pytest.
Use this to gate test code in percent-format notebook files so that tests run interactively (in Jupyter) and under pytest, but never on import.
Example::
# %%
from juplit import test
# %%
def add(a, b):
return a + b
# %%
if test():
assert add(1, 2) == 3