Commit 36401157 authored by Lee's avatar Lee Committed by xuehui
Browse files

Change the behavior of `nnictl log trial [--trialid TRIALID] [id]` (#900)

* add different tuner config files for config_test

* change MetisTuner config test due to no lightgbm python module in integration test

* install smac package in azure-pipelines

* SMAC need swig to be installed

* Try to install swig from source code

* remove SMAC test because the dependency can not be installed

* use sudo to install the swig

* sleep 10s to make sure the port has been released

* remove tuner test for networkmorphism because it uses more than 30s to release the tcp port

* word "down" to "done"

* add config test for Curvefitting assessor

* change file name

* Fix data type not match bug

* Optimize MetisTunner

* pretty the code

* Follow the review comment

* add exploration probability

* Avoid None type object generating

* fix nnictl log trial bug

* rollback chinese doc

* add argument 'experiment' to parser_log_trial and parser_trial_kill

* update doc
parent c29a0cc3
...@@ -207,8 +207,8 @@ nnictl support commands: ...@@ -207,8 +207,8 @@ nnictl support commands:
|Name, shorthand|Required|Default|Description| |Name, shorthand|Required|Default|Description|
|------|------|------ |------| |------|------|------ |------|
|id| False| |ID of the experiment you want to set| |id| False| |ID of the trial to be killed|
|--trialid, -t| True| |ID of the trial you want to kill.| |--experiment, -E| True| |Experiment id of the trial|
<a name="top"></a> <a name="top"></a>
* __nnictl top__ * __nnictl top__
...@@ -354,7 +354,8 @@ nnictl support commands: ...@@ -354,7 +354,8 @@ nnictl support commands:
|Name, shorthand|Required|Default|Description| |Name, shorthand|Required|Default|Description|
|------|------|------ |------| |------|------|------ |------|
|id| False| |the id of trial| |id| False| |ID of the trial to be found the log path|
|--experiment, -E| False| |Experiment ID of the trial, required when id is not empty.|
<a name="webui"></a> <a name="webui"></a>
### Manage webui ### Manage webui
......
...@@ -98,8 +98,8 @@ def parse_args(): ...@@ -98,8 +98,8 @@ def parse_args():
parser_trial_ls.add_argument('id', nargs='?', help='the id of experiment') parser_trial_ls.add_argument('id', nargs='?', help='the id of experiment')
parser_trial_ls.set_defaults(func=trial_ls) parser_trial_ls.set_defaults(func=trial_ls)
parser_trial_kill = parser_trial_subparsers.add_parser('kill', help='kill trial jobs') parser_trial_kill = parser_trial_subparsers.add_parser('kill', help='kill trial jobs')
parser_trial_kill.add_argument('id', nargs='?', help='the id of experiment') parser_trial_kill.add_argument('id', nargs='?', help='id of the trial to be killed')
parser_trial_kill.add_argument('--trialid', '-t', required=True, dest='trialid', help='the id of trial to be killed') parser_trial_kill.add_argument('--experiment', '-E', required=True, dest='experiment', help='experiment id of the trial')
parser_trial_kill.set_defaults(func=trial_kill) parser_trial_kill.set_defaults(func=trial_kill)
#parse experiment command #parse experiment command
...@@ -149,8 +149,8 @@ def parse_args(): ...@@ -149,8 +149,8 @@ def parse_args():
parser_log_stderr.add_argument('--path', action='store_true', default=False, help='get the path of stderr file') parser_log_stderr.add_argument('--path', action='store_true', default=False, help='get the path of stderr file')
parser_log_stderr.set_defaults(func=log_stderr) parser_log_stderr.set_defaults(func=log_stderr)
parser_log_trial = parser_log_subparsers.add_parser('trial', help='get trial log path') parser_log_trial = parser_log_subparsers.add_parser('trial', help='get trial log path')
parser_log_trial.add_argument('id', nargs='?', help='the id of experiment') parser_log_trial.add_argument('id', nargs='?', help='id of the trial to be found the log path')
parser_log_trial.add_argument('--trialid', '-T', dest='trialid', help='find trial log path by id') parser_log_trial.add_argument('--experiment', '-E', dest='experiment', help='experiment id of the trial, xperiment ID of the trial, required when id is not empty.')
parser_log_trial.set_defaults(func=log_trial) parser_log_trial.set_defaults(func=log_trial)
#parse package command #parse package command
......
...@@ -76,11 +76,14 @@ def check_experiment_id(args): ...@@ -76,11 +76,14 @@ def check_experiment_id(args):
return None return None
else: else:
return running_experiment_list[0] return running_experiment_list[0]
if experiment_dict.get(args.id): if hasattr(args, "experiment"):
return args.id if experiment_dict.get(args.experiment):
else: return args.experiment
print_error('Id not correct!') elif hasattr(args, "id"):
return None if experiment_dict.get(args.id):
return args.id
print_error('Id not correct!')
return None
def parse_ids(args): def parse_ids(args):
'''Parse the arguments for nnictl stop '''Parse the arguments for nnictl stop
...@@ -221,7 +224,7 @@ def trial_ls(args): ...@@ -221,7 +224,7 @@ def trial_ls(args):
response = rest_get(trial_jobs_url(rest_port), 20) response = rest_get(trial_jobs_url(rest_port), 20)
if response and check_response(response): if response and check_response(response):
content = json.loads(response.text) content = json.loads(response.text)
for index, value in enumerate(content): for index, value in enumerate(content):
content[index] = convert_time_stamp_to_date(value) content[index] = convert_time_stamp_to_date(value)
print(json.dumps(content, indent=4, sort_keys=True, separators=(',', ':'))) print(json.dumps(content, indent=4, sort_keys=True, separators=(',', ':')))
else: else:
...@@ -239,7 +242,7 @@ def trial_kill(args): ...@@ -239,7 +242,7 @@ def trial_kill(args):
return return
running, _ = check_rest_server_quick(rest_port) running, _ = check_rest_server_quick(rest_port)
if running: if running:
response = rest_delete(trial_job_id_url(rest_port, args.trialid), 20) response = rest_delete(trial_job_id_url(rest_port, args.id), 20)
if response and check_response(response): if response and check_response(response):
print(response.text) print(response.text)
else: else:
...@@ -327,14 +330,19 @@ def log_trial(args): ...@@ -327,14 +330,19 @@ def log_trial(args):
else: else:
print_error('Restful server is not running...') print_error('Restful server is not running...')
exit(1) exit(1)
if args.id: if args.experiment:
if trial_id_path_dict.get(args.id): if args.id:
print('id:' + args.id + ' path:' + trial_id_path_dict[args.id]) if trial_id_path_dict.get(args.id):
print('id:' + args.id + ' path:' + trial_id_path_dict[args.id])
else:
print_error('trial id is not valid!')
exit(1)
else: else:
print_error('trial id is not valid!') print_error('please specific the trial id!')
print_error("trial id list in this experiment: " + str(list(trial_id_path_dict.keys())))
exit(1) exit(1)
else: else:
for key in trial_id_path_dict.keys(): for key in trial_id_path_dict:
print('id:' + key + ' path:' + trial_id_path_dict[key]) print('id:' + key + ' path:' + trial_id_path_dict[key])
def get_config(args): def get_config(args):
...@@ -412,7 +420,7 @@ def show_experiment_info(): ...@@ -412,7 +420,7 @@ def show_experiment_info():
response = rest_get(trial_jobs_url(experiment_dict[key]['port']), 20) response = rest_get(trial_jobs_url(experiment_dict[key]['port']), 20)
if response and check_response(response): if response and check_response(response):
content = json.loads(response.text) content = json.loads(response.text)
for index, value in enumerate(content): for index, value in enumerate(content):
content[index] = convert_time_stamp_to_date(value) content[index] = convert_time_stamp_to_date(value)
print(TRIAL_MONITOR_CONTENT % (content[index].get('id'), content[index].get('startTime'), content[index].get('endTime'), content[index].get('status'))) print(TRIAL_MONITOR_CONTENT % (content[index].get('id'), content[index].get('startTime'), content[index].get('endTime'), content[index].get('status')))
print(TRIAL_MONITOR_TAIL) print(TRIAL_MONITOR_TAIL)
......
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