We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Investigate integrating https://pypi.org/project/towncrier/
Town crier can manage automatic change list based on news files.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `hydra/__init__.py`
Content:
```
1 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 from .config_loader import ConfigLoader
3 from .errors import MissingConfigException
4 from .main import main
5 from .hydra import Hydra
6 from .launcher import Launcher
7 from .plugins import Plugins
8 from .sweeper import Sweeper
9 from .utils import HydraConfig
10 from . import utils
11 
12 __all__ = [
13     "ConfigLoader",
14     "MissingConfigException",
15     "main",
16     "Launcher",
17     "Plugins",
18     "Sweeper",
19     "Hydra",
20     "HydraConfig",
21     "utils",
22 ]
23
```

Path: `setup.py`
Content:
```
1 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 import distutils
3 import os
4 import re
5 import shutil
6 from os.path import join, exists, isdir
7 
8 from setuptools import setup, find_packages
9 
10 
11 class CleanCommand(distutils.cmd.Command):
12     """
13     Our custom command to clean out junk files.
14     """
15 
16     description = "Cleans out junk files we don't want in the repo"
17     user_options = []
18 
19     def initialize_options(self):
20         pass
21 
22     def finalize_options(self):
23         pass
24 
25     @staticmethod
26     def find(root, includes, excludes=[]):
27         res = []
28         for parent, dirs, files in os.walk(root):
29             for f in dirs + files:
30                 add = list()
31                 for include in includes:
32                     if re.findall(include, f):
33                         add.append(join(parent, f))
34                 res.extend(add)
35         final_list = []
36         # Exclude things that matches an exclude pattern
37         for ex in excludes:
38             for file in res:
39                 if not re.findall(ex, file):
40                     final_list.append(file)
41         return final_list
42 
43     def run(self):
44         delete_patterns = [
45             ".eggs",
46             ".egg-info",
47             ".pytest_cache",
48             "build",
49             "dist",
50             "__pycache__",
51             ".pyc",
52         ]
53         deletion_list = CleanCommand.find(
54             ".", includes=delete_patterns, excludes=["\\.nox/.*"]
55         )
56 
57         for f in deletion_list:
58             if exists(f):
59                 if isdir(f):
60                     shutil.rmtree(f, ignore_errors=True)
61                 else:
62                     os.unlink(f)
63 
64 
65 with open("README.md", "r") as fh:
66     LONG_DESC = fh.read()
67     setup(
68         cmdclass={"clean": CleanCommand},
69         name="hydra",
70         version="0.1.0",
71         author="Omry Yadan",
72         author_email="omry@fb.com",
73         description="Hydra is a generic experimentation framework for scientific computing and "
74         "machine learning",
75         long_description=LONG_DESC,
76         long_description_content_type="text/markdown",
77         url="https://github.com/fairinternal/hydra",
78         keywords="experimentation",
79         packages=find_packages(exclude=["tests"]),
80         include_package_data=True,
81         classifiers=[
82             "Programming Language :: Python :: 2.7",
83             "Programming Language :: Python :: 3.6",
84             "Operating System :: OS Independent",
85         ],
86         install_requires=["omegaconf>=1.3.0rc10"],
87         # Install development dependencies with
88         # pip install -e .[dev]
89         extras_require={
90             "dev": ["pytest", "setuptools", "coverage", "pre-commit", "nox"]
91         },
92     )
93
```

