in src/vw-serving/src/vw_serving/sagemaker/integration.py [0:0]
def pretty_validation_message(e):
try:
if e.validator == 'enum':
return ("The value '{}' is not valid for the '{}' "
"hyperparameter which accepts one of the following: {}").format(
e.instance, ".".join(e.path), ", ".join(map(lambda v: "'{}'".format(v), e.validator_value))
)
elif e.validator == 'type':
return "The value '{}' is not valid for the '{}' hyperparameter which expects a {}".format(
e.instance, ".".join(e.path), e.validator_value
)
elif e.validator == 'additionalProperties':
return e.message.replace('properties', 'hyperparameters')
elif e.validator == 'required':
# This is hacky since jsonschema doesn't actually expose which value was missing
# so we have to determine it manually.
missing_values = ["'{}'".format(key) for key in e.validator_value if key not in e.instance]
return "No value(s) were specified for {} which are required hyperparameter(s)".format(
", ".join(missing_values)
)
elif e.validator == 'oneOf':
# oneOf validators are used to specify numbers.
# For every number we have both a string and either a number or float entry.
validator_messages = []
for validator in e.validator_value:
potential_messages = list(filter(lambda v: v is not None,
[
ConfigValidator.pretty_string_validator(validator),
ConfigValidator.pretty_number_validator(validator)
]))
if len(potential_messages) == 1:
validator_messages.append(potential_messages[0])
else:
# Either multiple validators matched or none did in which case we don't support
# this so just fallback.
return ConfigValidator.pretty_fallback_message(e)
return "The value '{}' is not valid for the '{}' hyperparameter which expects one of the " \
"following: {}".format(e.instance, ".".join(e.path), "; or ".join(validator_messages))
else:
# Provide the default value.
return ConfigValidator.pretty_fallback_message(e)
except Exception:
return ConfigValidator.pretty_fallback_message(e)