From 50be52b325511bfdc0df3e0e15e67c00013374d4 Mon Sep 17 00:00:00 2001 From: Miles Olson Date: Thu, 25 Apr 2024 08:51:31 -0700 Subject: [PATCH] Ban spaces in metric/parameter names in AxClient 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 Reviewed By: bernardbeckerman Differential Revision: D56576451 --- ax/service/utils/instantiation.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ax/service/utils/instantiation.py b/ax/service/utils/instantiation.py index 791781bf98..35f3ae0400 100644 --- a/ax/service/utils/instantiation.py +++ b/ax/service/utils/instantiation.py @@ -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!r}." + ) + return metric_class( name=name, lower_is_better=lower_is_better, @@ -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!r}." + ) + if parameter_class == "range": return cls._make_range_param( name=name,