fb-hydraomegaconf

Disable file output of hydra


I'm using hydra to log hyperparameters of experiments.

@hydra.main(config_name="config", config_path="../conf")
def evaluate_experiment(cfg: DictConfig) -> None:
    print(OmegaConf.to_yaml(cfg))
    ...

Sometimes I want to do a dry run to check something. For this I don't need any saved parameters, so I'm wondering how I can disable the savings to the filesystem completely in this case?


Solution

  • There is an enhancement request aimed at Hydra 1.1 to support disabling working directory management. Working directory management is doing many things:

    There are other related features:

    Different features has different ways to disable them:

    1. To prevent the creation of a working directory, you can override hydra.run.dir to ..
    2. To prevent saving the files into .hydra, override hydra.output_subdir to null.
    3. To prevent the creation of logging files, you can disable logging output of hydra/hydra_logging and hydra/job_logging, see this.

    A complete example might look like:

    $ python foo.py hydra.run.dir=. hydra.output_subdir=null hydra/job_logging=disabled hydra/hydra_logging=disabled
    

    Note that as always you can also override those config values through your config file.