brentyi / tyro

CLI interfaces & config objects, from types
https://brentyi.github.io/tyro
MIT License
467 stars 23 forks source link

For boolean flags, confused on when to use "--no-*" pattern and when to "--flag True/False" pattern #140

Open chengluberkeley opened 4 months ago

chengluberkeley commented 4 months ago

Hello, I am reading the tyro documentation on the boolean flags: https://brentyi.github.io/tyro/examples/01_basics/05_flags/ and get confused. Because when I refer to Nerfstudio here: https://github.com/nerfstudio-project/nerfstudio/blob/main/nerfstudio/configs/base_config.py#L143, according to the documentation, since it has default value, it should have flags: --viewer.quit-on-train-completion and --viewer.no-quit-on-train-completion. But this one is translated in tyro to --viewer.quit-on-train-completion True/False. Do I miss something? Thanks.

brentyi commented 4 months ago

Hello!

The reason for this is that Nerfstudio types are often wrapped with tyro.conf.FlagConversionOff[]: https://github.com/search?q=repo%3Anerfstudio-project%2Fnerfstudio%20flagconversionoff&type=code

See here for an example: https://brentyi.github.io/tyro/examples/04_additional/07_conf/ Docs: https://brentyi.github.io/tyro/api/tyro/conf/#tyro.conf.FlagConversionOff