Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor nnictl to support listing stopped experiments. (#256) #40

Merged
merged 1 commit into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions docs/NNICTLDOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| --experiment, -e| False| |ID of the experiment you want to resume|
| id| False| |The id of the experiment you want to resume|
| --port, -p| False| |Rest port of the experiment you want to resume|



Expand Down Expand Up @@ -87,8 +88,8 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| id| False| |ID of the experiment you want to set|
| --filename, -f| True| |the file storing your new search space|
| --id, -i| False| |ID of the experiment you want to set|

* __nnictl update concurrency__
* Description
Expand All @@ -103,8 +104,8 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| id| False| |ID of the experiment you want to set|
| --value, -v| True| |the number of allowed concurrent trials|
| --id, -i| False| |ID of the experiment you want to set|

* __nnictl update duration__
* Description
Expand All @@ -119,8 +120,8 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| --value, -v| True| |the experiment duration will be NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days.|
| --id, -i| False| |ID of the experiment you want to set|
| id| False| |ID of the experiment you want to set|
| --value, -v| True| |the experiment duration will be NUMBER seconds. SUFFIX may be 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days.|


* __nnictl trial__
Expand All @@ -137,7 +138,7 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| --id, -i| False| |ID of the experiment you want to set|
| id| False| |ID of the experiment you want to set|

* __nnictl trial kill__
* Description
Expand All @@ -151,9 +152,8 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| id| False| |ID of the experiment you want to set|
| --trialid, -t| True| |ID of the trial you want to kill.|
| --id, -i| False| |ID of the experiment you want to set|




Expand All @@ -171,7 +171,7 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| --id, -i| False| |ID of the experiment you want to set|
| id| False| |ID of the experiment you want to set|


* __nnictl experiment status__
Expand All @@ -186,17 +186,23 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| --id, -i| False| |ID of the experiment you want to set|
| id| False| |ID of the experiment you want to set|


* __nnictl experiment list__
* Description

Show the id and start time of all running experiments.
Show the information of all the (running) experiments.
* Usage

nnictl experiment list

Options:

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| all| False| False|Show all of experiments, including stopped experiments.|



* __nnictl config show__
Expand All @@ -223,10 +229,11 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| id| False| |ID of the experiment you want to set|
| --head, -h| False| |show head lines of stdout|
| --tail, -t| False| |show tail lines of stdout|
| --path, -p| False| |show the path of stdout file|
| --id, -i| False| |ID of the experiment you want to set|


* __nnictl log stderr__
* Description
Expand All @@ -241,10 +248,11 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| id| False| |ID of the experiment you want to set|
| --head, -h| False| |show head lines of stderr|
| --tail, -t| False| |show tail lines of stderr|
| --path, -p| False| |show the path of stderr file|
| --id, -i| False| |ID of the experiment you want to set|


* __nnictl log trial__
* Description
Expand All @@ -259,7 +267,7 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| --id, -I| False| |the id of trial|
| id| False| |the id of trial|


### Manage webui
Expand All @@ -276,4 +284,4 @@ nnictl webui

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| --id, -i| False| |ID of the experiment you want to set|
| id| False| |ID of the experiment you want to set|
21 changes: 17 additions & 4 deletions tools/nnicmd/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

class Config:
'''a util class to load and save config'''
def __init__(self, port):
config_path = os.path.join(NNICTL_HOME_DIR, str(port))
def __init__(self, file_path):
config_path = os.path.join(NNICTL_HOME_DIR, str(file_path))
os.makedirs(config_path, exist_ok=True)
self.config_file = os.path.join(config_path, '.config')
self.config = self.read_file()
Expand Down Expand Up @@ -73,11 +73,24 @@ def __init__(self):
self.experiment_file = os.path.join(NNICTL_HOME_DIR, '.experiment')
self.experiments = self.read_file()

def add_experiment(self, id, port, time):
def add_experiment(self, id, port, time, file_name):
'''set {key:value} paris to self.experiment'''
self.experiments[id] = [port, time]
self.experiments[id] = {}
self.experiments[id]['port'] = port
self.experiments[id]['startTime'] = time
self.experiments[id]['endTime'] = 'N/A'
self.experiments[id]['status'] = 'running'
self.experiments[id]['fileName'] = file_name
self.write_file()

def update_experiment(self, id, key, value):
'''Update experiment'''
if id not in self.experiments:
return False
self.experiments[id][key] = value
self.write_file()
return True

def remove_experiment(self, id):
'''remove an experiment by id'''
if id in self.experiments:
Expand Down
4 changes: 3 additions & 1 deletion tools/nnicmd/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@
EXPERIMENT_START_FAILED_INFO = 'There is an experiment running in the port %d, please stop it first or set another port!\n' \
'You could use \'nnictl stop --port [PORT]\' command to stop an experiment!\nOr you could use \'nnictl create --config [CONFIG_PATH] --port [PORT]\' to set port!\n'

EXPERIMENT_ID_INFO = '-----------------------------------------------------------------------\n' \
EXPERIMENT_INFORMATION_FORMAT = '-----------------------------------------------------------------------\n' \
' Experiment information\n' \
'%s\n' \
'-----------------------------------------------------------------------\n'

EXPERIMENT_DETAIL_FORMAT = 'Id: %s Status: %s StartTime: %s EndTime: %s \n'

PACKAGE_REQUIREMENTS = {
'SMAC': 'smac_tuner'
}
Expand Down
Loading