Repository: facebookresearch/hydra

Issue:
[Bug]: Nevergrad sweeper does not work with integers if there are less than 6 choices
Nevergrad sweeper complains if it has less than 6 values to sweep over in a range (e.g. `lower: 1` `upper:3`) and asks to use a list instead (`ValueError: For integers with 6 or fewer values, use a choice instead`). But if you use a list with integers it does not work because it assumes that choices contain only strings:

![Screen Shot 2020-08-15 at 7 42 39 PM](https://user-images.githubusercontent.com/24327668/90323444-84a3b680-df2f-11ea-8d77-1ce82ab9c7c6.png)

Line where the first error is raised: https://github.com/facebookresearch/hydra/blob/0e001afb2a55275b6f7dc33e79035dbf3a797c00/plugins/hydra_nevergrad_sweeper/hydra_plugins/hydra_nevergrad_sweeper/core.py#L178
Hydra Version: 1.0.0rc2


Of course I can give a string and then convert in my code, but it would probably be better to solve it differently? For example sliently treating it as a list without raising the first error ? Or at least to say in the raised error that you have to use a list and convert the str to int in your own code ? Not sure what is the best way..




Discussion:
This is going to be changed dramatically soon anyway.
we will be sure to test this case when we change it.
Take a look at the [Extended grammar syntax](https://hydra.cc/docs/next/advanced/override_grammar/extended) for a sneak preview.

cc @shagunsodhani , @jrapin.
@YannDubs, please provide a minimal repo. You can use the example app in the plugin dir.

Resolving patch:
diff --git a/plugins/hydra_nevergrad_sweeper/hydra_plugins/hydra_nevergrad_sweeper/core.py b/plugins/hydra_nevergrad_sweeper/hydra_plugins/hydra_nevergrad_sweeper/core.py
--- a/plugins/hydra_nevergrad_sweeper/hydra_plugins/hydra_nevergrad_sweeper/core.py
+++ b/plugins/hydra_nevergrad_sweeper/hydra_plugins/hydra_nevergrad_sweeper/core.py
@@ -140,7 +140,7 @@ def make_nevergrad_parameter(description: Any) -> Any:
     # revert config parsing
 
     if isinstance(description, (ListConfig, list)):
-        description = ",".join(description)
+        description = ",".join(str(x) for x in description)
     if isinstance(description, str):
         # cast to spec if possible
         try:


Test patch:
diff --git a/plugins/hydra_nevergrad_sweeper/tests/test_nevergrad_sweeper_plugin.py b/plugins/hydra_nevergrad_sweeper/tests/test_nevergrad_sweeper_plugin.py
--- a/plugins/hydra_nevergrad_sweeper/tests/test_nevergrad_sweeper_plugin.py
+++ b/plugins/hydra_nevergrad_sweeper/tests/test_nevergrad_sweeper_plugin.py
@@ -23,10 +23,12 @@ def test_discovery() -> None:
 
 
 @pytest.mark.parametrize(  # type: ignore
-    "string,param_cls,value_cls",
+    "description,param_cls,value_cls",
     [
         ("blu,blublu", ng.p.Choice, str),
+        (["blu", "blublu"], ng.p.Choice, str),
         ("0,1,2", ng.p.TransitionChoice, float),
+        ([0, 1, 2], ng.p.TransitionChoice, float),
         ("int:0,1,2", ng.p.TransitionChoice, int),
         ("str:0,1,2", ng.p.Choice, str),
         ("0.0,12.0,2.0", ng.p.Choice, float),
@@ -36,8 +38,10 @@ def test_discovery() -> None:
         ("blublu", str, str),
     ],
 )
-def test_make_nevergrad_parameter(string: str, param_cls: Any, value_cls: Any) -> None:
-    param = core.make_nevergrad_parameter(string)
+def test_make_nevergrad_parameter(
+    description: Any, param_cls: Any, value_cls: Any
+) -> None:
+    param = core.make_nevergrad_parameter(description)
     assert isinstance(param, param_cls)
     if param_cls is not str:
         assert isinstance(param.value, value_cls)