Unverified Commit 3423117d authored by Yuge Zhang's avatar Yuge Zhang Committed by GitHub
Browse files

Add config v2 example and refine validation error message (#3248)

parent bdb2826e
searchSpace:
momentum:
_type: uniform
_value: [0, 1]
hidden_size:
_type: choice
_value: [128, 256, 512, 1024]
batch_size:
_type: choice
_value: [16, 32, 64, 128]
lr:
_type: choice
_value: [0.0001, 0.001, 0.01, 0.1]
trainingService:
platform: local
trialCodeDirectory: .
trialCommand: python3 mnist.py
trialConcurrency: 1
trialGpuNumber: 0
tuner:
name: TPE
classArgs:
optimize_mode: maximize
searchSpace:
dropout_rate:
_type: uniform
_value: [0.5, 0.9]
conv_size:
_type: choice
_value: [2, 3, 5, 7]
hidden_size:
_type: choice
_value: [128, 512, 1024]
batch_size:
_type: choice
_value: [16, 32]
learning_rate:
_type: choice
_value: [0.0001, 0.001, 0.01, 0.1]
trainingService:
platform: local
trialCodeDirectory: .
trialCommand: python3 mnist.py
trialConcurrency: 1
trialGpuNumber: 0
tuner:
name: TPE
classArgs:
optimize_mode: maximize
...@@ -17,7 +17,7 @@ from .launcher_utils import validate_all_content ...@@ -17,7 +17,7 @@ from .launcher_utils import validate_all_content
from .rest_utils import rest_put, rest_post, check_rest_server, check_response from .rest_utils import rest_put, rest_post, check_rest_server, check_response
from .url_utils import cluster_metadata_url, experiment_url, get_local_urls from .url_utils import cluster_metadata_url, experiment_url, get_local_urls
from .config_utils import Config, Experiments from .config_utils import Config, Experiments
from .common_utils import get_yml_content, get_json_content, print_error, print_normal, \ from .common_utils import get_yml_content, get_json_content, print_error, print_normal, print_warning, \
detect_port, get_user detect_port, get_user
from .constants import NNICTL_HOME_DIR, ERROR_INFO, REST_TIME_OUT, EXPERIMENT_SUCCESS_INFO, LOG_HEADER from .constants import NNICTL_HOME_DIR, ERROR_INFO, REST_TIME_OUT, EXPERIMENT_SUCCESS_INFO, LOG_HEADER
...@@ -592,16 +592,21 @@ def create_experiment(args): ...@@ -592,16 +592,21 @@ def create_experiment(args):
print_error('Please set correct config path!') print_error('Please set correct config path!')
exit(1) exit(1)
experiment_config = get_yml_content(config_path) experiment_config = get_yml_content(config_path)
try:
config = ExperimentConfig(**experiment_config)
experiment_config = convert.to_v1_yaml(config)
except Exception:
pass
try: try:
validate_all_content(experiment_config, config_path) validate_all_content(experiment_config, config_path)
except Exception as e: except Exception:
print_error(e) print_warning('Validation with V1 schema failed. Trying to convert from V2 format...')
exit(1) try:
config = ExperimentConfig(**experiment_config)
experiment_config = convert.to_v1_yaml(config)
except Exception as e:
print_error(f'Conversion from v2 format failed: {repr(e)}')
try:
validate_all_content(experiment_config, config_path)
except Exception as e:
print_error(f'Config validation failed. {repr(e)}')
exit(1)
nni_config.set_config('experimentConfig', experiment_config) nni_config.set_config('experimentConfig', experiment_config)
nni_config.set_config('restServerPort', args.port) nni_config.set_config('restServerPort', args.port)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment