adobe / himl

A hierarchical yaml config in Python

Home Page:https://pypi.org/project/himl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Select among multiple .yaml files

Revaapriyan opened this issue · comments

Consider a config folder structure as below

configs
├─ prod
│   |─ zone1.yaml
│   └─ zone2.yaml
└─ default.yaml

default.yaml contains

path:
    parent: data
    result_path: "{{path.parent}}/{{zone.name}}/{{path.exp_name}}"

prod/zone1.yaml

zone:
   name: zone_A
path:
    exp_name : exp1

prod/zone2.yaml

zone:
   name: zone_B
path:
    exp_name : test
run:
    description: "testing himl"

code snippet:

from himl import ConfigProcessor
config = ConfigProcessor().process(path='configs/prod', print_data=True)

Expected Behaviour

default.yaml has default configurations that will be overridden by any of the selected zone configurations. An error to ask to chose between zone1.yaml and zone2.yaml files.

Actual Behaviour

the code resulted in merging the files by itself and provides the following as output.

path:
  exp_name: test
  parent: data
  result_path: data/zone_B/test
zone:
  name: zone_B
run:
  description: testing himl

Platform and Version

Platform: Ubuntu 20.04 LTS
himl version: v0.7.1

Hi @Revaapriyan, this is a good case where you can achieve this by adding another level in the hierarchy. This way you can give the specific paths you want deep merge and get a deterministic output.
It's expected to have all files deep merged at a given level, in alphabetical order.
To avoid unexpected outputs we might considering an option to error out, but a manual prompt it's not the way to go for automation.

@danielcoman Thanks.

configs
├─ prod
│   |─ zone1
│        |─ zone1.yaml
│   |─ zone2
│        |─ zone2.yaml
└─ default.yaml

This works as needed.