question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Override default hydra configuration

See original GitHub issue

For organizing experiments (using the example from the doc), we could override the defaults values in file experiment/nglite.yaml with

# @package _global_
defaults:
  - override /db: sqlite
  - override /server: nginx
  
server:
  port: 8080

Is it possible to override the hydra config within the same file? I tried

# @package _global_
defaults:
  - override /hydra: some_config

but would result an error Could not override 'hydra'. Did you mean to override hydra?.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ZachariahPangcommented, Jun 2, 2021

Hi @jieru-hu @Jasha10, Sorry I didn’t explain my question well. I’m using Hydra 1.1.0.rc1.

What I’m trying to do is having a single file containing all the configs related to a certain experiment (some specific model, trainer, logger, etc) in configs/experiment/experiment1.yaml. Normally all the logs are in logs/runs/some_date/some_time as normal, but when I run some experiments, the logs would be changed to another dir experiment/experiment_name/version.

My minimum config files looks as follow

  • configs
    • model
      • model1.yaml
      • model2.yaml
    • experiment
      • experiment1.yaml
      • experiment2.yaml
    • hydra
      • default.yaml
      • experiment.yaml
    • config.yaml

Inside configs/config.yaml, there is already a default hydra configuration

defaults:
  - model: model1
  - experiment: null
  - hydra: default

configs/hydra/default.yaml has

run:
    dir: logs/runs/${now:%Y-%m-%d}/${now:%H-%M-%S}

configs/hydra/experiment.yaml has

run:
    dir: experiment/${experiment_name}/${version}

configs/experiment/experiment1.yaml has

defaults:
    - override /model: model1
    - override /hydra: experiment

experiment_name: some_exp
version: v1

The desired behavior is to run with flag python main.py experiment=experiment1 and then the logs would automatically be inside experiment/some_exp/v1 instead of the default log dir. I’m not sure if this is the right approach.

0reactions
omrycommented, Jun 7, 2021

Closing, feel free to reopen and provide the requested info.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Basic Override syntax - Hydra
You can manipulate your configuration with overrides (via the command line or the Compose API). This includes: Modifying the Defaults List; Modifying the ......
Read more >
hydra - structured config group/package override via yaml
Trying to explain my problem using the example (files and folder structre) from the hydra documentation https://hydra.cc/docs/tutorials/ ...
Read more >
Hydra: Overview — Maze documentation - Read the Docs
Config Root & Defaults explains how the root config file works and how default components are specified. Overrides show how you can easily...
Read more >
Difference between facebook Hydra's + and ++ operators
my_app.py import hydra from omegaconf import OmegaConf, ... Overriding a config value ( foo.bar=value ) works only if the given key is ...
Read more >
modulus.hydra.config - NVIDIA Documentation Center
[docs]@dataclass class DefaultModulusConfig(ModulusConfig): # Core defaults # Can over-ride default with "override" hydra command defaults: List[Any] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found