Unverified Commit 59ce65c5 authored by SparkSnail's avatar SparkSnail Committed by GitHub
Browse files

fix nnictl log trial bug (#1550)

parent 55f48d27
......@@ -351,6 +351,7 @@ def log_stderr(args):
def log_trial(args):
''''get trial log path'''
trial_id_path_dict = {}
trial_id_list = []
nni_config = Config(get_config_filename(args))
rest_port = nni_config.get_config('restServerPort')
rest_pid = nni_config.get_config('restServerPid')
......@@ -363,23 +364,27 @@ def log_trial(args):
if response and check_response(response):
content = json.loads(response.text)
for trial in content:
trial_id_path_dict[trial['id']] = trial['logPath']
trial_id_list.append(trial.get('id'))
if trial.get('logPath'):
trial_id_path_dict[trial.get('id')] = trial['logPath']
else:
print_error('Restful server is not running...')
exit(1)
if args.id:
if args.trial_id:
if args.trial_id not in trial_id_list:
print_error('Trial id {0} not correct, please check your command!'.format(args.trial_id))
exit(1)
if trial_id_path_dict.get(args.trial_id):
print_normal('id:' + args.trial_id + ' path:' + trial_id_path_dict[args.trial_id])
else:
print_error('trial id is not valid.')
exit(1)
else:
print_error('please specific the trial id.')
print_error('Log path is not available yet, please wait...')
exit(1)
else:
print_normal('All of trial log info:')
for key in trial_id_path_dict:
print('id:' + key + ' path:' + trial_id_path_dict[key])
print_normal('id:' + key + ' path:' + trial_id_path_dict[key])
if not trial_id_path_dict:
print_normal('None')
def get_config(args):
'''get config info'''
......
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