I'm migrating to tyro from Hydra, and after spending a lot of time reading through issues + docs, I still can't figure out the recommended way to specialize.
Specifically, in Hydra's docs, they go over specializing on dataset + model which is a fairly common pattern. Currently I have the following:
@dataclass
class Config:
"""Main configuration for train-bp script."""
data: ALL_DATA_CFGS = field(default_factory=MNISTConfig)
optimizer: ALL_OPT_CFGS = field(default_factory=lambda: SGDConfig(learning_rate=0.01))
logger: ALL_LOGGER_CFGS = field(default_factory=lambda: WandbLoggerConfig())
model: ALL_MODEL_CFGS = field(default_factory=ConditionedMLPConfig)
If isinstance(cfg.model, CNNConfig) and isinstance(cfg.data, MNISTConfig), then I want to do things like set cfg.optimizer.learning_rate to specific value, etc. Currently, I tried to do this in __post_init__, but this clearly seems like the wrong place. Namely, I might have something like cfg.model.features that is unknown until the dataset is specified, but overwriting this in __post_init__ does not help since tyro flags it as a missing argument that's required.
I'm migrating to tyro from Hydra, and after spending a lot of time reading through issues + docs, I still can't figure out the recommended way to specialize.
Specifically, in Hydra's docs, they go over specializing on dataset + model which is a fairly common pattern. Currently I have the following:
If
isinstance(cfg.model, CNNConfig)andisinstance(cfg.data, MNISTConfig), then I want to do things like setcfg.optimizer.learning_rateto specific value, etc. Currently, I tried to do this in__post_init__, but this clearly seems like the wrong place. Namely, I might have something likecfg.model.featuresthat is unknown until the dataset is specified, but overwriting this in__post_init__does not help since tyro flags it as a missing argument that's required.