networktocode/diffsync

_get_initial_value_order seems to be flawed

milan2655 opened this issue · 11 comments

Environment

  • DiffSync version: 1.7.0
  • Python version 3.10.6

Output of the method get_tree_traversal() doesn't show correct order.

NautobotAdapter
── site
│   ├── device
│   │   └── interface
│   │       └── aip_address
│── aip_address

if the ip_class doesn't start with "a", output ios ok.
 
NautobotAdapter
── site
│   ├── device
│   │   └── interface
│   │       └── ip_address

BR Milan

Can you show what your DiffSync class looks like?

class NautobotAdapter(DiffSync):
    site = Site
    device = Device
    interface = Interface
    aip_address = IpAddress

   top_level = ["site"]

Can you try to come up with a minimal reproduction of this issue (i.e. does it always occur when a model name start with a?) and post the code in this issue that does that? Then we can troubleshoot it quickly and easily. Thanks!

test.py.zip

hallo,
test file is attached. changing modelname from _modelname = "aip_address" to _modelname = "ip_address", change the output of the metod get_tree_traversal().
br milan

Your children are mapping to ip_address and not aip_address.

class Interface(DiffSyncModel):
    _children = {
        "ip_address": "ip_addresses",
    }

i have changed mapping to aip_address:

_children = {
    "aip_address": "ip_addresses",
}

and the output is not changed:

NautobotAdapter
├── site
│   └── device
│       └── interface
│           └── aip_address
└── aip_address

Please show the full output, the issues can only be shown then. The prior as an example had clear issues, perhaps there are new ones.

how do you mean full output?

I think I see the issue. I have updated the title. _get_initial_value_order seems to not take into consideration children beyond top level, so by the time it get's to children of children there is not a correct expectation of what order it should be processed in

did you fix the issue?

did you fix the issue?

No, the issue is not fixed at this time. However, do feel free to submit a PR with a fix!