enhancementhelp wantedtab_completionwishlist
描述
🚀 Feature Request
Tab completion suggesting all possible options when trying to set an Enum type config.
Motivation
Minimal example to illustrate the issue:
# example.py
import hydra
from hydra.core.config_store import ConfigStore
from dataclasses import dataclass
from enum import Enum
class AnEnum(Enum):
OPTION_A = 1
OPTION_B = 2
@dataclass
class AppConfig:
an_enum_parameter: AnEnum = AnEnum.OPTION_A
# register config
cs = ConfigStore.instance()
cs.store(name="config", node=AppConfig)
@hydra.main(config_name="config")
def main(config: AppConfig):
pass
if __name__ == "__main__":
main()
With the above example, the tab completion only proposes the default option when trying to modify an_enum_parameter
python example.py an_enum_parameter=
# press TAB
python example.py an_enum_parameter=AnEnum.OPTION_A
Currently, one way to be aware of the available options is to enter an invalid option:
python example.py an_enum_parameter=INVALID
Error merging override an_enum_parameter=INVALID
Invalid value 'INVALID', expected one of [OPTION_A, OPTION_B]
full_key: an_enum_parameter
reference_type=Optional[AppConfig]
object_type=AppConfig
Pitch
It would be great for hydra to suggest all possible values the same way it does for group config:
python example.py an_enum_parameter=
# press TAB
an_enum_parameter=AnEnum.OPTION_A an_enum_parameter=AnEnum.OPTION_B