make x_enabled compulsory

Summary: Optional[some_configurable] won't autogenerate the enabled flag

Reviewed By: shapovalov

Differential Revision: D41522104

fbshipit-source-id: 555ff6b343faf6f18aad2f92fbb7c341f5e991c6
This commit is contained in:
Jeremy Reizenstein
2022-11-24 09:38:02 -08:00
committed by Facebook GitHub Bot
parent 1706eb8216
commit 60ab1cdb72
2 changed files with 10 additions and 5 deletions

View File

@@ -446,6 +446,7 @@ class TestConfig(unittest.TestCase):
b2: Optional[B]
b3: Optional[B]
b2_enabled: bool = True
b3_enabled: bool = False
def __post_init__(self):
run_auto_creation(self)
@@ -681,9 +682,10 @@ class TestConfig(unittest.TestCase):
def test_remove_unused_components_optional(self):
class MainTestWrapper(Configurable):
mt: Optional[MainTest]
mt_enabled: bool = False
args = get_default_args(MainTestWrapper)
self.assertEqual(list(args.keys()), ["mt_args", "mt_enabled"])
self.assertEqual(list(args.keys()), ["mt_enabled", "mt_args"])
remove_unused_components(args)
self.assertEqual(OmegaConf.to_yaml(args), "mt_enabled: false\n")
@@ -775,6 +777,7 @@ class TestConfig(unittest.TestCase):
boring_o: Optional[BoringConfigurable]
boring_o_enabled: bool = True
boring_0: Optional[BoringConfigurable]
boring_0_enabled: bool = False
def __post_init__(self):
run_auto_creation(self)