Deepdiff not ignoring order when passing ignore_order

584 Views Asked by At

I have two dictionaries:

#1

{"reg2/image2:0.1": {
"binaries": {
  "/bin/xyz": {
    "components": [
      "d",
      "aa",
      "new",
      "git.example.com/wayform-chassis/xyzserver-v0.25.3"
    ],
    "md5": "8bf54c95f9"
  }
},
"loose_packages": []}

#2

  "reg2/image2:0.2": {
"binaries": {
  "/bin/xyz": {
    "components": [
      "c",
      "git.example.com/wayform-chassis/xyzserver-v0.25.2",
      "aa",
      "asdhkjahsd"
    ],
    "md5": "f78f65f31"
  }
},
"loose_packages": ["test package"]}

With the following command: ddiff = deepdiff.DeepDiff(data_a, data_b, ignore_order=True, get_deep_distance=True)

My result is:

    reg2/image2: {
  "values_changed": {
    "root['binaries']['/bin/xyz']['md5']": {
      "new_value": "8bf54c95f9",
      "old_value": "f78f65f31"
    },
    "root['binaries']['/bin/xyz']['components'][3]": {
      "new_value": "git.example.com/wayform-chassis/xyzserver-v0.25.3",
      "old_value": "asdhkjahsd"
    },
    "root['binaries']['/bin/xyz']['components'][0]": {
      "new_value": "d",
      "old_value": "c"
    }
  },
  "iterable_item_added": {
    "root['binaries']['/bin/xyz']['components'][2]": "new"
  },
  "iterable_item_removed": {
    "root['binaries']['/bin/xyz']['components'][1]": "git.example.com/wayform-chassis/xyzserver-v0.25.2",
    "root['loose_packages'][0]": "test package"
  },
  "deep_distance": 0.25806451612903225
}

This is incorrect, or at least not how I want to present the result. it should not report that the value changed based on order, see how it says:

"root['binaries']['/bin/xyz']['components'][3]": {
  "new_value": "git.example.com/wayform-chassis/xyzserver-v0.25.3",
  "old_value": "asdhkjahsd"

I should instead see:

"root['binaries']['/bin/xyz']['components'][3]": {
  "new_value": "git.example.com/wayform-chassis/xyzserver-v0.25.3",
  "old_value": "git.example.com/wayform-chassis/xyzserver-v0.25.2"

Or at least:

"iterable_item_added": {
    "root['binaries']['/bin/xyz']['components'][3]": "git.example.com/wayform-chassis/xyzserver-v0.25.3"

"iterable_item_removed": {
    "root['binaries']['/bin/xyz']['components'][1]": "git.example.com/wayform-chassis/xyzserver-v0.25.2"

As you can see its saying the new value of the location changed, when I thought with my ignore order argument, its supposed to do just that, ignore the order and just report on the diffs?

If that is not achievable with deepdiff, What is a better way to get to the desired result?

0

There are 0 best solutions below