Questions about Hydra, an open source Python framework by Facebook
Questions tagged [fb-hydra]
182 questions
37
votes
5 answers
How to get a Hydra config without using @hydra.main()
Let's say we have following setup (copied & shortened from the Hydra docs):
Configuration file: config.yaml
db:
driver: mysql
user: omry
pass: secret
Python file: my_app.py
import hydra
@hydra.main(config_path="config.yaml")
def my_app(cfg):
…

flawr
- 10,814
- 3
- 41
- 71
13
votes
2 answers
Convert hydra/omegaconf config to python nested dict/list?
I'd like to convert a OmegaConf/Hydra config to a nested dictionary/list. How can I do this?

Rylan Schaeffer
- 1,945
- 2
- 28
- 50
13
votes
1 answer
Create a new key in hydra DictConfig from python file
I'd like to add a key + value after my Hydra Config is loaded. Essentially I want to run my code and check if a gpu is available or not. If it is, log the device as gpu, else keep the cpu.
Essentially saving the output of…

universvm
- 353
- 2
- 11
8
votes
3 answers
How to override hydra working dir from within a script?
I know that I can change the working dir in config by setting hydra.run.dir=XXX from the command line.
But how to do it properly from script w/o using CLI arguments in a way that even the logs are saved in the dir which I set?
This code won't work…

Temak
- 2,929
- 36
- 49
6
votes
2 answers
Is it possible to use Pydantic instead of dataclasses in Structured Configs in hydra-core python package?
Recently I have started to use hydra to manage the configs in my application. I use Structured Configs to create schema for .yaml config files. Structured Configs in Hyda uses dataclasses for type checking. However, I also want to use some kind of…

Kıvanç Yüksel
- 701
- 7
- 17
5
votes
2 answers
What is the correct way of accessing Hydra's current output directory?
Assuming I prevent Hydra from changing the current working directory, how can I still retrieve the job's output directory (i.e., the folder Hydra created for storing the results of the particular job) from main()?
Ideally, I'd like a method that…

Trisoloriansunscreen
- 1,543
- 1
- 15
- 27
5
votes
1 answer
Hydra: access name of config file from code
I have a config tree such as:
config.yaml
model/
model_a.yaml
model_b.yaml
model_c.yaml
Where config.yaml contains:
# @package _global_
defaults:
- _self_
- model: model_a.yaml
some_var: 42
I would like to access the name of the model…

miccio
- 133
- 1
- 10
5
votes
1 answer
Specializing a Hydra configuration with Explicit Nesting
I would like to have:
conf/
├── config.yaml
├── data
│ └── data.yaml
├── render
│ └── renderer.yaml
├── storage
│ └── local.yaml
└── text
├── font.yaml
└── regions.yaml
Where, in the config.yaml, the text/font.yaml assigned to font…

Índio
- 539
- 5
- 12
5
votes
1 answer
fb-hydra: How to get inner configurations to inherit outer configuration fields?
I am trying to write a hierarchical configuration structure such that config files in the inner directories inherit from the config files in the outer directories. For example, in the following scenario
upper_config
|
|-middle_config
| |
| …

Mike
- 444
- 1
- 8
- 19
5
votes
1 answer
How to load Hydra parameters from previous jobs (without having to use argparse and the compose API)?
I'm using Hydra for training machine learning models. It's great for doing complex commands like python train.py data=MNIST batch_size=64 loss=l2. However, if I want to then run the trained model with the same parameters, I have to do something like…

Rachel
- 53
- 3
4
votes
2 answers
What are Hydra advantages vs using a regular configuration file
I wonder what are the advantages of using Hydra to manage my configuration files,
versus loading .yaml configuration file directly (using import yaml)?

Ilan Geffen
- 179
- 8
4
votes
1 answer
Hydra multirun all permutations in parallel
I am trying to find the very best configuration of hiperparameters for my LSTM using HYDRA. The problem is that there are several houndreds of possible permutations and I want to test them all. So I am trying to use HYDRA with JobLib Launcher to do…

user164948
- 51
- 4
4
votes
2 answers
Specify Hydra multirun sweeps in a config file
I would like to run a Hydra multirun, but specify the sweeps in a config file.
I would like to know if there is a way to do this before asking for a feature request.
So far what I have tried is the following:
Tree structure:
.
├── conf
│ ├──…

Zaccharie Ramzi
- 2,106
- 1
- 18
- 37
4
votes
1 answer
Returning the config from the function decorated with hydra.main()
Is there an option to get from the function under @hydra.main decorator the configuration object as a dictionary?
I tried something like this, but it returns None
@hydra.main(config_path="conf", config_name="config")
def my_app(cfg) -> dict:
…

itamar kanter
- 1,170
- 3
- 10
- 25
4
votes
2 answers
How to do file over-rides in hydra?
I have a main config file, let's say config.yaml:
num_layers: 4
embedding_size: 512
learning_rate: 0.2
max_steps: 200000
I'd like to be able to override this, on the command-line, with another file, like say big_model.yaml, which I'd use…

Hugh Perkins
- 7,975
- 7
- 63
- 71