Repository: facebookresearch/hydra

Issue:
[Bug] --cfg not working
# 🐛 Bug

when running `python main.py --cfg hydra`


** Stack trace/error message **
```
Traceback (most recent call last):
  File "main.py", line 576, in <module>
    main()
  File "/private/home/yannd/.conda/envs/assl/lib/python3.7/site-packages/hydra/main.py", line 24, in decorated_main
    strict=strict,
  File "/private/home/yannd/.conda/envs/assl/lib/python3.7/site-packages/hydra/_internal/utils.py", line 183, in run_hydra
    hydra.show_cfg(overrides=args.overrides, cfg_type=args.cfg)
  File "/private/home/yannd/.conda/envs/assl/lib/python3.7/site-packages/hydra/_internal/hydra.py", line 116, in show_cfg
    cfg = self.compose_config(overrides, with_log_configuration=True)
TypeError: compose_config() missing 1 required positional argument: 'overrides'
```

## System information
- Hydra 0.11
- Python : 3.7


Discussion:

Resolving patch:
diff --git a/hydra/_internal/hydra.py b/hydra/_internal/hydra.py
--- a/hydra/_internal/hydra.py
+++ b/hydra/_internal/hydra.py
@@ -96,7 +96,7 @@ def multirun(self, config_file, task_function, overrides):
         )
         HydraConfig().set_config(cfg)
         sweeper = Plugins.instantiate_sweeper(
-            config=cfg, config_loader=self.config_loader, task_function=task_function,
+            config=cfg, config_loader=self.config_loader, task_function=task_function
         )
         task_overrides = cfg.hydra.overrides.task
         return sweeper.sweep(arguments=task_overrides)
@@ -111,9 +111,11 @@ def get_sanitized_hydra_cfg(src_cfg):
         del cfg.hydra["help"]
         return cfg
 
-    def show_cfg(self, overrides, cfg_type):
+    def show_cfg(self, config_file, overrides, cfg_type):
         assert cfg_type in ["job", "hydra", "all"]
-        cfg = self.compose_config(overrides, with_log_configuration=True)
+        cfg = self.compose_config(
+            config_file=config_file, overrides=overrides, with_log_configuration=True
+        )
         if cfg_type == "job":
             del cfg["hydra"]
         elif cfg_type == "hydra":
diff --git a/hydra/_internal/utils.py b/hydra/_internal/utils.py
--- a/hydra/_internal/utils.py
+++ b/hydra/_internal/utils.py
@@ -180,7 +180,9 @@ def run_hydra(args_parser, task_function, config_path, strict):
             overrides=args.overrides,
         )
     elif args.cfg:
-        hydra.show_cfg(overrides=args.overrides, cfg_type=args.cfg)
+        hydra.show_cfg(
+            config_file=config_file, overrides=args.overrides, cfg_type=args.cfg
+        )
     elif args.shell_completion:
         hydra.shell_completion(config_file=config_file, overrides=args.overrides)
     else:


Test patch:
diff --git a/tests/test_hydra.py b/tests/test_hydra.py
--- a/tests/test_hydra.py
+++ b/tests/test_hydra.py
@@ -224,6 +224,22 @@ def test_short_module_name(tmpdir):
         chdir_hydra_root()
 
 
+@pytest.mark.parametrize(
+    "flag,expected_keys",
+    [("--cfg=all", ["db", "hydra"]), ("--cfg=hydra", ["hydra"]), ("--cfg=job", ["db"])],
+)
+def test_cfg(tmpdir, flag, expected_keys):
+    try:
+        os.chdir("examples/tutorial/4_defaults")
+        cmd = [sys.executable, "my_app.py", "hydra.run.dir=" + str(tmpdir), flag]
+        result = subprocess.check_output(cmd)
+        conf = OmegaConf.create(str(result.decode("utf-8")))
+        for key in expected_keys:
+            assert key in conf
+    finally:
+        chdir_hydra_root()
+
+
 @pytest.mark.parametrize(
     "calling_file, calling_module",
     [