From 4b07a59cf5509bc9eff73303d514c371fd734e60 Mon Sep 17 00:00:00 2001 From: zhangyuge Date: Mon, 11 Nov 2019 12:22:54 +0800 Subject: [PATCH 1/2] show experiment name in nnictl list --- tools/nni_cmd/config_utils.py | 4 +++- tools/nni_cmd/constants.py | 2 +- tools/nni_cmd/launcher.py | 8 +++++--- tools/nni_cmd/nnictl_utils.py | 29 +++++++++++++++++++++-------- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/tools/nni_cmd/config_utils.py b/tools/nni_cmd/config_utils.py index c7c88bcf3e..97a26cd999 100644 --- a/tools/nni_cmd/config_utils.py +++ b/tools/nni_cmd/config_utils.py @@ -72,7 +72,7 @@ def __init__(self): self.experiment_file = os.path.join(NNICTL_HOME_DIR, '.experiment') self.experiments = self.read_file() - def add_experiment(self, expId, port, time, file_name, platform): + def add_experiment(self, expId, port, time, file_name, platform, author_name, experiment_name): '''set {key:value} paris to self.experiment''' self.experiments[expId] = {} self.experiments[expId]['port'] = port @@ -81,6 +81,8 @@ def add_experiment(self, expId, port, time, file_name, platform): self.experiments[expId]['status'] = 'INITIALIZED' self.experiments[expId]['fileName'] = file_name self.experiments[expId]['platform'] = platform + self.experiments[expId]['authorName'] = author_name + self.experiments[expId]['experimentName'] = experiment_name self.write_file() def update_experiment(self, expId, key, value): diff --git a/tools/nni_cmd/constants.py b/tools/nni_cmd/constants.py index 0777d2db98..419433d0d8 100644 --- a/tools/nni_cmd/constants.py +++ b/tools/nni_cmd/constants.py @@ -66,7 +66,7 @@ '%s\n' \ '----------------------------------------------------------------------------------------\n' -EXPERIMENT_DETAIL_FORMAT = 'Id: %s Status: %s Port: %s Platform: %s StartTime: %s EndTime: %s \n' +EXPERIMENT_DETAIL_FORMAT = 'Id: %s Name: %s Status: %s Port: %s Platform: %s StartTime: %s EndTime: %s\n' EXPERIMENT_MONITOR_INFO = 'Id: %s Status: %s Port: %s Platform: %s \n' \ 'StartTime: %s Duration: %s' diff --git a/tools/nni_cmd/launcher.py b/tools/nni_cmd/launcher.py index f99f8dfe43..a1e03caf7a 100644 --- a/tools/nni_cmd/launcher.py +++ b/tools/nni_cmd/launcher.py @@ -478,10 +478,12 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen web_ui_url_list = get_local_urls(args.port) nni_config.set_config('webuiUrl', web_ui_url_list) - #save experiment information + # save experiment information nnictl_experiment_config = Experiments() - nnictl_experiment_config.add_experiment(experiment_id, args.port, start_time, config_file_name,\ - experiment_config['trainingServicePlatform']) + nnictl_experiment_config.add_experiment(experiment_id, args.port, start_time, config_file_name, + experiment_config['trainingServicePlatform'], + experiment_config['authorName'], + experiment_config['experimentName']) print_normal(EXPERIMENT_SUCCESS_INFO % (experiment_id, ' '.join(web_ui_url_list))) diff --git a/tools/nni_cmd/nnictl_utils.py b/tools/nni_cmd/nnictl_utils.py index 4cadce182d..8045be66d2 100644 --- a/tools/nni_cmd/nnictl_utils.py +++ b/tools/nni_cmd/nnictl_utils.py @@ -99,9 +99,13 @@ def check_experiment_id(args, update=True): print_error('There are multiple experiments, please set the experiment id...') experiment_information = "" for key in running_experiment_list: - experiment_information += (EXPERIMENT_DETAIL_FORMAT % (key, experiment_dict[key]['status'], \ - experiment_dict[key]['port'], experiment_dict[key].get('platform'), experiment_dict[key]['startTime'],\ - experiment_dict[key]['endTime'])) + experiment_information += EXPERIMENT_DETAIL_FORMAT % (key, + experiment_dict[key].get('experimentName', 'N/A'), + experiment_dict[key]['status'], + experiment_dict[key]['port'], + experiment_dict[key].get('platform'), + experiment_dict[key]['startTime'], + experiment_dict[key]['endTime']) print(EXPERIMENT_INFORMATION_FORMAT % experiment_information) exit(1) elif not running_experiment_list: @@ -155,9 +159,13 @@ def parse_ids(args): print_error('There are multiple experiments, please set the experiment id...') experiment_information = "" for key in running_experiment_list: - experiment_information += (EXPERIMENT_DETAIL_FORMAT % (key, experiment_dict[key]['status'], \ - experiment_dict[key]['port'], experiment_dict[key].get('platform'), experiment_dict[key]['startTime'], \ - experiment_dict[key]['endTime'])) + experiment_information += EXPERIMENT_DETAIL_FORMAT % (key, + experiment_dict[key].get('experimentName', 'N/A'), + experiment_dict[key]['status'], + experiment_dict[key]['port'], + experiment_dict[key].get('platform'), + experiment_dict[key]['startTime'], + experiment_dict[key]['endTime']) print(EXPERIMENT_INFORMATION_FORMAT % experiment_information) exit(1) else: @@ -573,8 +581,13 @@ def experiment_list(args): print_warning('There is no experiment running...\nYou can use \'nnictl experiment list --all\' to list all experiments.') experiment_information = "" for key in experiment_id_list: - experiment_information += (EXPERIMENT_DETAIL_FORMAT % (key, experiment_dict[key]['status'], experiment_dict[key]['port'],\ - experiment_dict[key].get('platform'), experiment_dict[key]['startTime'], experiment_dict[key]['endTime'])) + experiment_information += EXPERIMENT_DETAIL_FORMAT % (key, + experiment_dict[key].get('experimentName', 'N/A'), + experiment_dict[key]['status'], + experiment_dict[key]['port'], + experiment_dict[key].get('platform'), + experiment_dict[key]['startTime'], + experiment_dict[key]['endTime']) print(EXPERIMENT_INFORMATION_FORMAT % experiment_information) def get_time_interval(time1, time2): From 45670644a30067010e14c8db991e277cf9cd1027 Mon Sep 17 00:00:00 2001 From: zhangyuge Date: Mon, 11 Nov 2019 13:39:41 +0800 Subject: [PATCH 2/2] remove author name in metadata --- tools/nni_cmd/config_utils.py | 3 +-- tools/nni_cmd/launcher.py | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/nni_cmd/config_utils.py b/tools/nni_cmd/config_utils.py index 97a26cd999..670121e95b 100644 --- a/tools/nni_cmd/config_utils.py +++ b/tools/nni_cmd/config_utils.py @@ -72,7 +72,7 @@ def __init__(self): self.experiment_file = os.path.join(NNICTL_HOME_DIR, '.experiment') self.experiments = self.read_file() - def add_experiment(self, expId, port, time, file_name, platform, author_name, experiment_name): + def add_experiment(self, expId, port, time, file_name, platform, experiment_name): '''set {key:value} paris to self.experiment''' self.experiments[expId] = {} self.experiments[expId]['port'] = port @@ -81,7 +81,6 @@ def add_experiment(self, expId, port, time, file_name, platform, author_name, ex self.experiments[expId]['status'] = 'INITIALIZED' self.experiments[expId]['fileName'] = file_name self.experiments[expId]['platform'] = platform - self.experiments[expId]['authorName'] = author_name self.experiments[expId]['experimentName'] = experiment_name self.write_file() diff --git a/tools/nni_cmd/launcher.py b/tools/nni_cmd/launcher.py index a1e03caf7a..1452f343bb 100644 --- a/tools/nni_cmd/launcher.py +++ b/tools/nni_cmd/launcher.py @@ -482,7 +482,6 @@ def launch_experiment(args, experiment_config, mode, config_file_name, experimen nnictl_experiment_config = Experiments() nnictl_experiment_config.add_experiment(experiment_id, args.port, start_time, config_file_name, experiment_config['trainingServicePlatform'], - experiment_config['authorName'], experiment_config['experimentName']) print_normal(EXPERIMENT_SUCCESS_INFO % (experiment_id, ' '.join(web_ui_url_list)))