Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5060

How to dump a hydra config into yaml with `_target_` fields

$
0
0

I instantiate a hydra configuration from a python dataclass. For example

from dataclasses import dataclassfrom typing import Anyfrom hydra.utils import instantiateclass Model():    def __init__(self, x=1):        self.x = x@dataclassclass MyConfig:    model: Any    param: intstatic_config = MyConfig(model=Model(x=2), param='whatever')instantiated_config = instantiate(static_config)

Now, I would like to dump this configuration as a yaml, including the _target_ fields that Hydra uses to re-instantiate the objects pointed to inside the configuration. I would like to avoid having to write my own logic to write those _target_ fields, and I imagine there must be some hydra utility that does this, but I can't seem to find it in the documentation.


Viewing all articles
Browse latest Browse all 5060


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>