{"id":46178502,"url":"https://github.com/cmhac/enforce-notebook-run-order","last_synced_at":"2026-03-02T19:37:57.079Z","repository":{"id":171104472,"uuid":"647361880","full_name":"cmhac/enforce-notebook-run-order","owner":"cmhac","description":"Pre-commit hook to force Jupyter notebooks to be run in the correct order","archived":false,"fork":false,"pushed_at":"2025-11-17T17:48:43.000Z","size":1894,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-17T18:21:41.143Z","etag":null,"topics":["data-science","jupyter-notebooks","pre-commit"],"latest_commit_sha":null,"homepage":"https://cmhac.github.io/enforce-notebook-run-order/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmhac.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2023-05-30T16:01:30.000Z","updated_at":"2025-11-17T17:48:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9c361eb-dfe4-4847-9ecb-2434b1a77f85","html_url":"https://github.com/cmhac/enforce-notebook-run-order","commit_stats":null,"previous_names":["christopher-hacker/enforce-notebook-run-order","cmhac/enforce-notebook-run-order"],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/cmhac/enforce-notebook-run-order","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmhac%2Fenforce-notebook-run-order","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmhac%2Fenforce-notebook-run-order/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmhac%2Fenforce-notebook-run-order/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmhac%2Fenforce-notebook-run-order/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmhac","download_url":"https://codeload.github.com/cmhac/enforce-notebook-run-order/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmhac%2Fenforce-notebook-run-order/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30016547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T17:00:27.440Z","status":"ssl_error","status_checked_at":"2026-03-02T17:00:03.402Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","jupyter-notebooks","pre-commit"],"created_at":"2026-03-02T19:37:53.882Z","updated_at":"2026-03-02T19:37:57.060Z","avatar_url":"https://github.com/cmhac.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"left\"\u003e\n \u003ca href=\"https://badge.fury.io/py/enforce-notebook-run-order\"\u003e\n   \u003cimg src=\"https://badge.fury.io/py/enforce-notebook-run-order@2x.png\" alt=\"PyPI version\" height=\"20\"\u003e\n \u003c/a\u003e\n \u003ca href=\"https://codecov.io/gh/cmhac/enforce-notebook-run-order\" \u003e \n   \u003cimg src=\"https://codecov.io/gh/cmhac/enforce-notebook-run-order/branch/main/graph/badge.svg?token=019MXVQYN5\"/\u003e \n \u003c/a\u003e\n  \u003ca href=\"https://github.com/cmhac/enforce-notebook-run-order/actions/workflows/test.yaml\"\u003e\n    \u003cimg src=\"https://github.com/cmhac/enforce-notebook-run-order/actions/workflows/test.yaml/badge.svg\" alt=\"Run tests\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/cmhac/enforce-notebook-run-order/actions/workflows/publish-pypi.yaml\"\u003e\n    \u003cimg src=\"https://github.com/cmhac/enforce-notebook-run-order/actions/workflows/publish-pypi.yaml/badge.svg\" alt=\"Publish to PyPi\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/cmhac/enforce-notebook-run-order/actions/workflows/docs.yml\"\u003e\n   \u003cimg src=\"https://github.com/cmhac/enforce-notebook-run-order/actions/workflows/docs.yml/badge.svg\" alt=\"Build docs\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# enforce-notebook-run-order\n\nEnforce the run order of Jupyter notebooks.\n\nJupyter notebooks are great for interactive data analysis. However, they\ncan encourage a bad habit: running cells out of order. This can lead to\nnotebooks being committed to the repository in a state where they don\\'t\nrun from top to bottom, and other collaborators may receive different\nresults when trying to reproduce the analysis.\n\n`enforce-notebook-run-order` attempts to fix this by raising an\nexception before each commit if any cells are run out of order.\n\n## Language Support\n\nThis tool works with **all Jupyter notebook kernels**, including:\n\n- **Python** (IPython)\n- **R** (IRkernel)\n- **Julia**\n- **Scala**, **Java**, **C++**, and many others\n\nAny language kernel that produces standard `.ipynb` files with\n`execution_count` metadata is supported. The tool is language-agnostic\nand only inspects the notebook\\'s execution order metadata.\n\n## Validation Requirements\n\nFor a notebook to be considered valid, it must meet the following\nrequirements:\n\n- **All non-empty code cells must be executed**: Each code cell with\n  content must have an `execution_count` value (not `None`).\n- **Execution must start from 1**: The first non-empty code cell must\n  have `execution_count=1`.\n- **No gaps in execution sequence**: Execution counts must be strictly\n  sequential (1, 2, 3, \\...) with no skipped numbers.\n\n**Examples:**\n\n- ✅ **Valid**: Cells with execution counts `1, 2, 3, 4`\n- ❌ **Invalid**: Cells starting with `0, 1, 2` (must start from 1)\n- ❌ **Invalid**: Cells starting with `2, 3, 4` (must start from 1)\n- ❌ **Invalid**: Cells with `1, 2, 4, 5` (gap at 3)\n- ❌ **Invalid**: Cells with `1, 3, 2` (not sequential)\n- ❌ **Invalid**: Cells with `1, 2, None` (unexecuted cell)\n\n**Note**: Empty code cells (cells with no content) are ignored and do\nnot need to be executed.\n\n## Usage\n\n`enforce-notebook-run-order` is designed to work primarily as a\n[pre-commit hook](https://pre-commit.com/), but can also be used as a\nstandalone script when needed.\n\n### pre-commit hook (Recommended)\n\nThe intended way to use `enforce-notebook-run-order` is as a pre-commit\nhook to automatically validate notebook execution order before each\ncommit.\n\nTo set it up, add the following to your `.pre-commit-config.yaml`:\n\n``` yaml\nrepos:\n-   repo: https://github.com/cmhac/enforce-notebook-run-order\n    rev: \u003creplace with latest version from https://github.com/cmhac/enforce-notebook-run-order/releases/\u003e\n    hooks:\n    -   id: enforce-notebook-run-order\n```\n\nThis will automatically check all notebooks in your repository before\neach commit, preventing out-of-order execution from being committed to\nyour repository.\n\n### Standalone\n\nFor manual validation or CI integration, `enforce-notebook-run-order`\ncan be used as a standalone script.\n\nFirst, install it the same way you install other Python packages, such\nas:\n\n``` bash\npip install enforce-notebook-run-order\n```\n\nRun it with the path to the notebook(s) you want to check:\n\n``` bash\nnbcheck my_notebook.ipynb my_other_notebook.ipynb\n```\n\nOr point it to a directory to check all notebooks in that directory:\n\n``` bash\nnbcheck my_notebooks/\n```\n\nIf no paths are specified, `nbcheck` will check all notebooks in the\ncurrent directory.\n\nYou can also use the full `enforce-notebook-run-order` command, but the\n`nbcheck` command is provided as a convenience.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmhac%2Fenforce-notebook-run-order","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmhac%2Fenforce-notebook-run-order","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmhac%2Fenforce-notebook-run-order/lists"}