rbgirshick / yacs

YACS -- Yet Another Configuration System
Apache License 2.0
1.28k stars 90 forks source link

[Feature Request] Allow environment variables in yaml file #20

Closed Mengman closed 5 years ago

Mengman commented 5 years ago

I hope yacs can support use environment variable in yaml file.

for example

TRAIN:
    GPU_ID:${GPU:1}

GPU is the environment variable, if environment variable does not exist the value after colon 1 will be used.

rbgirshick commented 5 years ago

I suggest that in your code that uses yacs, you can load the relevant env variables and then use CfgNode.merge_from_list to make them override the default values. I think this does not need to be directly supported via a syntax extension. Example usage: https://github.com/rbgirshick/yacs/blob/master/yacs/tests.py#L314-L326.