omry / omegaconf

Flexible Python configuration system. The last one you will ever need.
BSD 3-Clause "New" or "Revised" License
1.91k stars 104 forks source link

Make flow style of yaml dump configurable #1075

Open mdraw opened 1 year ago

mdraw commented 1 year ago

Dumping yaml with the currently hardcoded default_flow_style=False setting results in sometimes less than optimal string representations. Example output of OmegaConf.to_yaml(cfg):

nhood:
- - -1
  - 0
  - 0
- - 0
  - -1
  - 0
- - 0
  - 0
  - -1

After the proposed change you can use OmegaConf.to_yaml(cfg, default_flow_style=None) to get this output instead:

nhood:
- [-1, 0, 0]
- [0, -1, 0]
- [0, 0, -1]
omry commented 1 year ago

Hi @mdraw, This is nice. Can you add a some basic testing and make sure everything passes (you may need to rebase).