Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Support multiple experiments (#194)
Browse files Browse the repository at this point in the history
* fix nnictl bug

* fix nnictl create bug

* add experiment status logic

* add more information for nnictl

* fix Evolution Tuner bug

* refactor code

* fix code in updater.py

* fix nnictl --help

* fix classArgs bug

* update check response.status_code logic

* show trial log path

* update document

* fix install.sh

* set default vallue for maxTrialNum and maxExecDuration

* fix nnictl

* fix config path hint

* support multiPhase

* fix bash-completion

* refactor bash-completion

* add sklearn-regression

* add search_space

* fix bug

* fix install.sh

* refactor code

* remove unused code

* support multi experiments

* fix issues

* Support multiple experiments of nnictl (#183)

* fix nnictl bug

* fix nnictl create bug

* add experiment status logic

* add more information for nnictl

* fix Evolution Tuner bug

* refactor code

* fix code in updater.py

* fix nnictl --help

* fix classArgs bug

* update check response.status_code logic

* show trial log path

* update document

* fix install.sh

* set default vallue for maxTrialNum and maxExecDuration

* fix nnictl

* fix config path hint

* support multiPhase

* fix bash-completion

* refactor bash-completion

* add sklearn-regression

* add search_space

* fix bug

* fix install.sh

* refactor code

* remove unused code

* support multi experiments

* fix issues

* Let nni manager web server handle static content

* set nnictl stop require the port

* Support multiple experiments of nnictl (#183)

* fix nnictl bug

* fix nnictl create bug

* add experiment status logic

* add more information for nnictl

* fix Evolution Tuner bug

* refactor code

* fix code in updater.py

* fix nnictl --help

* fix classArgs bug

* update check response.status_code logic

* show trial log path

* update document

* fix install.sh

* set default vallue for maxTrialNum and maxExecDuration

* fix nnictl

* fix config path hint

* support multiPhase

* fix bash-completion

* refactor bash-completion

* add sklearn-regression

* add search_space

* fix bug

* fix install.sh

* refactor code

* remove unused code

* support multi experiments

* fix issues

* Let nni manager web server handle static content

* Dev multiple experiments (#189)

* fix nnictl bug

* fix nnictl create bug

* add experiment status logic

* add more information for nnictl

* fix Evolution Tuner bug

* refactor code

* fix code in updater.py

* fix nnictl --help

* fix classArgs bug

* update check response.status_code logic

* show trial log path

* update document

* fix install.sh

* set default vallue for maxTrialNum and maxExecDuration

* fix nnictl

* fix config path hint

* support multiPhase

* fix bash-completion

* refactor bash-completion

* add sklearn-regression

* add search_space

* fix bug

* fix install.sh

* refactor code

* remove unused code

* support multi experiments

* fix issues

* set nnictl stop require the port

* Update documents for supporting multiple experiments

* create a constant variable for 51188

* Fixed issue that WebUI can not refresh page

* Upgrade Node.js and Yarn to latest version
  • Loading branch information
goooxu authored Oct 11, 2018
1 parent c0d13c7 commit 0da67d7
Show file tree
Hide file tree
Showing 21 changed files with 127 additions and 343 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ language: python
python:
- "3.6"
before_install:
- wget https://nodejs.org/dist/v10.10.0/node-v10.10.0-linux-x64.tar.xz
- tar xf node-v10.10.0-linux-x64.tar.xz
- sudo mv node-v10.10.0-linux-x64 /usr/local/node
- wget https://nodejs.org/dist/v10.12.0/node-v10.12.0-linux-x64.tar.xz
- tar xf node-v10.12.0-linux-x64.tar.xz
- sudo mv node-v10.12.0-linux-x64 /usr/local/node
- export PATH=/usr/local/node/bin:$PATH
- sudo sh -c 'PATH=/usr/local/node/bin:$PATH yarn global add serve'
install:
- make
- make easy-install
Expand Down
46 changes: 9 additions & 37 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,14 @@ else # is normal user
endif

## Dependency information
NODE_VERSION ?= v10.10.0
NODE_VERSION ?= v10.12.0
NODE_TARBALL ?= node-$(NODE_VERSION)-linux-x64.tar.xz
NODE_PATH ?= $(INSTALL_PREFIX)/nni/node

YARN_VERSION ?= v1.9.4
YARN_VERSION ?= v1.10.1
YARN_TARBALL ?= yarn-$(YARN_VERSION).tar.gz
YARN_PATH ?= /tmp/nni-yarn

SERVE_VERSION ?= 10.0.1
SERVE_TARBALL ?= serve-$(SERVE_VERSION).tgz
SERVE_PATH ?= $(INSTALL_PREFIX)/nni/serve


## Check if dependencies have been installed globally
ifeq (, $(shell command -v node 2>/dev/null))
$(info $(_INFO) Node.js not found $(_END))
Expand All @@ -57,21 +52,15 @@ ifeq (, $(shell command -v yarnpkg 2>/dev/null))
$(info $(_INFO) Yarn not found $(_END))
_MISS_DEPS := 1 # yarn not found
endif
ifeq (, $(shell command -v serve 2>/dev/null))
$(info $(_INFO) Serve not found $(_END))
_MISS_DEPS := 1 # serve not found
endif

ifdef _MISS_DEPS
$(info $(_INFO) Missing dependencies, use local toolchain $(_END))
NODE := $(NODE_PATH)/bin/node
YARN := PATH=$${PATH}:$(NODE_PATH)/bin $(YARN_PATH)/bin/yarn
SERVE := $(SERVE_PATH)/serve
else
$(info $(_INFO) All dependencies found, use global toolchain $(_END))
NODE := node
YARN := yarnpkg
SERVE := serve
endif


Expand All @@ -85,7 +74,7 @@ build:
#$(_INFO) Building NNI Manager $(_END)
cd src/nni_manager && $(YARN) && $(YARN) build

#$(_INFO) Building Web UI $(_END)
#$(_INFO) Building WebUI $(_END)
cd src/webui && $(YARN) && $(YARN) build

#$(_INFO) Building Python SDK $(_END)
Expand Down Expand Up @@ -169,19 +158,13 @@ $(YARN_TARBALL):
#$(_INFO) Downloading Yarn $(_END)
wget https://github.com/yarnpkg/yarn/releases/download/$(YARN_VERSION)/$(YARN_TARBALL)

$(SERVE_TARBALL):
#$(_INFO) Downloading serve $(_END)
wget https://registry.npmjs.org/serve/-/$(SERVE_TARBALL)

.PHONY: intall-dependencies
install-dependencies: $(NODE_TARBALL) $(YARN_TARBALL) $(SERVE_TARBALL)
install-dependencies: $(NODE_TARBALL) $(YARN_TARBALL)
#$(_INFO) Cleaning $(_END)
rm -rf $(NODE_PATH)
rm -rf $(YARN_PATH)
rm -rf $(SERVE_PATH)
mkdir -p $(NODE_PATH)
mkdir -p $(YARN_PATH)
mkdir -p $(SERVE_PATH)

#$(_INFO) Extracting Node.js $(_END)
tar -xf $(NODE_TARBALL)
Expand All @@ -190,15 +173,6 @@ install-dependencies: $(NODE_TARBALL) $(YARN_TARBALL) $(SERVE_TARBALL)
#$(_INFO) Extracting Yarn $(_END)
tar -xf $(YARN_TARBALL)
mv -fT yarn-$(YARN_VERSION) $(YARN_PATH)

#$(_INFO) Installing serve $(_END)
PATH=$${PATH}:$(NODE_PATH)/bin npm install --prefix $(SERVE_PATH) $(SERVE_TARBALL)

#$(_INFO) Creating serve executable script $(_END)
echo '#!/bin/sh' > $(SERVE_PATH)/serve
echo '$(NODE) $(SERVE_PATH)/node_modules/serve/bin/serve.js $$@' >> $(SERVE_PATH)/serve
chmod +x $(SERVE_PATH)/serve


.PHONY: install-python-modules
install-python-modules:
Expand All @@ -217,8 +191,8 @@ install-node-modules:
cp -rT src/nni_manager/dist $(INSTALL_PREFIX)/nni/nni_manager
cp -rT src/nni_manager/node_modules $(INSTALL_PREFIX)/nni/nni_manager/node_modules

#$(_INFO) Installing Web UI $(_END)
cp -rT src/webui/build $(INSTALL_PREFIX)/nni/webui
#$(_INFO) Installing WebUI $(_END)
cp -rT src/webui/build $(INSTALL_PREFIX)/nni/nni_manager/static


.PHONY: install-dev-modules
Expand All @@ -235,8 +209,8 @@ install-dev-modules:
ln -sf ${PWD}/src/nni_manager/dist $(INSTALL_PREFIX)/nni/nni_manager
ln -sf ${PWD}/src/nni_manager/node_modules $(INSTALL_PREFIX)/nni/nni_manager/node_modules

#$(_INFO) Installing Web UI $(_END)
ln -sf ${PWD}/src/webui/build $(INSTALL_PREFIX)/nni/webui
#$(_INFO) Installing WebUI $(_END)
ln -sf ${PWD}/src/webui/build $(INSTALL_PREFIX)/nni/nni_manager/static


.PHONY: install-scripts
Expand All @@ -250,8 +224,6 @@ install-scripts:

echo '#!/bin/sh' > $(BIN_PATH)/nnictl
echo 'NNI_MANAGER=$(BIN_PATH)/nnimanager \' >> $(BIN_PATH)/nnictl
echo 'NNI_SERVE=$(SERVE) \' >> $(BIN_PATH)/nnictl
echo 'WEB_UI_FOLDER=$(INSTALL_PREFIX)/nni/webui \' >> $(BIN_PATH)/nnictl
echo 'python3 -m nnicmd.nnictl $$@' >> $(BIN_PATH)/nnictl
chmod +x $(BIN_PATH)/nnictl

Expand Down Expand Up @@ -300,7 +272,7 @@ ifdef _ROOT
$(error You should not develop NNI as root)
endif
ifdef _MISS_DEPS
# $(error Please install Node.js, Yarn, and Serve to develop NNI)
# $(error Please install Node.js and Yarn to develop NNI)
endif
#$(_INFO) Pass! $(_END)

Expand Down
12 changes: 5 additions & 7 deletions README.Makefile.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ The targets will be detailed later.

NNI requires at least Node.js, Yarn, and PIP to build, while TypeScript is also recommended.

NNI requires Node.js, serve, and all dependency libraries to run.
NNI requires Node.js, and all dependency libraries to run.
Required Node.js libraries (including TypeScript) can be installed by Yarn, and required Python libraries can be installed by setuptools or PIP.

For NNI *users*, `make install-dependencies` can be used to install Node.js, Yarn, and serve.
This will install Node.js and serve to NNI's installation directory, and install Yarn to `/tmp/nni-yarn`.
For NNI *users*, `make install-dependencies` can be used to install Node.js and Yarn.
This will install Node.js to NNI's installation directory, and install Yarn to `/tmp/nni-yarn`.
This target requires wget to work.

For NNI *developers*, it is recommended to install Node.js, Yarn, and serve manually.
For NNI *developers*, it is recommended to install Node.js and Yarn manually.
See their official sites for installation guide.

## Building NNI
Expand All @@ -42,7 +42,7 @@ When install as non-priviledged user and virtualenv is not detected, `--user` fl

In addition, `nnictl` offers a bash completion scripts, which will be installed to `/usr/share/bash-completion/completions` or `~/.bash_completion.d`.

In some configuration, NNI will also install Node.js and the serve module to `/usr/share/nni`.
In some configuration, NNI will also install Node.js to `/usr/share/nni`.

All directories mentioned above are configurable. See next section for details.

Expand All @@ -60,10 +60,8 @@ Available variables are listed below:
| `BASH_COMP_SCRIPT` | Path of bash completion script | `~/.bash_completion.d/nnictl` | `/usr/share/bash-completion/completions/nnictl` |
| `PIP_MODE` | Arguments for `python3 setup.py install` | `--user` if `VIRTUAL_ENV` not set | (empty) |
| `NODE_PATH` | Path to install Node.js runtime | `$INSTALL_PREFIX/nni/node` | `$INSTALL_PREFIX/nni/node` |
| `SERVE_PATH` | Path to install serve package | `$INSTALL_PREFIX/nni/serve` | `$INSTALL_PREFIX/nni/serve` |
| `YARN_PATH` | Path to install Yarn | `/tmp/nni-yarn` | `/tmp/nni-yarn` |
| `NODE` | Node.js command | see source file | see source file |
| `SERVE` | serve command | see source file | see source file |
| `YARN` | Yarn command | see source file | see source file |

Note that these variables will influence installation destination as well as generated `nnictl` and `nnimanager` scripts.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ Try it out:
nnictl create --config ~/nni/examples/trials/mnist/config.yml
```

In the command output, find out the **Web UI url** and open it in your browser. You can analyze your experiment through WebUI, or browse trials' tensorboard.
In the command output, find out the **WebUI url** and open it in your browser. You can analyze your experiment through WebUI, or browse trials' tensorboard.

To learn more about how this example was constructed and how to analyze the experiment results in NNI Web UI, please refer to [How to write a trial run on NNI (MNIST as an example)?](docs/WriteYourTrial.md)
To learn more about how this example was constructed and how to analyze the experiment results in NNI WebUI, please refer to [How to write a trial run on NNI (MNIST as an example)?](docs/WriteYourTrial.md)

## **Please refer to [Get Started Tutorial](docs/GetStarted.md) for more detailed information.**
## More tutorials
Expand Down
2 changes: 1 addition & 1 deletion docs/HowToContribute.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ For example, run the command
```
nnictl create --config ~/nni/examples/trials/mnist/config.yml
```
And open web ui to check if everything is OK
And open WebUI to check if everything is OK

**6. Redeploy**

Expand Down
43 changes: 1 addition & 42 deletions docs/NNICTLDOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ nnictl stop
nnictl update
nnictl resume
nnictl trial
nnictl webui
nnictl experiment
nnictl config
nnictl log
Expand All @@ -33,9 +32,7 @@ nnictl log

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| --config, -c| True| |yaml configure file of the experiment|
| --webuiport, -w| False| 8080|assign a port for webui|

| --config, -c| True| |yaml configure file of the experiment|

* __nnictl resume__
Expand Down Expand Up @@ -140,44 +137,6 @@ nnictl log

### Manage WebUI
* __nnictl webui start__
* Description

Start web ui function for nni, and will get a url list, you can open any of the url to see nni web page.

* Usage

nnictl webui start [OPTIONS]

Options:

| Name, shorthand | Required|Default | Description |
| ------ | ------ | ------ |------ |
| --port, -p| False| 8080|assign a port for webui|


* __nnictl webui stop__
* Description

Stop web ui function, and release url occupied. If you want to start again, use 'nnictl start webui' command
* Usage
nnictl webui stop
* __nnictl webui url__
* Description

Show the urls of web ui.
* Usage
nnictl webui url



### Manage experiment information

* __nnictl experiment show__
Expand Down
2 changes: 1 addition & 1 deletion docs/PAIMode.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ You can see the pai jobs created by NNI in your OpenPAI cluster's web portal, li

Notice: In pai mode, NNIManager will start a rest server and listen on `51189` port, to receive metrics from trial job running in PAI container. So you should `enable 51189` TCP port in your firewall rule to allow incoming traffic.

Once a trial job is completed, you can goto NNI WebUI's overview page (like http://localhost:8080/oview) to check trial's information.
Once a trial job is completed, you can goto NNI WebUI's overview page (like http://localhost:51188/oview) to check trial's information.

Expand a trial information in trial list view, click the logPath link like:
![](./nni_webui_joblist.jpg)
Expand Down
2 changes: 1 addition & 1 deletion docs/RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Initial release of Neural Network Intelligence (NNI).
* Provide Python API for user to wrap trial code as NNI deployable codes
* Experiments
* Provide a command line toolkit 'nnictl' for experiments management
* Provide a web UI for viewing experiments details and managing experiments
* Provide a WebUI for viewing experiments details and managing experiments
* Continuous Integration
* Support CI by providing out-of-box integration with [travis-ci](https://github.com/travis-ci) on ubuntu
* Others
Expand Down
8 changes: 4 additions & 4 deletions docs/StartExperiment.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ NNICTL need to set experiment config before start an experiment, experiment conf
### 2.5 Check experiment cofig
NNICTL will ensure the request to set config is successfully executed.

### 2.6 Start Web UI
NNICTL will start a Web UI process to show Web UI information,the default port of Web UI is 8080.
### 2.6 Start WebUI
NNICTL will start a WebUI to show information,the default port of WebUI is 51188.

### 2.7 Check Web UI
If Web UI is not successfully started, nnictl will give a warning information, and will continue to start experiment.
### 2.7 Check WebUI
If WebUI is not successfully started, nnictl will give a warning information, and will continue to start experiment.

### 2.8 Start Experiment
This is the most import step of starting an nni experiment, nnictl will call restful server process to setup an experiment.
Expand Down
8 changes: 5 additions & 3 deletions src/nni_manager/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ function usage(): void {
console.info('usage: node main.js --port <port> --mode <local/remote/pai> --start_mode <new/resume> --experiment_id <id>');
}

let port: number = NNIRestServer.DEFAULT_PORT;
const strPort: string = parseArg(['--port', '-p']);
if (strPort && strPort.length > 0) {
port = parseInt(strPort, 10);
if (!strPort || strPort.length === 0) {
usage();
process.exit(1);
}

const port: number = parseInt(strPort, 10);

const mode: string = parseArg(['--mode', '-m']);
if (!['local', 'remote', 'pai'].includes(mode)) {
usage();
Expand Down
14 changes: 8 additions & 6 deletions src/nni_manager/rest_server/nniRestServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,39 @@

'use strict';

import * as express from 'express';
import * as bodyParser from 'body-parser';
import * as path from 'path';
import * as component from '../common/component';
import { RestServer } from '../common/restServer'
import { createRestHandler } from './restHandler';

/**
* NNI Main rest server, provides rest API to support
* # nnictl CLI tool
* # NNI Web UI
* # NNI WebUI
*
*/
@component.Singleton
export class NNIRestServer extends RestServer{
/** NNI main rest service default port */
public static readonly DEFAULT_PORT: number = 51188;

export class NNIRestServer extends RestServer {
private readonly API_ROOT_URL: string = '/api/v1/nni';

/**
* constructor to provide NNIRestServer's own rest property, e.g. port
*/
constructor() {
super();
this.port = NNIRestServer.DEFAULT_PORT;
}

/**
* NNIRestServer's own router registration
*/
protected registerRestHandler(): void {
this.app.use(express.static('static'));
this.app.use(bodyParser.json());
this.app.use(this.API_ROOT_URL, createRestHandler(this));
this.app.get('*', (req: express.Request, res: express.Response) => {
res.sendFile(path.resolve('static/index.html'));
});
}
}
2 changes: 1 addition & 1 deletion src/webui/src/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const MANAGER_IP = `${window.location.protocol}//${window.location.hostname}:51188/api/v1/nni`;
export const MANAGER_IP = `/api/v1/nni`;
export const trialJobStatus = [
'UNKNOWN',
'WAITING',
Expand Down
2 changes: 1 addition & 1 deletion test/naive/nnictl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
WEB_UI_FOLDER=${PWD}/../../src/webui python3 -m nnicmd.nnictl $@
python3 -m nnicmd.nnictl $@
3 changes: 1 addition & 2 deletions tools/bash-completion
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# list of commands/arguments
__nnictl_cmds="create resume update stop trial webui experiment config rest log"
__nnictl_cmds="create resume update stop trial experiment config rest log"
__nnictl_create_cmds="--config --webuiport"
__nnictl_resume_cmds="--experiment --manager --webuiport"
__nnictl_update_cmds="searchspace concurrency duration"
Expand All @@ -17,7 +17,6 @@ __nnictl_log_cmds="stdout stderr"
__nnictl_log_stdout_cmds="--tail --head --path"
__nnictl_log_stderr_cmds="--tail --head --path"


# list of arguments that accept a file name
__nnictl_file_args=" --config -c --filename -f "

Expand Down
Loading

0 comments on commit 0da67d7

Please sign in to comment.