Commit e6b3828c authored by Lee's avatar Lee Committed by SparkSnail
Browse files

Revert to orginal `nnictl log trial` and `nnictl trial kill` (#988)

* Revert to orginal `nnictl log trial` and `nnictl trial kill`

* Change print() to print_normal()
parent fcbb0ea3
......@@ -287,8 +287,8 @@ Debug mode will disable version check function in Trialkeeper.
|Name, shorthand|Required|Default|Description|
|------|------|------ |------|
|id| False| |ID of the trial to be killed|
|--experiment, -E| True| |Experiment id of the trial|
|id| False| |Experiment ID of the trial|
|--trial_id, -T| True| |ID of the trial you want to kill.|
* Example
......@@ -538,8 +538,8 @@ Debug mode will disable version check function in Trialkeeper.
|Name, shorthand|Required|Default|Description|
|------|------|------ |------|
|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.|
|id| False| |Experiment ID of the trial|
|--trial_id, -T| False| |ID of the trial to be found the log path, required when id is not empty.|
<a name="webui"></a>
![](https://placehold.it/15/1589F0/000000?text=+) `Manage webui`
......@@ -566,7 +566,7 @@ Debug mode will disable version check function in Trialkeeper.
|Name, shorthand|Required|Default|Description|
|------|------|------ |------|
|id| False| |ID of the experiment you want to set|
|--trialid| False| |ID of the trial|
|--trial_id, -T| False| |ID of the trial|
|--port| False| 6006|The port of the tensorboard process|
* Detail
......@@ -575,7 +575,7 @@ Debug mode will disable version check function in Trialkeeper.
2. If you want to use tensorboard, you need to write your tensorboard log data to environment variable [NNI_OUTPUT_DIR] path.
3. In local mode, nnictl will set --logdir=[NNI_OUTPUT_DIR] directly and start a tensorboard process.
4. In remote mode, nnictl will create a ssh client to copy log data from remote machine to local temp directory firstly, and then start a tensorboard process in your local machine. You need to notice that nnictl only copy the log data one time when you use the command, if you want to see the later result of tensorboard, you should execute nnictl tensorboard command again.
5. If there is only one trial job, you don't need to set trialid. If there are multiple trial jobs running, you should set the trialid, or you could use [nnictl tensorboard start --trialid all] to map --logdir to all trial log paths.
5. If there is only one trial job, you don't need to set trial id. If there are multiple trial jobs running, you should set the trial id, or you could use [nnictl tensorboard start --trial_id all] to map --logdir to all trial log paths.
* __nnictl tensorboard stop__
* Description
......
......@@ -98,8 +98,8 @@ def parse_args():
parser_trial_ls.add_argument('id', nargs='?', help='the id of experiment')
parser_trial_ls.set_defaults(func=trial_ls)
parser_trial_kill = parser_trial_subparsers.add_parser('kill', help='kill trial jobs')
parser_trial_kill.add_argument('id', nargs='?', help='id of the trial to be killed')
parser_trial_kill.add_argument('--experiment', '-E', required=True, dest='experiment', help='experiment id of the trial')
parser_trial_kill.add_argument('id', nargs='?', help='the id of experiment')
parser_trial_kill.add_argument('--trial_id', '-T', required=True, dest='trial_id', help='the id of trial to be killed')
parser_trial_kill.set_defaults(func=trial_kill)
parser_trial_export = parser_trial_subparsers.add_parser('export', help='export trial job results to csv')
parser_trial_export.add_argument('id', nargs='?', help='the id of experiment')
......@@ -153,8 +153,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.set_defaults(func=log_stderr)
parser_log_trial = parser_log_subparsers.add_parser('trial', help='get trial log path')
parser_log_trial.add_argument('id', nargs='?', help='id of the trial to be found the log path')
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.add_argument('id', nargs='?', help='the id of experiment')
parser_log_trial.add_argument('--trial_id', '-T', dest='trial_id', help='find trial log path by id')
parser_log_trial.set_defaults(func=log_trial)
#parse package command
......@@ -172,7 +172,7 @@ def parse_args():
parser_tensorboard_subparsers = parser_tensorboard.add_subparsers()
parser_tensorboard_start = parser_tensorboard_subparsers.add_parser('start', help='start tensorboard')
parser_tensorboard_start.add_argument('id', nargs='?', help='the id of experiment')
parser_tensorboard_start.add_argument('--trialid', dest='trialid', help='the id of trial')
parser_tensorboard_start.add_argument('--trial_id', '-T', dest='trial_id', help='the id of trial')
parser_tensorboard_start.add_argument('--port', dest='port', default=6006, help='the port to start tensorboard')
parser_tensorboard_start.set_defaults(func=start_tensorboard)
parser_tensorboard_start = parser_tensorboard_subparsers.add_parser('stop', help='stop tensorboard')
......
......@@ -103,14 +103,11 @@ def check_experiment_id(args):
return None
else:
return running_experiment_list[0]
if hasattr(args, "experiment"):
if experiment_dict.get(args.experiment):
return args.experiment
elif hasattr(args, "id"):
if experiment_dict.get(args.id):
return args.id
print_error('Id not correct!')
return None
if experiment_dict.get(args.id):
return args.id
else:
print_error('Id not correct!')
return None
def parse_ids(args):
'''Parse the arguments for nnictl stop
......@@ -357,16 +354,15 @@ def log_trial(args):
else:
print_error('Restful server is not running...')
exit(1)
if args.experiment:
if args.id:
if trial_id_path_dict.get(args.id):
print('id:' + args.id + ' path:' + trial_id_path_dict[args.id])
if args.id:
if args.trial_id:
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("trial id list in this experiment: " + str(list(trial_id_path_dict.keys())))
exit(1)
else:
for key in trial_id_path_dict:
......
......@@ -40,7 +40,7 @@ def parse_log_path(args, trial_content):
path_list = []
host_list = []
for trial in trial_content:
if args.trialid and args.trialid != 'all' and trial.get('id') != args.trialid:
if args.trial_id and args.trial_id != 'all' and trial.get('id') != args.trial_id:
continue
pattern = r'(?P<head>.+)://(?P<host>.+):(?P<path>.*)'
match = re.search(pattern,trial['logPath'])
......@@ -48,7 +48,7 @@ def parse_log_path(args, trial_content):
path_list.append(match.group('path'))
host_list.append(match.group('host'))
if not path_list:
print_error('Trial id %s error!' % args.trialid)
print_error('Trial id %s error!' % args.trial_id)
exit(1)
return path_list, host_list
......@@ -154,7 +154,7 @@ def start_tensorboard(args):
if not trial_content:
print_error('No trial information!')
exit(1)
if len(trial_content) > 1 and not args.trialid:
if len(trial_content) > 1 and not args.trial_id:
print_error('There are multiple trials, please set trial id!')
exit(1)
experiment_id = nni_config.get_config('experimentId')
......
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