Hydra: [Bug] value interpolation does not work in list

Created on 3 Nov 2019  路  6Comments  路  Source: facebookresearch/hydra

Value interpolation does not seem to work in list e.g.:

chckpnt_dirnames: 
  - ${base_dir}/${model.name}/
  - .

Doesn't replace model.name and base_dir

bug

All 6 comments

Please provide a complete working example that reproduces that. I was not able to reproduce.

config.yaml:

test1: first
test2: second
tests:
  - ${test1}/${test2}
  - ${test1}

main.py:

@hydra.main(config_path="config.yaml")
def main(args):
    print(args.test1)
    print(args.test2)
    print(args.tests)

out:

first
second
['${test1}/${test2}', '${test1}']

Mhhh it actually works but I was thinking of it as a real list:

print(args.tests)
print(list(args.tests))
print([i for i in args.tests])
print([args.tests[0], args.tests[1]])
print([args.tests[i] for i in range(len(args.tests))])

out:

['${test1}/${test2}', '${test1}']
['${test1}/${test2}', '${test1}']
['${test1}/${test2}', '${test1}']
['first/second', 'first']
['first/second', 'first']

If you are converting to a list this is no longer an OmegaConf object.

The proper way to convert to a primitive list is to use:
resolved_list = args.tests.to_container(resolve=True)

Also, why do you even need to convert it to a primitive list?

Because I'm logging it and wanted to see the interpolated strings (which didn't work when just logging the OmegaConf object)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ImMrMa picture ImMrMa  路  4Comments

lkhphuc picture lkhphuc  路  3Comments

SunQpark picture SunQpark  路  4Comments

jan-matthis picture jan-matthis  路  3Comments

natolambert picture natolambert  路  4Comments