Skip to main content
Version: 1.2

A simple command-line application

Β Example (Click Here)

This is a simple Hydra application that prints your configuration. The my_app function is a placeholder for your code. We will slowly evolve this example to showcase more Hydra features.

The examples in this tutorial are available here.
from omegaconf import DictConfig, OmegaConf
import hydra

def my_app(cfg: DictConfig) -> None:

if __name__ == "__main__":

In this example, Hydra creates an empty cfg object and passes it to the function annotated with @hydra.main.

You can add config values via the command line. The + indicates that the field is new.

$ python +db.driver=mysql +db.user=omry +db.password=secret
driver: mysql
user: omry
password: secret

See the version_base page for details on the version_base parameter.

See Hydra's command line flags and Basic Override Syntax for more information about the command line.