-
|
(I'm very new to hydra and hydra-zen, and cannot quite wrap my head around it) python run.py task=train train.lr=0.01
python run.py task=eval eval.model_path=model.pthI understand, I could do something like: from dataclasses import dataclass, field
from hydra_zen import ZenStore, zen
@dataclass
class TrainConfig:
lr: float = 0.01
num_epochs: int = 5
batch_size: int = 32
@dataclass
class EvalConfig:
model_path: str = "model.pth"
batch_size: int = 16
@dataclass
class MainConfig:
task = "train"
train: TrainConfig = field(default_factory=TrainConfig)
eval: EvalConfig = field(default_factory=EvalConfig)
# def main(cfg: MainConfig) -> None:
# print(OmegaConf.to_yaml(cfg))
def main_fn(task: str, train: TrainConfig, eval: EvalConfig) -> None:
print(OmegaConf.to_yaml(cfg))
store = ZenStore()
store(MainConfig, name="main")
if __name__ == "__main__":
store.add_to_hydra_store()
zen(main_fn).hydra_main(
config_name="main",
config_path=None,
version_base="1.3",
)to call |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
What you are asking for is Hydra's default behavior; just use But note that it is typically better design to have your function deal not with configs but the objects that are instantiated from those configs. That is the main differentiating factor of hydra-zen apps vs Hydra apps. |
Beta Was this translation helpful? Give feedback.
What you are asking for is Hydra's default behavior; just use
hydra.maininstead ofzen.But note that it is typically better design to have your function deal not with configs but the objects that are instantiated from those configs. That is the main differentiating factor of hydra-zen apps vs Hydra apps.