roy-ht / pre-commit-jupyter

Clean up cell outputs of jupyter notebook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failes with json.decode Expecting ',' error

richtong opened this issue · comments

Just trying it out. I used the default configuration

  - repo: https://github.com/aflc/pre-commit-jupyter
  ¦ rev: v1.1.0
  ¦ hooks:
  ¦ ¦ - id: jupyter-notebook-cleanup
  ¦ ¦ ¦ args:
  ¦ ¦ ¦ ¦ - --remove-kernel-metadata
  ¦ ¦ ¦ ¦ - --pin-patterns
  ¦ ¦ ¦ ¦ - "[pin];[donotremove]"
  ¦ ¦ ¦ files: \.ipynb$
  ¦ ¦ ¦ types: ["file"]

Judging by the output it's the cleanup line in remove_output_file.

 File "/Users/rich/.cache/pre-commit/repotx7s5n95/py_env-python3/lib/python3.8/site-packages/jupyter_notebook_cleanup/cli.py", line 27, in main
    remove_output_file(
  File "/Users/rich/.cache/pre-commit/repotx7s5n95/py_env-python3/lib/python3.8/site-packages/jupyter_notebook_cleanup/cli.py", line 49, in remove_output_file
    data = json.load(f, object_pairs_hook=OrderedDict)

Thank you for your report!

I'll look into this weekend.

I slightly modified the code.

So would you try it with below settings?
(repo name is different because i changed my username, but old one still be available)

Thanks!

default_stages: [commit, push]
fail_fast: true
repos:
  - repo: https://github.com/roy-ht/pre-commit-jupyter
    rev: specify-default-encoding
    hooks:
      - id: jupyter-notebook-cleanup
        args:
          - --remove-kernel-metadata
          - --pin-patterns
          - "[pin];[donotremove]"