Skip to content

Ignoring diffs does not work #774

Closed
Closed
@physkets

Description

The following is the config I am trying to use in order for nbdime to ignore certain metadata as well as outputs for the purpose of displaying diffs under git diff and to prevent any data in there from being committed.

$ cat ~/.jupyter/nbdime_config.json
{
  "Diff": {
    "ignore": [
      "/metadata/papermill",
      "/cells/*/metadata/papermill",
      "/cells/*/metadata/execution",
      "/cells/*/execution_count",
      "/cells/*/outputs"
    ]
  },
  "Merge": {
    "ignore": [
      "/metadata/papermill",
      "/cells/*/metadata/papermill",
      "/cells/*/metadata/execution",
      "/cells/*/execution_count",
      "/cells/*/outputs"
    ]
  }
}

When I verify it, I see:

$ nbdime --config
All available config options, and their current values:

NbDiff:
  Ignore: {}
  attachments: <unset, resolves to true>
  color_words: false
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  ignore: ["/metadata/papermill", "/cells/*/metadata/papermill", "/cells/*/metadata/execution", "/cells/*/execution_count", "/cells/*/outputs"]
  metadata: <unset, resolves to true>
  outputs: <unset, resolves to true>
  sources: <unset, resolves to true>

NbDiffWeb:
  Ignore: {}
  attachments: <unset, resolves to true>
  base_url: "/"
  browser: null
  color_words: false
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  ignore: ["/metadata/papermill", "/cells/*/metadata/papermill", "/cells/*/metadata/execution", "/cells/*/execution_count", "/cells/*/outputs"]
  ip: "127.0.0.1"
  metadata: <unset, resolves to true>
  outputs: <unset, resolves to true>
  persist: false
  port: 0
  sources: <unset, resolves to true>
  workdirectory: "/home/user/Programs/Gels"

NbMerge:
  Ignore: {}
  attachments: <unset, resolves to true>
  color_words: false
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  ignore: ["/metadata/papermill", "/cells/*/metadata/papermill", "/cells/*/metadata/execution", "/cells/*/execution_count", "/cells/*/outputs"]
  ignore_transients: true
  input_strategy: null
  merge_strategy: "inline"
  metadata: <unset, resolves to true>
  output_strategy: null
  outputs: <unset, resolves to true>
  sources: <unset, resolves to true>

NbMergeWeb:
  Ignore: {}
  attachments: <unset, resolves to true>
  base_url: "/"
  browser: null
  color_words: false
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  ignore: ["/metadata/papermill", "/cells/*/metadata/papermill", "/cells/*/metadata/execution", "/cells/*/execution_count", "/cells/*/outputs"]
  ignore_transients: true
  input_strategy: null
  ip: "127.0.0.1"
  merge_strategy: "inline"
  metadata: <unset, resolves to true>
  output_strategy: null
  outputs: <unset, resolves to true>
  persist: false
  port: 0
  show_base: true
  sources: <unset, resolves to true>
  workdirectory: "/home/user/Programs/Gels"

NbShow:
  Ignore: {}
  attachments: <unset, resolves to true>
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  metadata: <unset, resolves to true>
  outputs: <unset, resolves to true>
  sources: <unset, resolves to true>

Server:
  base_url: "/"
  browser: null
  ip: "127.0.0.1"
  persist: false
  port: 8888
  workdirectory: "/home/user/Programs/Gels"

Extension:
  Ignore: {}
  attachments: <unset, resolves to true>
  color_words: false
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  ignore: ["/metadata/papermill", "/cells/*/metadata/papermill", "/cells/*/metadata/execution", "/cells/*/execution_count", "/cells/*/outputs"]
  metadata: <unset, resolves to true>
  outputs: <unset, resolves to true>
  sources: <unset, resolves to true>

NbDiffDriver:
  Ignore: {}
  attachments: <unset, resolves to true>
  color_words: false
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  ignore: ["/metadata/papermill", "/cells/*/metadata/papermill", "/cells/*/metadata/execution", "/cells/*/execution_count", "/cells/*/outputs"]
  metadata: <unset, resolves to true>
  outputs: <unset, resolves to true>
  sources: <unset, resolves to true>

NbDiffTool:
  Ignore: {}
  attachments: <unset, resolves to true>
  base_url: "/"
  browser: null
  color_words: false
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  ignore: ["/metadata/papermill", "/cells/*/metadata/papermill", "/cells/*/metadata/execution", "/cells/*/execution_count", "/cells/*/outputs"]
  ip: "127.0.0.1"
  metadata: <unset, resolves to true>
  outputs: <unset, resolves to true>
  persist: false
  port: 0
  sources: <unset, resolves to true>
  workdirectory: "/home/user/Programs/Gels"

NbMergeDriver:
  Ignore: {}
  attachments: <unset, resolves to true>
  color_words: false
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  ignore: ["/metadata/papermill", "/cells/*/metadata/papermill", "/cells/*/metadata/execution", "/cells/*/execution_count", "/cells/*/outputs"]
  ignore_transients: true
  input_strategy: null
  merge_strategy: "inline"
  metadata: <unset, resolves to true>
  output_strategy: null
  outputs: <unset, resolves to true>
  sources: <unset, resolves to true>

NbMergeTool:
  Ignore: {}
  attachments: <unset, resolves to true>
  base_url: "/"
  browser: null
  color_words: false
  details: <unset, resolves to true>
  id: <unset, resolves to true>
  ignore: ["/metadata/papermill", "/cells/*/metadata/papermill", "/cells/*/metadata/execution", "/cells/*/execution_count", "/cells/*/outputs"]
  ignore_transients: true
  input_strategy: null
  ip: "127.0.0.1"
  merge_strategy: "inline"
  metadata: <unset, resolves to true>
  output_strategy: null
  outputs: <unset, resolves to true>
  persist: false
  port: 0
  sources: <unset, resolves to true>
  workdirectory: "/home/user/Programs/Gels"

which tells me that the configuration was successfully applied.

However, when I look at a git diff, I still see all the metadata begin diffed.

When I use nbdime directly for the diff, with the config file specified, I get the following error:

$ nbdime diff --config /home/user/.jupyter/nbdime_config.json path/to/notebook.ipynb
Traceback (most recent call last):
  File "/usr/bin/nbdime", line 8, in <module>
    sys.exit(main_dispatch())
             ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/nbdime/__main__.py", line 135, in main_dispatch
    return main(args)
           ^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/nbdime/nbdiffapp.py", line 129, in main
    arguments = _build_arg_parser().parse_args(args)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/argparse.py", line 1896, in parse_args
    args, argv = self.parse_known_args(args, namespace)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/nbdime/args.py", line 35, in parse_known_args
    return super(ConfigBackedParser, self).parse_known_args(args=args, namespace=namespace)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/argparse.py", line 1932, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/argparse.py", line 2153, in _parse_known_args
    start_index = consume_optional(start_index)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/argparse.py", line 2093, in consume_optional
    take_action(action, args, option_string)
  File "/usr/lib/python3.12/argparse.py", line 2008, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/lib/python3.12/site-packages/nbdime/args.py", line 117, in __call__
    header = entrypoint_configurables[parser.prog].__name__
             ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
KeyError: 'nbdime'

Is this a bug with nbdime or am I doing something wrong?

Activity

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions