Skip to content

Setting HydraConfig parameters in structured configs #2051

Answered by Jasha10
NickGeneva asked this question in Q&A
Discussion options

You must be logged in to vote

When figuring out how to write a structured config, it's sometimes productive to start with a yaml config and work backwards from there.
For example, suppose you want to produce a structured config that is equivalent to the following yaml:

hydra:
  run:
    dir: "sql_outputs/${hydra:job.override_dirname}/${hydra:job.name}"

The equivalent structured config should have a field called hydra with a default value given by the python dictionary {"run": {"dir": "sql_outputs/${hydra:job.override_dirname}/${hydra:job.name}"}}.
Thus, we have the following:

from dataclasses import dataclass, field

@dataclass
class Foo:
    hydra: Any = field(default_factory=lambda: {
        "run": {
            "dir"

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@NickGeneva
Comment options

@Jasha10
Comment options

Jasha10 Feb 25, 2022
Collaborator

Answer selected by NickGeneva
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement Enhanvement request
2 participants
Converted from issue

This discussion was converted from issue #2049 on February 23, 2022 09:29.