From e87c540a6f3d0cbaf5a21ab64fc873f3fedaa9e3 Mon Sep 17 00:00:00 2001 From: ROUVREAU Vincent <vincent.rouvreau@inria.fr> Date: Mon, 26 Feb 2024 09:14:18 +0100 Subject: [PATCH] give a try to notebook stripout --- .pre-commit-config.yaml | 5 +++++ CONTRIBUTING.md | 5 ++--- Scripts/pre-commit | 14 -------------- environment.yml | 1 - 4 files changed, 7 insertions(+), 18 deletions(-) create mode 100644 .pre-commit-config.yaml delete mode 100755 Scripts/pre-commit diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..d60debf --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,5 @@ +repos: +- repo: https://github.com/kynan/nbstripout + rev: 0.7.1 + hooks: + - id: nbstripout diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b38464b..5ce119e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,13 +7,12 @@ All contributions are welcome, but please read this first. If you intend to contribute, please install first the pre-commit hook: ```shell -cp Scripts/pre-commit .git/hooks/pre-commit +conda install -c conda-forge pre-commit # or pip install pre-commit +pre-commit install ``` This hook clears executed cells when committing a notebook. -You need [nbconvert](https://nbconvert.readthedocs.io/en/latest/) to be installed for this pre-commit hook to work properly; it is done automatically if you're using the provided miniconda environment. - ## Workflow diff --git a/Scripts/pre-commit b/Scripts/pre-commit deleted file mode 100755 index 378e760..0000000 --- a/Scripts/pre-commit +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# This file is expected to be use as pre-commit git hook; copy it in .git/hooks/ - -file_list=`git diff --cached --diff-filter=ACM --name-only` - -for file in ${file_list} -do - if [ "${file##*.}" = "ipynb" ]; then - echo "Clear cells from ${file}" - jupyter nbconvert --clear-output --inplace ${file} - git add ${file} - fi -done diff --git a/environment.yml b/environment.yml index 1cd2f92..a1c0be0 100644 --- a/environment.yml +++ b/environment.yml @@ -4,4 +4,3 @@ channels: dependencies: - jupyterlab - xeus-cling - - nbconvert -- GitLab