Skip to content

Commit

Permalink
Ban spaces in metric/parameter names in AxClient
Browse files Browse the repository at this point in the history
Summary: Spaces in names break parsing needed for contraints in AxClient. We discussed many options fo rmoving forward here but this simple solution is the least disruptive

Differential Revision: D56576451
  • Loading branch information
mpolson64 authored and facebook-github-bot committed Apr 25, 2024
1 parent 859055c commit bec6d6b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ax/service/utils/instantiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ def _make_metric(
for_opt_config: bool = False,
metric_definitions: Optional[Dict[str, Dict[str, Any]]] = None,
) -> Metric:
if " " in name:
raise ValueError(
"Metric names cannot contain spaces when used with AxClient. Got "
f"{name}."
)

return metric_class(
name=name,
lower_is_better=lower_is_better,
Expand Down Expand Up @@ -314,6 +320,12 @@ def parameter_from_json(
"'bool' or 'str'."
)

if " " in name:
raise ValueError(
"Parameter names cannot contain spaces when used with AxClient. Got "
f"{name}."
)

if parameter_class == "range":
return cls._make_range_param(
name=name,
Expand Down

0 comments on commit bec6d6b

Please sign in to comment.