google / google/ml_collections

ml_collections / absl -- cannot read config updates from --flagfile

Open
#20 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
1k
Forks
49
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When using `config_flags.DEFINE_config_dict` we are unable to use `--flagfile` to override values, we get the error:

```bash
FATAL Flags parsing error: Unknown command line flag ...
```

**To Reproduce**

```python
# test.py

from absl import app, flags
from ml_collections import config_dict, config_flags

import copy

CONFIG = config_dict.ConfigDict(
{
'animal': {
'cat': 10,
'dog': 20
},
'vehicle': {
'car': 30,
'train': 40
}
}
)

FLAGS = flags.FLAGS
# _CONFIG = config_flags.DEFINE_config_dict('config', copy.deepcopy(CONFIG))
_CONFIG = config_flags.DEFINE_config_dict('config', CONFIG)

def main(_):

print(FLAGS.config)

if __name__ == '__main__':
app.run(main)
```

```text
# flagfile.txt
--config.animal.cat=5000
```

```bash
$ python test.py --flagfile=flagfile.txt

FATAL Flags parsing error: Unknown command line flag 'config.animal.cat'
Pass --helpshort or --helpfull to see help on flags.
```

**Expected behavior**
`absl` should be able to read the changes to config from the `flagfile.txt`, something is going wrong here.

**Environment:**
- OS: MacOS
- OS Version: macOS Venture (13.0)
- Python: 3.10.0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.