Path: `hydra/main.py`
Content:
```
1 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
2 import argparse
3 import inspect
4 import os
5 import sys
6 
7 import pkg_resources
8 
9 from .hydra import Hydra
10 
11 
12 def get_args():
13     parser = argparse.ArgumentParser(description="Hydra experimentation framework")
14     version = pkg_resources.require("hydra")[0].version
15     parser.add_argument(
16         "--version", action="version", version="hydra {}".format(version)
17     )
18     parser.add_argument(
19         "overrides",
20         nargs="*",
21         help="Any key=value arguments to override config values (use dots for.nested=overrides)",
22     )
23     parser.add_argument(
24         "--verbose",
25         "-v",
26         help="Activate debug logging, otherwise takes a comma separated list of loggers ('root' for root logger)",
27         nargs="?",
28         default=None,
29     )
30 
31     parser.add_argument("--cfg", "-c", action="store_true", help="Show config")
32 
33     parser.add_argument("--run", "-r", action="store_true", help="Run a job")
34 
35     parser.add_argument(
36         "--multirun",
37         "-m",
38         action="store_true",
39         help="Run multiple jobs with the configured launcher",
40     )
41     parser.add_argument(
42         "--sweep",
43         "-s",
44         action="store_true",
45         help="Perform a sweep (deprecated, use --multirun|-m)",
46     )
47 
48     return parser.parse_args()
49 
50 
51 def run_hydra(task_function, config_path, strict):
52     stack = inspect.stack()
53     calling_file = stack[2][0].f_locals["__file__"]
54 
55     target_file = os.path.basename(calling_file)
56     task_name = os.path.splitext(target_file)[0]
57     args = get_args()
58 
59     if os.path.isabs(config_path):
60         raise RuntimeError("Config path should be relative")
61     abs_config_path = os.path.realpath(
62         os.path.join(os.path.dirname(calling_file), config_path)
63     )
64     if not os.path.exists(abs_config_path):
65         raise RuntimeError("Config path '{}' does not exist".format(abs_config_path))
66     if os.path.isfile(abs_config_path):
67         conf_dir = os.path.dirname(abs_config_path)
68         conf_filename = os.path.basename(abs_config_path)
69     else:
70         conf_dir = abs_config_path
71         conf_filename = None
72 
73     hydra = Hydra(
74         task_name=task_name,
75         conf_dir=conf_dir,
76         conf_filename=conf_filename,
77         task_function=task_function,
78         verbose=args.verbose,
79         strict=strict,
80     )
81 
82     if args.run + args.cfg + args.multirun > 1:
83         raise ValueError("Only one of --run, --sweep and --cfg can be specified")
84     if args.run + args.cfg + args.multirun == 0:
85         args.run = True
86 
87     if args.run:
88         command = "run"
89     elif args.sweep:
90         raise RuntimeError("-s|--sweep is no longer supported, please us -m|--multirun")
91     elif args.multirun:
92         command = "multirun"
93     elif args.cfg:
94         command = "cfg"
95 
96     if command == "run":
97         hydra.run(overrides=args.overrides)
98     elif command == "multirun":
99         hydra.multirun(overrides=args.overrides)
100     elif command == "cfg":
101         hydra.show_cfg(overrides=args.overrides)
102     else:
103         print("Command not specified")
104 
105 
106 def main(config_path=".", strict=False):
107     """
108     :param config_path: the config path, can be a directory in which it's used as the config root
109     or a file to load
110     :param strict: strict mode, will throw an error if command line overrides are not changing an
111     existing key or
112            if the code is accessing a non existent key
113     """
114 
115     def main_decorator(task_function):
116         def decorated_main():
117             try:
118                 run_hydra(task_function, config_path, strict)
119             except KeyboardInterrupt:
120                 sys.exit(-1)
121             except SystemExit:
122                 pass
123 
124         return decorated_main
125 
126     return main_decorator
127
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/hydra/__init__.py b/hydra/__init__.py
--- a/hydra/__init__.py
+++ b/hydra/__init__.py
@@ -9,7 +9,11 @@
 from .utils import HydraConfig
 from . import utils
 
+# Source of truth for Hydra's version
+__version__ = "0.1.1"
+
 __all__ = [
+    "__version__",
     "ConfigLoader",
     "MissingConfigException",
     "main",
diff --git a/hydra/main.py b/hydra/main.py
--- a/hydra/main.py
+++ b/hydra/main.py
@@ -11,7 +11,7 @@
 
 def get_args():
     parser = argparse.ArgumentParser(description="Hydra experimentation framework")
-    version = pkg_resources.require("hydra")[0].version
+    version = pkg_resources.get_distribution("hydra").version
     parser.add_argument(
         "--version", action="version", version="hydra {}".format(version)
     )
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,5 @@
 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
+import codecs
 import distutils
 import os
 import re
@@ -7,6 +8,21 @@
 
 from setuptools import setup, find_packages
 
+here = os.path.abspath(os.path.dirname(__file__))
+
+
+def read(*parts):
+    with codecs.open(os.path.join(here, *parts), "r") as fp:
+        return fp.read()
+
+
+def find_version(*file_paths):
+    version_file = read(*file_paths)
+    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
+    if version_match:
+        return version_match.group(1)
+    raise RuntimeError("Unable to find version string.")
+
 
 class CleanCommand(distutils.cmd.Command):
     """
@@ -67,7 +83,7 @@
     setup(
         cmdclass={"clean": CleanCommand},
         name="hydra",
-        version="0.1.0",
+        version=find_version("hydra", "__init__.py"),
         author="Omry Yadan",
         author_email="omry@fb.com",
         description="Hydra is a generic experimentation framework for scientific computing and "
@@ -87,6 +103,13 @@
         # Install development dependencies with
         # pip install -e .[dev]
         extras_require={
-            "dev": ["pytest", "setuptools", "coverage", "pre-commit", "nox"]
+            "dev": [
+                "pytest",
+                "setuptools",
+                "coverage",
+                "pre-commit",
+                "nox",
+                "towncrier",
+            ]
         },
     )

{"golden_diff": "diff --git a/hydra/__init__.py b/hydra/__init__.py\n--- a/hydra/__init__.py\n+++ b/hydra/__init__.py\n@@ -9,7 +9,11 @@\n from .utils import HydraConfig\n from . import utils\n \n+# Source of truth for Hydra's version\n+__version__ = \"0.1.1\"\n+\n __all__ = [\n+    \"__version__\",\n     \"ConfigLoader\",\n     \"MissingConfigException\",\n     \"main\",\ndiff --git a/hydra/main.py b/hydra/main.py\n--- a/hydra/main.py\n+++ b/hydra/main.py\n@@ -11,7 +11,7 @@\n \n def get_args():\n     parser = argparse.ArgumentParser(description=\"Hydra experimentation framework\")\n-    version = pkg_resources.require(\"hydra\")[0].version\n+    version = pkg_resources.get_distribution(\"hydra\").version\n     parser.add_argument(\n         \"--version\", action=\"version\", version=\"hydra {}\".format(version)\n     )\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -1,4 +1,5 @@\n # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\n+import codecs\n import distutils\n import os\n import re\n@@ -7,6 +8,21 @@\n \n from setuptools import setup, find_packages\n \n+here = os.path.abspath(os.path.dirname(__file__))\n+\n+\n+def read(*parts):\n+    with codecs.open(os.path.join(here, *parts), \"r\") as fp:\n+        return fp.read()\n+\n+\n+def find_version(*file_paths):\n+    version_file = read(*file_paths)\n+    version_match = re.search(r\"^__version__ = ['\\\"]([^'\\\"]*)['\\\"]\", version_file, re.M)\n+    if version_match:\n+        return version_match.group(1)\n+    raise RuntimeError(\"Unable to find version string.\")\n+\n \n class CleanCommand(distutils.cmd.Command):\n     \"\"\"\n@@ -67,7 +83,7 @@\n     setup(\n         cmdclass={\"clean\": CleanCommand},\n         name=\"hydra\",\n-        version=\"0.1.0\",\n+        version=find_version(\"hydra\", \"__init__.py\"),\n         author=\"Omry Yadan\",\n         author_email=\"omry@fb.com\",\n         description=\"Hydra is a generic experimentation framework for scientific computing and \"\n@@ -87,6 +103,13 @@\n         # Install development dependencies with\n         # pip install -e .[dev]\n         extras_require={\n-            \"dev\": [\"pytest\", \"setuptools\", \"coverage\", \"pre-commit\", \"nox\"]\n+            \"dev\": [\n+                \"pytest\",\n+                \"setuptools\",\n+                \"coverage\",\n+                \"pre-commit\",\n+                \"nox\",\n+                \"towncrier\",\n+            ]\n         },\n     )\n", "issue": "Investigate integrating https://pypi.org/project/towncrier/\nTown crier can manage automatic change list based on news files.\n", "before_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nfrom .config_loader import ConfigLoader\nfrom .errors import MissingConfigException\nfrom .main import main\nfrom .hydra import Hydra\nfrom .launcher import Launcher\nfrom .plugins import Plugins\nfrom .sweeper import Sweeper\nfrom .utils import HydraConfig\nfrom . import utils\n\n__all__ = [\n    \"ConfigLoader\",\n    \"MissingConfigException\",\n    \"main\",\n    \"Launcher\",\n    \"Plugins\",\n    \"Sweeper\",\n    \"Hydra\",\n    \"HydraConfig\",\n    \"utils\",\n]\n", "path": "hydra/__init__.py"}, {"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nimport distutils\nimport os\nimport re\nimport shutil\nfrom os.path import join, exists, isdir\n\nfrom setuptools import setup, find_packages\n\n\nclass CleanCommand(distutils.cmd.Command):\n    \"\"\"\n    Our custom command to clean out junk files.\n    \"\"\"\n\n    description = \"Cleans out junk files we don't want in the repo\"\n    user_options = []\n\n    def initialize_options(self):\n        pass\n\n    def finalize_options(self):\n        pass\n\n    @staticmethod\n    def find(root, includes, excludes=[]):\n        res = []\n        for parent, dirs, files in os.walk(root):\n            for f in dirs + files:\n                add = list()\n                for include in includes:\n                    if re.findall(include, f):\n                        add.append(join(parent, f))\n                res.extend(add)\n        final_list = []\n        # Exclude things that matches an exclude pattern\n        for ex in excludes:\n            for file in res:\n                if not re.findall(ex, file):\n                    final_list.append(file)\n        return final_list\n\n    def run(self):\n        delete_patterns = [\n            \".eggs\",\n            \".egg-info\",\n            \".pytest_cache\",\n            \"build\",\n            \"dist\",\n            \"__pycache__\",\n            \".pyc\",\n        ]\n        deletion_list = CleanCommand.find(\n            \".\", includes=delete_patterns, excludes=[\"\\\\.nox/.*\"]\n        )\n\n        for f in deletion_list:\n            if exists(f):\n                if isdir(f):\n                    shutil.rmtree(f, ignore_errors=True)\n                else:\n                    os.unlink(f)\n\n\nwith open(\"README.md\", \"r\") as fh:\n    LONG_DESC = fh.read()\n    setup(\n        cmdclass={\"clean\": CleanCommand},\n        name=\"hydra\",\n        version=\"0.1.0\",\n        author=\"Omry Yadan\",\n        author_email=\"omry@fb.com\",\n        description=\"Hydra is a generic experimentation framework for scientific computing and \"\n        \"machine learning\",\n        long_description=LONG_DESC,\n        long_description_content_type=\"text/markdown\",\n        url=\"https://github.com/fairinternal/hydra\",\n        keywords=\"experimentation\",\n        packages=find_packages(exclude=[\"tests\"]),\n        include_package_data=True,\n        classifiers=[\n            \"Programming Language :: Python :: 2.7\",\n            \"Programming Language :: Python :: 3.6\",\n            \"Operating System :: OS Independent\",\n        ],\n        install_requires=[\"omegaconf>=1.3.0rc10\"],\n        # Install development dependencies with\n        # pip install -e .[dev]\n        extras_require={\n            \"dev\": [\"pytest\", \"setuptools\", \"coverage\", \"pre-commit\", \"nox\"]\n        },\n    )\n", "path": "setup.py"}, {"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nimport argparse\nimport inspect\nimport os\nimport sys\n\nimport pkg_resources\n\nfrom .hydra import Hydra\n\n\ndef get_args():\n    parser = argparse.ArgumentParser(description=\"Hydra experimentation framework\")\n    version = pkg_resources.require(\"hydra\")[0].version\n    parser.add_argument(\n        \"--version\", action=\"version\", version=\"hydra {}\".format(version)\n    )\n    parser.add_argument(\n        \"overrides\",\n        nargs=\"*\",\n        help=\"Any key=value arguments to override config values (use dots for.nested=overrides)\",\n    )\n    parser.add_argument(\n        \"--verbose\",\n        \"-v\",\n        help=\"Activate debug logging, otherwise takes a comma separated list of loggers ('root' for root logger)\",\n        nargs=\"?\",\n        default=None,\n    )\n\n    parser.add_argument(\"--cfg\", \"-c\", action=\"store_true\", help=\"Show config\")\n\n    parser.add_argument(\"--run\", \"-r\", action=\"store_true\", help=\"Run a job\")\n\n    parser.add_argument(\n        \"--multirun\",\n        \"-m\",\n        action=\"store_true\",\n        help=\"Run multiple jobs with the configured launcher\",\n    )\n    parser.add_argument(\n        \"--sweep\",\n        \"-s\",\n        action=\"store_true\",\n        help=\"Perform a sweep (deprecated, use --multirun|-m)\",\n    )\n\n    return parser.parse_args()\n\n\ndef run_hydra(task_function, config_path, strict):\n    stack = inspect.stack()\n    calling_file = stack[2][0].f_locals[\"__file__\"]\n\n    target_file = os.path.basename(calling_file)\n    task_name = os.path.splitext(target_file)[0]\n    args = get_args()\n\n    if os.path.isabs(config_path):\n        raise RuntimeError(\"Config path should be relative\")\n    abs_config_path = os.path.realpath(\n        os.path.join(os.path.dirname(calling_file), config_path)\n    )\n    if not os.path.exists(abs_config_path):\n        raise RuntimeError(\"Config path '{}' does not exist\".format(abs_config_path))\n    if os.path.isfile(abs_config_path):\n        conf_dir = os.path.dirname(abs_config_path)\n        conf_filename = os.path.basename(abs_config_path)\n    else:\n        conf_dir = abs_config_path\n        conf_filename = None\n\n    hydra = Hydra(\n        task_name=task_name,\n        conf_dir=conf_dir,\n        conf_filename=conf_filename,\n        task_function=task_function,\n        verbose=args.verbose,\n        strict=strict,\n    )\n\n    if args.run + args.cfg + args.multirun > 1:\n        raise ValueError(\"Only one of --run, --sweep and --cfg can be specified\")\n    if args.run + args.cfg + args.multirun == 0:\n        args.run = True\n\n    if args.run:\n        command = \"run\"\n    elif args.sweep:\n        raise RuntimeError(\"-s|--sweep is no longer supported, please us -m|--multirun\")\n    elif args.multirun:\n        command = \"multirun\"\n    elif args.cfg:\n        command = \"cfg\"\n\n    if command == \"run\":\n        hydra.run(overrides=args.overrides)\n    elif command == \"multirun\":\n        hydra.multirun(overrides=args.overrides)\n    elif command == \"cfg\":\n        hydra.show_cfg(overrides=args.overrides)\n    else:\n        print(\"Command not specified\")\n\n\ndef main(config_path=\".\", strict=False):\n    \"\"\"\n    :param config_path: the config path, can be a directory in which it's used as the config root\n    or a file to load\n    :param strict: strict mode, will throw an error if command line overrides are not changing an\n    existing key or\n           if the code is accessing a non existent key\n    \"\"\"\n\n    def main_decorator(task_function):\n        def decorated_main():\n            try:\n                run_hydra(task_function, config_path, strict)\n            except KeyboardInterrupt:\n                sys.exit(-1)\n            except SystemExit:\n                pass\n\n        return decorated_main\n\n    return main_decorator\n", "path": "hydra/main.py"}], "after_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nfrom .config_loader import ConfigLoader\nfrom .errors import MissingConfigException\nfrom .main import main\nfrom .hydra import Hydra\nfrom .launcher import Launcher\nfrom .plugins import Plugins\nfrom .sweeper import Sweeper\nfrom .utils import HydraConfig\nfrom . import utils\n\n# Source of truth for Hydra's version\n__version__ = \"0.1.1\"\n\n__all__ = [\n    \"__version__\",\n    \"ConfigLoader\",\n    \"MissingConfigException\",\n    \"main\",\n    \"Launcher\",\n    \"Plugins\",\n    \"Sweeper\",\n    \"Hydra\",\n    \"HydraConfig\",\n    \"utils\",\n]\n", "path": "hydra/__init__.py"}, {"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nimport codecs\nimport distutils\nimport os\nimport re\nimport shutil\nfrom os.path import join, exists, isdir\n\nfrom setuptools import setup, find_packages\n\nhere = os.path.abspath(os.path.dirname(__file__))\n\n\ndef read(*parts):\n    with codecs.open(os.path.join(here, *parts), \"r\") as fp:\n        return fp.read()\n\n\ndef find_version(*file_paths):\n    version_file = read(*file_paths)\n    version_match = re.search(r\"^__version__ = ['\\\"]([^'\\\"]*)['\\\"]\", version_file, re.M)\n    if version_match:\n        return version_match.group(1)\n    raise RuntimeError(\"Unable to find version string.\")\n\n\nclass CleanCommand(distutils.cmd.Command):\n    \"\"\"\n    Our custom command to clean out junk files.\n    \"\"\"\n\n    description = \"Cleans out junk files we don't want in the repo\"\n    user_options = []\n\n    def initialize_options(self):\n        pass\n\n    def finalize_options(self):\n        pass\n\n    @staticmethod\n    def find(root, includes, excludes=[]):\n        res = []\n        for parent, dirs, files in os.walk(root):\n            for f in dirs + files:\n                add = list()\n                for include in includes:\n                    if re.findall(include, f):\n                        add.append(join(parent, f))\n                res.extend(add)\n        final_list = []\n        # Exclude things that matches an exclude pattern\n        for ex in excludes:\n            for file in res:\n                if not re.findall(ex, file):\n                    final_list.append(file)\n        return final_list\n\n    def run(self):\n        delete_patterns = [\n            \".eggs\",\n            \".egg-info\",\n            \".pytest_cache\",\n            \"build\",\n            \"dist\",\n            \"__pycache__\",\n            \".pyc\",\n        ]\n        deletion_list = CleanCommand.find(\n            \".\", includes=delete_patterns, excludes=[\"\\\\.nox/.*\"]\n        )\n\n        for f in deletion_list:\n            if exists(f):\n                if isdir(f):\n                    shutil.rmtree(f, ignore_errors=True)\n                else:\n                    os.unlink(f)\n\n\nwith open(\"README.md\", \"r\") as fh:\n    LONG_DESC = fh.read()\n    setup(\n        cmdclass={\"clean\": CleanCommand},\n        name=\"hydra\",\n        version=find_version(\"hydra\", \"__init__.py\"),\n        author=\"Omry Yadan\",\n        author_email=\"omry@fb.com\",\n        description=\"Hydra is a generic experimentation framework for scientific computing and \"\n        \"machine learning\",\n        long_description=LONG_DESC,\n        long_description_content_type=\"text/markdown\",\n        url=\"https://github.com/fairinternal/hydra\",\n        keywords=\"experimentation\",\n        packages=find_packages(exclude=[\"tests\"]),\n        include_package_data=True,\n        classifiers=[\n            \"Programming Language :: Python :: 2.7\",\n            \"Programming Language :: Python :: 3.6\",\n            \"Operating System :: OS Independent\",\n        ],\n        install_requires=[\"omegaconf>=1.3.0rc10\"],\n        # Install development dependencies with\n        # pip install -e .[dev]\n        extras_require={\n            \"dev\": [\n                \"pytest\",\n                \"setuptools\",\n                \"coverage\",\n                \"pre-commit\",\n                \"nox\",\n                \"towncrier\",\n            ]\n        },\n    )\n", "path": "setup.py"}, {"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nimport argparse\nimport inspect\nimport os\nimport sys\n\nimport pkg_resources\n\nfrom .hydra import Hydra\n\n\ndef get_args():\n    parser = argparse.ArgumentParser(description=\"Hydra experimentation framework\")\n    version = pkg_resources.get_distribution(\"hydra\").version\n    parser.add_argument(\n        \"--version\", action=\"version\", version=\"hydra {}\".format(version)\n    )\n    parser.add_argument(\n        \"overrides\",\n        nargs=\"*\",\n        help=\"Any key=value arguments to override config values (use dots for.nested=overrides)\",\n    )\n    parser.add_argument(\n        \"--verbose\",\n        \"-v\",\n        help=\"Activate debug logging, otherwise takes a comma separated list of loggers ('root' for root logger)\",\n        nargs=\"?\",\n        default=None,\n    )\n\n    parser.add_argument(\"--cfg\", \"-c\", action=\"store_true\", help=\"Show config\")\n\n    parser.add_argument(\"--run\", \"-r\", action=\"store_true\", help=\"Run a job\")\n\n    parser.add_argument(\n        \"--multirun\",\n        \"-m\",\n        action=\"store_true\",\n        help=\"Run multiple jobs with the configured launcher\",\n    )\n    parser.add_argument(\n        \"--sweep\",\n        \"-s\",\n        action=\"store_true\",\n        help=\"Perform a sweep (deprecated, use --multirun|-m)\",\n    )\n\n    return parser.parse_args()\n\n\ndef run_hydra(task_function, config_path, strict):\n    stack = inspect.stack()\n    calling_file = stack[2][0].f_locals[\"__file__\"]\n\n    target_file = os.path.basename(calling_file)\n    task_name = os.path.splitext(target_file)[0]\n    args = get_args()\n\n    if os.path.isabs(config_path):\n        raise RuntimeError(\"Config path should be relative\")\n    abs_config_path = os.path.realpath(\n        os.path.join(os.path.dirname(calling_file), config_path)\n    )\n    if not os.path.exists(abs_config_path):\n        raise RuntimeError(\"Config path '{}' does not exist\".format(abs_config_path))\n    if os.path.isfile(abs_config_path):\n        conf_dir = os.path.dirname(abs_config_path)\n        conf_filename = os.path.basename(abs_config_path)\n    else:\n        conf_dir = abs_config_path\n        conf_filename = None\n\n    hydra = Hydra(\n        task_name=task_name,\n        conf_dir=conf_dir,\n        conf_filename=conf_filename,\n        task_function=task_function,\n        verbose=args.verbose,\n        strict=strict,\n    )\n\n    if args.run + args.cfg + args.multirun > 1:\n        raise ValueError(\"Only one of --run, --sweep and --cfg can be specified\")\n    if args.run + args.cfg + args.multirun == 0:\n        args.run = True\n\n    if args.run:\n        command = \"run\"\n    elif args.sweep:\n        raise RuntimeError(\"-s|--sweep is no longer supported, please us -m|--multirun\")\n    elif args.multirun:\n        command = \"multirun\"\n    elif args.cfg:\n        command = \"cfg\"\n\n    if command == \"run\":\n        hydra.run(overrides=args.overrides)\n    elif command == \"multirun\":\n        hydra.multirun(overrides=args.overrides)\n    elif command == \"cfg\":\n        hydra.show_cfg(overrides=args.overrides)\n    else:\n        print(\"Command not specified\")\n\n\ndef main(config_path=\".\", strict=False):\n    \"\"\"\n    :param config_path: the config path, can be a directory in which it's used as the config root\n    or a file to load\n    :param strict: strict mode, will throw an error if command line overrides are not changing an\n    existing key or\n           if the code is accessing a non existent key\n    \"\"\"\n\n    def main_decorator(task_function):\n        def decorated_main():\n            try:\n                run_hydra(task_function, config_path, strict)\n            except KeyboardInterrupt:\n                sys.exit(-1)\n            except SystemExit:\n                pass\n\n        return decorated_main\n\n    return main_decorator\n", "path": "hydra/main.py"}]}