prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Better error message if config structure passed to instantiate is invalid.
  # 🐛 Bug
  
  In [common patterns#creating objects](https://cli.dev/docs/patterns/objects), if the `params` are mistakenly valued with a single string, the [`instantiate`](https://github.com/facebookresearch/hydra/blob/cb7904c666b34a53e09194993a0dd7b10fd97c99/hydra/utils.py#L44-L53) function exists with the error mentioned in "Stack trace/error messages":
  
  This is fine to some extent, which is do you (Hydra team) aim at providing this kind of output messages? 
  
  <!-- A clear and concise description of what the bug is. -->
  
  ## To reproduce
  
  ** Minimal Code/Config snippet to reproduce **
  
  Set `params` to `bug_report` as in:
  
  ```YAML
  class: ...
  params: bug_report
  ```
  
  ** Stack trace/error message **
  ```
  > AttributeError: 'str' object has no attribute 'merge_with'
  [2019-10-16 02:25:21,592][hydra.utils][ERROR] - Error instantiating [[OBJECT_NAME]] : 'str' object has no attribute 'merge_with'
  ```
  **Optional video**
  If applicable, record a short [video](https://asciinema.org) with to help explain your problem.
  You can also 
  
  ## Expected Behavior
  <!-- A clear and concise description of what you expected to happen. -->
  
  I expect to have some sort of an error message explaining that `params` should be a collection of values where [[TYPE]] was provided. 
   
  ## System information
  - <!-- Hydra Version --> Hydra Version: 0.9.0
  
  - <!-- Operating system --> Operating System: Arch Linux
  
  ## Additional context
  If you confirm that this should be fixed, I've already implemented the solution (IMO). 
  
  Better error message if config structure passed to instantiate is invalid.
  # 🐛 Bug
  
  In [common patterns#creating objects](https://cli.dev/docs/patterns/objects), if the `params` are mistakenly valued with a single string, the [`instantiate`](https://github.com/facebookresearch/hydra/blob/cb7904c666b34a53e09194993a0dd7b10fd97c99/hydra/utils.py#L44-L53) function exists with the error mentioned in "Stack trace/error messages":
  
  This is fine to some extent, which is do you (Hydra team) aim at providing this kind of output messages? 
  
  <!-- A clear and concise description of what the bug is. -->
  
  ## To reproduce
  
  ** Minimal Code/Config snippet to reproduce **
  
  Set `params` to `bug_report` as in:
  
  ```YAML
  class: ...
  params: bug_report
  ```
  
  ** Stack trace/error message **
  ```
  > AttributeError: 'str' object has no attribute 'merge_with'
  [2019-10-16 02:25:21,592][hydra.utils][ERROR] - Error instantiating [[OBJECT_NAME]] : 'str' object has no attribute 'merge_with'
  ```
  **Optional video**
  If applicable, record a short [video](https://asciinema.org) with to help explain your problem.
  You can also 
  
  ## Expected Behavior
  <!-- A clear and concise description of what you expected to happen. -->
  
  I expect to have some sort of an error message explaining that `params` should be a collection of values where [[TYPE]] was provided. 
   
  ## System information
  - <!-- Hydra Version --> Hydra Version: 0.9.0
  
  - <!-- Operating system --> Operating System: Arch Linux
  
  ## Additional context
  If you confirm that this should be fixed, I've already implemented the solution (IMO). 
  
  
  </issue>
  <code>
  [start of hydra/utils.py]
  1 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
  2 import logging.config
  3 
  4 from omegaconf import OmegaConf
  5 
  6 # pylint: disable=C0103
  7 log = logging.getLogger(__name__)
  8 
  9 
  10 def get_method(path):
  11     return get_class(path)
  12 
  13 
  14 def get_class(path):
  15     try:
  16         from importlib import import_module
  17 
  18         module_path, _, class_name = path.rpartition(".")
  19         mod = import_module(module_path)
  20         try:
  21             klass = getattr(mod, class_name)
  22         except AttributeError:
  23             raise ImportError(
  24                 "Class {} is not in module {}".format(class_name, module_path)
  25             )
  26         return klass
  27     except ValueError as e:
  28         log.error("Error initializing class " + path)
  29         raise e
  30 
  31 
  32 def get_static_method(full_method_name):
  33     try:
  34         spl = full_method_name.split(".")
  35         method_name = spl.pop()
  36         class_name = ".".join(spl)
  37         clz = get_class(class_name)
  38         return getattr(clz, method_name)
  39     except Exception as e:
  40         log.error("Error getting static method {} : {}".format(full_method_name, e))
  41         raise e
  42 
  43 
  44 def instantiate(config, *args, **kwargs):
  45     assert config is not None, "Input config is None"
  46     try:
  47         clazz = get_class(config["class"])
  48         params = config.params if "params" in config else OmegaConf.create()
  49         params.merge_with(OmegaConf.create(kwargs))
  50         return clazz(*args, **params)
  51     except Exception as e:
  52         log.error("Error instantiating {} : {}".format(config["class"], e))
  53         raise e
  54
  [end of hydra/utils.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/hydra/utils.py b/hydra/utils.py
  --- a/hydra/utils.py
  +++ b/hydra/utils.py
  @@ -1,7 +1,7 @@
   # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
   import logging.config
   
  -from omegaconf import OmegaConf
  +from omegaconf import OmegaConf, DictConfig
   
   # pylint: disable=C0103
   log = logging.getLogger(__name__)
  @@ -46,6 +46,11 @@
       try:
           clazz = get_class(config["class"])
           params = config.params if "params" in config else OmegaConf.create()
  +        assert isinstance(
  +            params, DictConfig
  +        ), "Input config params are expected to be a mapping, found {}".format(
  +            type(config.params)
  +        )
           params.merge_with(OmegaConf.create(kwargs))
           return clazz(*args, **params)
       except Exception as e:
  
verification_info: {"golden_diff": "diff --git a/hydra/utils.py b/hydra/utils.py\n--- a/hydra/utils.py\n+++ b/hydra/utils.py\n@@ -1,7 +1,7 @@\n # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\n import logging.config\n \n-from omegaconf import OmegaConf\n+from omegaconf import OmegaConf, DictConfig\n \n # pylint: disable=C0103\n log = logging.getLogger(__name__)\n@@ -46,6 +46,11 @@\n     try:\n         clazz = get_class(config[\"class\"])\n         params = config.params if \"params\" in config else OmegaConf.create()\n+        assert isinstance(\n+            params, DictConfig\n+        ), \"Input config params are expected to be a mapping, found {}\".format(\n+            type(config.params)\n+        )\n         params.merge_with(OmegaConf.create(kwargs))\n         return clazz(*args, **params)\n     except Exception as e:\n", "issue": "Better error message if config structure passed to instantiate is invalid.\n# \ud83d\udc1b Bug\r\n\r\nIn [common patterns#creating objects](https://cli.dev/docs/patterns/objects), if the `params` are mistakenly valued with a single string, the [`instantiate`](https://github.com/facebookresearch/hydra/blob/cb7904c666b34a53e09194993a0dd7b10fd97c99/hydra/utils.py#L44-L53) function exists with the error mentioned in \"Stack trace/error messages\":\r\n\r\nThis is fine to some extent, which is do you (Hydra team) aim at providing this kind of output messages? \r\n\r\n<!-- A clear and concise description of what the bug is. -->\r\n\r\n## To reproduce\r\n\r\n** Minimal Code/Config snippet to reproduce **\r\n\r\nSet `params` to `bug_report` as in:\r\n\r\n```YAML\r\nclass: ...\r\nparams: bug_report\r\n```\r\n\r\n** Stack trace/error message **\r\n```\r\n> AttributeError: 'str' object has no attribute 'merge_with'\r\n[2019-10-16 02:25:21,592][hydra.utils][ERROR] - Error instantiating [[OBJECT_NAME]] : 'str' object has no attribute 'merge_with'\r\n```\r\n**Optional video**\r\nIf applicable, record a short [video](https://asciinema.org) with to help explain your problem.\r\nYou can also \r\n\r\n## Expected Behavior\r\n<!-- A clear and concise description of what you expected to happen. -->\r\n\r\nI expect to have some sort of an error message explaining that `params` should be a collection of values where [[TYPE]] was provided. \r\n \r\n## System information\r\n- <!-- Hydra Version --> Hydra Version: 0.9.0\r\n\r\n- <!-- Operating system --> Operating System: Arch Linux\r\n\r\n## Additional context\r\nIf you confirm that this should be fixed, I've already implemented the solution (IMO). \r\n\nBetter error message if config structure passed to instantiate is invalid.\n# \ud83d\udc1b Bug\r\n\r\nIn [common patterns#creating objects](https://cli.dev/docs/patterns/objects), if the `params` are mistakenly valued with a single string, the [`instantiate`](https://github.com/facebookresearch/hydra/blob/cb7904c666b34a53e09194993a0dd7b10fd97c99/hydra/utils.py#L44-L53) function exists with the error mentioned in \"Stack trace/error messages\":\r\n\r\nThis is fine to some extent, which is do you (Hydra team) aim at providing this kind of output messages? \r\n\r\n<!-- A clear and concise description of what the bug is. -->\r\n\r\n## To reproduce\r\n\r\n** Minimal Code/Config snippet to reproduce **\r\n\r\nSet `params` to `bug_report` as in:\r\n\r\n```YAML\r\nclass: ...\r\nparams: bug_report\r\n```\r\n\r\n** Stack trace/error message **\r\n```\r\n> AttributeError: 'str' object has no attribute 'merge_with'\r\n[2019-10-16 02:25:21,592][hydra.utils][ERROR] - Error instantiating [[OBJECT_NAME]] : 'str' object has no attribute 'merge_with'\r\n```\r\n**Optional video**\r\nIf applicable, record a short [video](https://asciinema.org) with to help explain your problem.\r\nYou can also \r\n\r\n## Expected Behavior\r\n<!-- A clear and concise description of what you expected to happen. -->\r\n\r\nI expect to have some sort of an error message explaining that `params` should be a collection of values where [[TYPE]] was provided. \r\n \r\n## System information\r\n- <!-- Hydra Version --> Hydra Version: 0.9.0\r\n\r\n- <!-- Operating system --> Operating System: Arch Linux\r\n\r\n## Additional context\r\nIf you confirm that this should be fixed, I've already implemented the solution (IMO). \r\n\n", "before_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nimport logging.config\n\nfrom omegaconf import OmegaConf\n\n# pylint: disable=C0103\nlog = logging.getLogger(__name__)\n\n\ndef get_method(path):\n    return get_class(path)\n\n\ndef get_class(path):\n    try:\n        from importlib import import_module\n\n        module_path, _, class_name = path.rpartition(\".\")\n        mod = import_module(module_path)\n        try:\n            klass = getattr(mod, class_name)\n        except AttributeError:\n            raise ImportError(\n                \"Class {} is not in module {}\".format(class_name, module_path)\n            )\n        return klass\n    except ValueError as e:\n        log.error(\"Error initializing class \" + path)\n        raise e\n\n\ndef get_static_method(full_method_name):\n    try:\n        spl = full_method_name.split(\".\")\n        method_name = spl.pop()\n        class_name = \".\".join(spl)\n        clz = get_class(class_name)\n        return getattr(clz, method_name)\n    except Exception as e:\n        log.error(\"Error getting static method {} : {}\".format(full_method_name, e))\n        raise e\n\n\ndef instantiate(config, *args, **kwargs):\n    assert config is not None, \"Input config is None\"\n    try:\n        clazz = get_class(config[\"class\"])\n        params = config.params if \"params\" in config else OmegaConf.create()\n        params.merge_with(OmegaConf.create(kwargs))\n        return clazz(*args, **params)\n    except Exception as e:\n        log.error(\"Error instantiating {} : {}\".format(config[\"class\"], e))\n        raise e\n", "path": "hydra/utils.py"}]}