Skip to content

pre_executed directory is not excluded from pre-commit's sphinx-build #543

Closed

Description

@hombit

Reproducible example, it uses v2.0.7 because of #542

# Initialize a new project
copier copy gh:lincc-frameworks/python-project-template -r v2.0.7 new_project
## Select simple and and answer other questions 
cd new_project
python3 -mvenv ~/.virtualenvs/new_project && source ~/.virtualenvs/new_project/bin/activate
bash .initialize_new_project.sh

# Create a notebook which creates Hello.text file on run
python -m pip install jupytext
echo 'print("Hello, world!")' > hello_world.py
python -m jupytext --to ipynb --output docs/pre_executed/hello_world.ipynb hello_world.py
# Test that the does NOT exist
test -f Hello.text && exit 1
test -f docs/pre_executed/Hello.text && exit 1

# Commit and see that notebook has been run
git switch -c new-branch
git add docs/pre_executed/hello_world.ipynb
git commit -m "Hello"

# Fail appeared 
test -f docs/pre_executed/Hello.text && exit 1  # FAILS

Activity

  1. delucchi-cmu commented on Oct 8, 2025

    @delucchi-cmu
    Contributor

    As I understand, the notebook rendering tool will try to run a notebook if it doesn't have any output cells already. So the notebooks we'd typically have that are really pre-executed will have output cells. Those notebooks may also contain the following metadata block:

       "nbsphinx": {
        "execute": "never"
       },
    

    If you execute the notebook outside the pre-commit, delete the canary file, then attempt to run the pre-commit, will the notebook still be run and file created?

  2. self-assigned this
    on Jan 26, 2026
  3. delucchi-cmu commented on Jan 26, 2026

    @delucchi-cmu
    Contributor

    #549 will remove the sphinx-build stage entirely from pre-commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions