From 9b33f3a7b7d799378decc2b7ef065e279599825d Mon Sep 17 00:00:00 2001 From: Eric Liang Date: Sat, 3 Mar 2018 20:25:58 -0800 Subject: [PATCH] [autoscaler] Bad error message when dict field omitted (#1632) * Wed Feb 28 23:22:55 PST 2018 * Wed Feb 28 23:24:07 PST 2018 --- python/ray/autoscaler/autoscaler.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/python/ray/autoscaler/autoscaler.py b/python/ray/autoscaler/autoscaler.py index 813a7f83f..c6f4b0acc 100644 --- a/python/ray/autoscaler/autoscaler.py +++ b/python/ray/autoscaler/autoscaler.py @@ -467,6 +467,13 @@ class StandardAutoscaler(object): suffix, self.load_metrics.debug_string()) +def typename(v): + if isinstance(v, type): + return v.__name__ + else: + return type(v).__name__ + + def validate_config(config, schema=CLUSTER_CONFIG_SCHEMA): if type(config) is not dict: raise ValueError("Config is not a dictionary") @@ -476,7 +483,7 @@ def validate_config(config, schema=CLUSTER_CONFIG_SCHEMA): if k not in config: raise ValueError( "Missing required config key `{}` of type {}".format( - k, v.__name__)) + k, typename(v))) if isinstance(v, type): if not isinstance(config[k], v): raise ValueError(