Browse Source

change the error message about the `type` in optimizer config from list_err_msg to str_err_msg

tags/v1.1.0
luopengting 5 years ago
parent
commit
fc70687d52
2 changed files with 4 additions and 2 deletions
  1. +1
    -1
      mindinsight/optimizer/common/validator/optimizer_config.py
  2. +3
    -1
      tests/ut/optimizer/common/validator/test_optimizer_config.py

+ 1
- 1
mindinsight/optimizer/common/validator/optimizer_config.py View File

@@ -79,7 +79,7 @@ class ParameterSchema(Schema):


bounds = fields.List(fields.Number(error_messages=number_err_msg), error_messages=list_err_msg) bounds = fields.List(fields.Number(error_messages=number_err_msg), error_messages=list_err_msg)
choice = fields.List(fields.Number(error_messages=number_err_msg), error_messages=list_err_msg) choice = fields.List(fields.Number(error_messages=number_err_msg), error_messages=list_err_msg)
type = fields.Str(error_messages=list_err_msg)
type = fields.Str(error_messages=str_err_msg)
source = fields.Str(error_messages=str_err_msg) source = fields.Str(error_messages=str_err_msg)


@validates("bounds") @validates("bounds")


+ 3
- 1
tests/ut/optimizer/common/validator/test_optimizer_config.py View File

@@ -65,12 +65,14 @@ class TestOptimizerConfig:
config_dict['target']['goal'] = init_list config_dict['target']['goal'] = init_list
config_dict['parameters']['learning_rate']['bounds'] = init_str config_dict['parameters']['learning_rate']['bounds'] = init_str
config_dict['parameters']['learning_rate']['choice'] = init_str config_dict['parameters']['learning_rate']['choice'] = init_str
config_dict['parameters']['learning_rate']['type'] = init_list
expected_err = { expected_err = {
'command': ["Value type should be 'str'."], 'command': ["Value type should be 'str'."],
'parameters': { 'parameters': {
'learning_rate': { 'learning_rate': {
'bounds': ["Value type should be 'list'."], 'bounds': ["Value type should be 'list'."],
'choice': ["Value type should be 'list'."]
'choice': ["Value type should be 'list'."],
'type': ["Value type should be 'str'."]
} }
}, },
'summary_base_dir': ["Value type should be 'str'."], 'summary_base_dir': ["Value type should be 'str'."],


Loading…
Cancel
Save