[autoscaler] Fix Defaults (#1661)

This commit is contained in:
Richard Liaw 2018-03-09 16:59:21 -08:00 committed by GitHub
parent 2b747ba46c
commit 40799fee37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -503,14 +503,16 @@ def check_required(config, schema):
def check_extraneous(config, schema):
"""Make sure all items of config are in schema"""
if type(config) is not dict:
raise ValueError("Config is not a dictionary")
raise ValueError("Config {} is not a dictionary".format(config))
for k in config:
if k not in schema:
raise ValueError(
"Unexpected config key `{}` not in {}".format(
k, list(schema.keys())))
v, kreq = schema[k]
if isinstance(v, type):
if v is None:
continue
elif isinstance(v, type):
if not isinstance(config[k], v):
raise ValueError(
"Config key `{}` has wrong type {}, expected {}".format(
@ -522,7 +524,7 @@ def check_extraneous(config, schema):
def validate_config(config, schema=CLUSTER_CONFIG_SCHEMA):
"""Required Dicts indicate that no extra fields can be introduced."""
if type(config) is not dict:
raise ValueError("Config is not a dictionary")
raise ValueError("Config {} is not a dictionary".format(config))
check_required(config, schema)
check_extraneous(config, schema)