dbbs-lab / bsb-core

The Brain Scaffold Builder
https://bsb.readthedocs.io
GNU General Public License v3.0
22 stars 16 forks source link

Merging dictionaries breaks referrencing. #848

Closed drodarie closed 5 months ago

drodarie commented 5 months ago
cell_types:
  $import:
    ref: ref2.yaml#/cell_types
    values:
      - my_cell
$import:
  ref: ref1.yaml#/
  values:
    - cell_types
    - placement
    - connectivity

This configuration should first import the cell_types dict from ref1.yaml and then be merged the imported my_cell of ref2.yaml The sub files are correctly imported but the first merge with ref1 overrides the cell_types dictionary reference that is used by ref2. Hence, when the dict from ref2 is merged with the root, the final cell_types dictionary looks like this:

cell_types:
  cell_type_from_ref1: 
    [...]
  $import:
    ref: ref2.yaml#/cell_types
    values:
      - my_cell

The function merge from each type should return the original instance of the node to prevent reference errors.