diff --git a/deployment/pypi/setup.py b/deployment/pypi/setup.py
index bd97927c3f..c0447b4f70 100644
--- a/deployment/pypi/setup.py
+++ b/deployment/pypi/setup.py
@@ -63,7 +63,7 @@
'psutil',
'requests',
'astor',
- 'pyhdfs',
+ 'PythonWebHDFS',
'hyperopt',
'json_tricks',
'numpy',
diff --git a/docs/en_US/Builtin_Assessors.md b/docs/en_US/Builtin_Assessors.md
index 2723c35eb9..479be0da9a 100644
--- a/docs/en_US/Builtin_Assessors.md
+++ b/docs/en_US/Builtin_Assessors.md
@@ -4,10 +4,14 @@ NNI provides state-of-the-art tuning algorithm in our builtin-assessors and make
Note: Click the **Assessor's name** to get a detailed description of the algorithm, click the corresponding **Usage** to get the Assessor's installation requirements, suggested scenario and using example.
+Currently we support the following Assessors:
+* [Medianstop](medianstopAssessor.md)
+* [Curvefitting](curvefittingAssessor.md)
+
|Assessor|Brief Introduction of Algorithm|
|---|---|
-|[Medianstop](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/medianstop_assessor/README.md) [(Usage)](#MedianStop)|Medianstop is a simple early stopping rule. It stops a pending trial X at step S if the trial’s best objective value by step S is strictly worse than the median value of the running averages of all completed trials’ objectives reported up to step S. [Reference Paper](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/46180.pdf)|
-|[Curvefitting](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/curvefitting_assessor/README.md) [(Usage)](#Curvefitting)|Curve Fitting Assessor is a LPA(learning, predicting, assessing) algorithm. It stops a pending trial X at step S if the prediction of final epoch's performance worse than the best final performance in the trial history. In this algorithm, we use 12 curves to fit the accuracy curve. [Reference Paper](http://aad.informatik.uni-freiburg.de/papers/15-IJCAI-Extrapolation_of_Learning_Curves.pdf)|
+|__Medianstop__[(Usage)](#MedianStop)|Medianstop is a simple early stopping rule. It stops a pending trial X at step S if the trial’s best objective value by step S is strictly worse than the median value of the running averages of all completed trials’ objectives reported up to step S. [Reference Paper](https://static.googleusercontent.com/media/research.google.com/en//pubs/archive/46180.pdf)|
+|__Curvefitting__[(Usage)](#Curvefitting)|Curve Fitting Assessor is a LPA(learning, predicting, assessing) algorithm. It stops a pending trial X at step S if the prediction of final epoch's performance worse than the best final performance in the trial history. In this algorithm, we use 12 curves to fit the accuracy curve. [Reference Paper](http://aad.informatik.uni-freiburg.de/papers/15-IJCAI-Extrapolation_of_Learning_Curves.pdf)|
## Usage of Builtin Assessors
diff --git a/docs/en_US/Builtin_Tuner.md b/docs/en_US/Builtin_Tuner.md
index 18dc25e7ba..be5d7445af 100644
--- a/docs/en_US/Builtin_Tuner.md
+++ b/docs/en_US/Builtin_Tuner.md
@@ -4,18 +4,30 @@ NNI provides state-of-the-art tuning algorithm as our builtin-tuners and makes t
Note: Click the **Tuner's name** to get a detailed description of the algorithm, click the corresponding **Usage** to get the Tuner's installation requirements, suggested scenario and using example.
+Currently we support the following algorithms:
+* [TPE](hyperoptTuner.md)
+* [Random Search](hyperoptTuner.md)
+* [Anneal](hyperoptTuner.md)
+* [Naive Evolution](evolutionTuner.md)
+* [SMAC](smacTuner.md)
+* [Batch tuner](batchTuner.md)
+* [Grid Search](gridsearchTuner.md)
+* [Hyperband](hyperbandAdvisor.md)
+* [Network Morphism](networkmorphismTuner.md)
+* [Metis Tuner](metisTuner.md)
+
|Tuner|Brief Introduction of Algorithm|
|---|---|
-|[TPE](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/hyperopt_tuner/README.md) [(Usage)](#TPE)|The Tree-structured Parzen Estimator (TPE) is a sequential model-based optimization (SMBO) approach. SMBO methods sequentially construct models to approximate the performance of hyperparameters based on historical measurements, and then subsequently choose new hyperparameters to test based on this model. [Reference Paper](https://papers.nips.cc/paper/4443-algorithms-for-hyper-parameter-optimization.pdf)|
-|[Random Search](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/hyperopt_tuner/README.md) [(Usage)](#Random)|In Random Search for Hyper-Parameter Optimization show that Random Search might be surprisingly simple and effective. We suggest that we could use Random Search as the baseline when we have no knowledge about the prior distribution of hyper-parameters. [Reference Paper](http://www.jmlr.org/papers/volume13/bergstra12a/bergstra12a.pdf)|
-|[Anneal](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/hyperopt_tuner/README.md) [(Usage)](#Anneal)|This simple annealing algorithm begins by sampling from the prior, but tends over time to sample from points closer and closer to the best ones observed. This algorithm is a simple variation on the random search that leverages smoothness in the response surface. The annealing rate is not adaptive.|
-|[Naive Evolution](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/evolution_tuner/README.md) [(Usage)](#Evolution)|Naive Evolution comes from Large-Scale Evolution of Image Classifiers. It randomly initializes a population-based on search space. For each generation, it chooses better ones and does some mutation (e.g., change a hyperparameter, add/remove one layer) on them to get the next generation. Naive Evolution requires many trials to works, but it's very simple and easy to expand new features. [Reference paper](https://arxiv.org/pdf/1703.01041.pdf)|
-|[SMAC](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/smac_tuner/README.md) [(Usage)](#SMAC)|SMAC is based on Sequential Model-Based Optimization (SMBO). It adapts the most prominent previously used model class (Gaussian stochastic process models) and introduces the model class of random forests to SMBO, in order to handle categorical parameters. The SMAC supported by nni is a wrapper on the SMAC3 Github repo. Notice, SMAC need to be installed by `nnictl package` command. [Reference Paper,](https://www.cs.ubc.ca/~hutter/papers/10-TR-SMAC.pdf) [Github Repo](https://github.com/automl/SMAC3)|
-|[Batch tuner](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/batch_tuner/README.md) [(Usage)](#Batch)|Batch tuner allows users to simply provide several configurations (i.e., choices of hyper-parameters) for their trial code. After finishing all the configurations, the experiment is done. Batch tuner only supports the type choice in search space spec.|
-|[Grid Search](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/gridsearch_tuner/README.md) [(Usage)](#GridSearch)|Grid Search performs an exhaustive searching through a manually specified subset of the hyperparameter space defined in the searchspace file. Note that the only acceptable types of search space are choice, quniform, qloguniform. The number q in quniform and qloguniform has special meaning (different from the spec in search space spec). It means the number of values that will be sampled evenly from the range low and high.|
-|[Hyperband](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/hyperband_advisor/README.md) [(Usage)](#Hyperband)|Hyperband tries to use the limited resource to explore as many configurations as possible, and finds out the promising ones to get the final result. The basic idea is generating many configurations and to run them for the small number of STEPs to find out promising one, then further training those promising ones to select several more promising one.[Reference Paper](https://arxiv.org/pdf/1603.06560.pdf)|
-|[Network Morphism](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/networkmorphism_tuner/README.md) [(Usage)](#NetworkMorphism)|Network Morphism provides functions to automatically search for architecture of deep learning models. Every child network inherits the knowledge from its parent network and morphs into diverse types of networks, including changes of depth, width, and skip-connection. Next, it estimates the value of a child network using the historic architecture and metric pairs. Then it selects the most promising one to train. [Reference Paper](https://arxiv.org/abs/1806.10282)|
-|[Metis Tuner](https://github.com/Microsoft/nni/blob/master/src/sdk/pynni/nni/metis_tuner/README.md) [(Usage)](#MetisTuner)|Metis offers the following benefits when it comes to tuning parameters: While most tools only predict the optimal configuration, Metis gives you two outputs: (a) current prediction of optimal configuration, and (b) suggestion for the next trial. No more guesswork. While most tools assume training datasets do not have noisy data, Metis actually tells you if you need to re-sample a particular hyper-parameter. [Reference Paper](https://www.microsoft.com/en-us/research/publication/metis-robustly-tuning-tail-latencies-cloud-systems/)|
+|__TPE__ [(Usage)](#TPE)|The Tree-structured Parzen Estimator (TPE) is a sequential model-based optimization (SMBO) approach. SMBO methods sequentially construct models to approximate the performance of hyperparameters based on historical measurements, and then subsequently choose new hyperparameters to test based on this model. [Reference Paper](https://papers.nips.cc/paper/4443-algorithms-for-hyper-parameter-optimization.pdf)|
+|__Random Search__ [(Usage)](#Random)|In Random Search for Hyper-Parameter Optimization show that Random Search might be surprisingly simple and effective. We suggest that we could use Random Search as the baseline when we have no knowledge about the prior distribution of hyper-parameters. [Reference Paper](http://www.jmlr.org/papers/volume13/bergstra12a/bergstra12a.pdf)|
+|__Anneal__ [(Usage)](#Anneal)|This simple annealing algorithm begins by sampling from the prior, but tends over time to sample from points closer and closer to the best ones observed. This algorithm is a simple variation on the random search that leverages smoothness in the response surface. The annealing rate is not adaptive.|
+|__Naive Evolution__ [(Usage)](#Evolution)|Naive Evolution comes from Large-Scale Evolution of Image Classifiers. It randomly initializes a population-based on search space. For each generation, it chooses better ones and does some mutation (e.g., change a hyperparameter, add/remove one layer) on them to get the next generation. Naive Evolution requires many trials to works, but it's very simple and easy to expand new features. [Reference paper](https://arxiv.org/pdf/1703.01041.pdf)|
+|__SMAC__ [(Usage)](#SMAC)|SMAC is based on Sequential Model-Based Optimization (SMBO). It adapts the most prominent previously used model class (Gaussian stochastic process models) and introduces the model class of random forests to SMBO, in order to handle categorical parameters. The SMAC supported by nni is a wrapper on the SMAC3 Github repo. Notice, SMAC need to be installed by `nnictl package` command. [Reference Paper,](https://www.cs.ubc.ca/~hutter/papers/10-TR-SMAC.pdf) [Github Repo](https://github.com/automl/SMAC3)|
+|__Batch tuner__ [(Usage)](#Batch)|Batch tuner allows users to simply provide several configurations (i.e., choices of hyper-parameters) for their trial code. After finishing all the configurations, the experiment is done. Batch tuner only supports the type choice in search space spec.|
+|__Grid Search__ [(Usage)](#GridSearch)|Grid Search performs an exhaustive searching through a manually specified subset of the hyperparameter space defined in the searchspace file. Note that the only acceptable types of search space are choice, quniform, qloguniform. The number q in quniform and qloguniform has special meaning (different from the spec in search space spec). It means the number of values that will be sampled evenly from the range low and high.|
+|__Hyperband__ [(Usage)](#Hyperband)|Hyperband tries to use the limited resource to explore as many configurations as possible, and finds out the promising ones to get the final result. The basic idea is generating many configurations and to run them for the small number of STEPs to find out promising one, then further training those promising ones to select several more promising one.[Reference Paper](https://arxiv.org/pdf/1603.06560.pdf)|
+|__Network Morphism__ [(Usage)](#NetworkMorphism)|Network Morphism provides functions to automatically search for architecture of deep learning models. Every child network inherits the knowledge from its parent network and morphs into diverse types of networks, including changes of depth, width, and skip-connection. Next, it estimates the value of a child network using the historic architecture and metric pairs. Then it selects the most promising one to train. [Reference Paper](https://arxiv.org/abs/1806.10282)|
+|__Metis Tuner__ [(Usage)](#MetisTuner)|Metis offers the following benefits when it comes to tuning parameters: While most tools only predict the optimal configuration, Metis gives you two outputs: (a) current prediction of optimal configuration, and (b) suggestion for the next trial. No more guesswork. While most tools assume training datasets do not have noisy data, Metis actually tells you if you need to re-sample a particular hyper-parameter. [Reference Paper](https://www.microsoft.com/en-us/research/publication/metis-robustly-tuning-tail-latencies-cloud-systems/)|
diff --git a/docs/en_US/HowToDebug.md b/docs/en_US/HowToDebug.md
index f64adc5ef7..e33cc45480 100644
--- a/docs/en_US/HowToDebug.md
+++ b/docs/en_US/HowToDebug.md
@@ -1,4 +1,88 @@
-**How to Debug in NNI**
-===
-
-*Coming soon*
+**How to Debug in NNI**
+===
+
+## Overview
+
+There are three parts that might have logs in NNI. They are nnimanager, dispatcher and trial. Here we will introduce them succinctly. More information please refer to [Overview](Overview.md).
+
+- **NNI controller**: NNI controller (nnictl) is the nni command-line tool that is used to manage experiments (e.g., start an experiment).
+- **nnimanager**: nnimanager is the core of NNI, whose log is important when the whole experiment fails (e.g., no webUI or training service fails)
+- **Dispatcher**: Dispatcher calls the methods of **Tuner** and **Assessor**. Logs of dispatcher are related to the tuner or assessor code.
+ - **Tuner**: Tuner is an AutoML algorithm, which generates a new configuration for the next try. A new trial will run with this configuration.
+ - **Assessor**: Assessor analyzes trial's intermediate results (e.g., periodically evaluated accuracy on test dataset) to tell whether this trial can be early stopped or not.
+- **Trial**: Trial code is the code you write to run your experiment, which is an individual attempt at applying a new configuration (e.g., a set of hyperparameter values, a specific nerual architecture).
+
+## Where is the log
+
+There are three kinds of log in NNI. When creating a new experiment, you can specify log level as debug by adding `--debug`. Besides, you can set more detailed log level in your configuration file by using
+`logLevel` keyword. Available logLevels are: `trace`, `debug`, `info`, `warning`, `error`, `fatal`.
+
+### NNI controller
+
+All possible errors that happen when launching an NNI experiment can be found here.
+
+You can use `nnictl log stderr` to find error information. For more options please refer to [NNICTL](NNICTLDOC.md)
+
+
+### Experiment Root Directory
+Every experiment has a root folder, which is shown on the right-top corner of webUI. Or you could assemble it by replacing the `experiment_id` with your actual experiment_id in path `~/nni/experiment/experiment_id/` in case of webUI failure. `experiment_id` could be seen when you run `nnictl create ...` to create a new experiment.
+
+> For flexibility, we also offer a `logDir` option in your configuration, which specifies the directory to store all experiments (defaults to `~/nni/experiment`). Please refer to [Configuration](ExperimentConfig.md) for more details.
+
+Under that directory, there is another directory named `log`, where `nnimanager.log` and `dispatcher.log` are placed.
+
+### Trial Root Directory
+
+Usually in webUI, you can click `+` in the left of every trial to expand it to see each trial's log path.
+
+Besides, there is another directory under experiment root directory, named `trials`, which stores all the trials.
+Every trial has a unique id as its directory name. In this directory, a file named `stderr` records trial error and another named `trial.log` records this trial's log.
+
+## Different kinds of errors
+
+There are different kinds of errors. However, they can be divided into three categories based on their severity. So when nni fails, check each part sequentially.
+
+Generally, if webUI is started successfully, there is a `Status` in the `Overview` tab, serving as a possible indicator of what kind of error happens. Otherwise you should check manually.
+
+### **NNI** Fails
+
+This is the most serious error. When this happens, the whole experiment fails and no trial will be run. Usually this might be related to some installation problem.
+
+When this happens, you should check `nnictl`'s error output file `stderr` (i.e., nnictl log stderr) and then the `nnimanager`'s log to find if there is any error.
+
+
+### **Dispatcher** Fails
+
+Dispatcher fails. Usually, for some new users of NNI, it means that tuner fails. You could check dispatcher's log to see what happens to your dispatcher. For built-in tuner, some common errors might be invalid search space (unsupported type of search space or inconsistence between initializing args in configuration file and actual tuner's \_\_init\_\_ function args).
+
+Take the later situation as an example. If you write a customized tuner who's \_\_init\_\_ function has an argument called `optimize_mode`, which you do not provide in your configuration file, NNI will fail to run your tuner so the experiment fails. You can see errors in the webUI like:
+
+![](../img/dispatcher_error.jpg)
+
+Here we can see it is a dispatcher error. So we can check dispatcher's log, which might look like:
+
+```
+[2019-02-19 19:36:45] DEBUG (nni.main/MainThread) START
+[2019-02-19 19:36:47] ERROR (nni.main/MainThread) __init__() missing 1 required positional arguments: 'optimize_mode'
+Traceback (most recent call last):
+ File "/usr/lib/python3.7/site-packages/nni/__main__.py", line 202, in
+ main()
+ File "/usr/lib/python3.7/site-packages/nni/__main__.py", line 164, in main
+ args.tuner_args)
+ File "/usr/lib/python3.7/site-packages/nni/__main__.py", line 81, in create_customized_class_instance
+ instance = class_constructor(**class_args)
+TypeError: __init__() missing 1 required positional arguments: 'optimize_mode'.
+```
+
+### **Trial** Fails
+
+In this situation, NNI can still run and create new trials.
+
+It means your trial code (which is run by NNI) fails. This kind of error is strongly related to your trial code. Please check trial's log to fix any possible errors shown there.
+
+A common example of this would be run the mnist example without installing tensorflow. Surely there is an Import Error (that is, not installing tensorflow but trying to import it in your trial code) and thus every trial fails.
+
+![](../img/trial_error.jpg)
+
+As it shows, every trial has a log path, where you can find trial'log and stderr.
+
diff --git a/docs/en_US/Reference.rst b/docs/en_US/Reference.rst
index df57d3af6e..3ce330c3c4 100644
--- a/docs/en_US/Reference.rst
+++ b/docs/en_US/Reference.rst
@@ -5,6 +5,7 @@ References
:maxdepth: 3
Command Line
+ Python API
Annotation
Configuration
Search Space
\ No newline at end of file
diff --git a/src/sdk/pynni/nni/batch_tuner/README.md b/docs/en_US/batchTuner.md
similarity index 78%
rename from src/sdk/pynni/nni/batch_tuner/README.md
rename to docs/en_US/batchTuner.md
index ed8ea1dbe8..c949eea5df 100644
--- a/src/sdk/pynni/nni/batch_tuner/README.md
+++ b/docs/en_US/batchTuner.md
@@ -3,6 +3,6 @@ Batch Tuner on NNI
## Batch Tuner
-Batch tuner allows users to simply provide several configurations (i.e., choices of hyper-parameters) for their trial code. After finishing all the configurations, the experiment is done. Batch tuner only supports the type choice in [search space spec](../../../../../docs/en_US/SearchSpaceSpec.md).
+Batch tuner allows users to simply provide several configurations (i.e., choices of hyper-parameters) for their trial code. After finishing all the configurations, the experiment is done. Batch tuner only supports the type choice in [search space spec](SearchSpaceSpec.md).
Suggested sceanrio: If the configurations you want to try have been decided, you can list them in searchspace file (using choice) and run them using batch tuner.
\ No newline at end of file
diff --git a/docs/en_US/conf.py b/docs/en_US/conf.py
index 77f3a1a395..65cfa4eb14 100644
--- a/docs/en_US/conf.py
+++ b/docs/en_US/conf.py
@@ -189,7 +189,6 @@
github_doc_root = 'https://github.com/Microsoft/nni/tree/master/doc/'
def setup(app):
app.add_config_value('recommonmark_config', {
- 'url_resolver': lambda url: github_doc_root + url if url.startswith('..') else url,
- 'enable_auto_toc_tree': False,
+ 'enable_auto_toc_tree': True,
}, True)
app.add_transform(AutoStructify)
diff --git a/src/sdk/pynni/nni/curvefitting_assessor/README.md b/docs/en_US/curvefittingAssessor.md
similarity index 100%
rename from src/sdk/pynni/nni/curvefitting_assessor/README.md
rename to docs/en_US/curvefittingAssessor.md
diff --git a/src/sdk/pynni/nni/evolution_tuner/README.md b/docs/en_US/evolutionTuner.md
similarity index 100%
rename from src/sdk/pynni/nni/evolution_tuner/README.md
rename to docs/en_US/evolutionTuner.md
diff --git a/src/sdk/pynni/nni/gridsearch_tuner/README.md b/docs/en_US/gridsearchTuner.md
similarity index 67%
rename from src/sdk/pynni/nni/gridsearch_tuner/README.md
rename to docs/en_US/gridsearchTuner.md
index 5f1914b608..9f858b4d88 100644
--- a/src/sdk/pynni/nni/gridsearch_tuner/README.md
+++ b/docs/en_US/gridsearchTuner.md
@@ -3,4 +3,4 @@ Grid Search on NNI
## Grid Search
-Grid Search performs an exhaustive searching through a manually specified subset of the hyperparameter space defined in the searchspace file. Note that the only acceptable types of search space are `choice`, `quniform`, `qloguniform`. **The number `q` in `quniform` and `qloguniform` has special meaning (different from the spec in [search space spec](../../../../../docs/en_US/SearchSpaceSpec.md)). It means the number of values that will be sampled evenly from the range `low` and `high`.**
\ No newline at end of file
+Grid Search performs an exhaustive searching through a manually specified subset of the hyperparameter space defined in the searchspace file. Note that the only acceptable types of search space are `choice`, `quniform`, `qloguniform`. **The number `q` in `quniform` and `qloguniform` has special meaning (different from the spec in [search space spec](SearchSpaceSpec.md)). It means the number of values that will be sampled evenly from the range `low` and `high`.**
\ No newline at end of file
diff --git a/src/sdk/pynni/nni/hyperband_advisor/README.md b/docs/en_US/hyperbandAdvisor.md
similarity index 100%
rename from src/sdk/pynni/nni/hyperband_advisor/README.md
rename to docs/en_US/hyperbandAdvisor.md
diff --git a/src/sdk/pynni/nni/hyperopt_tuner/README.md b/docs/en_US/hyperoptTuner.md
similarity index 100%
rename from src/sdk/pynni/nni/hyperopt_tuner/README.md
rename to docs/en_US/hyperoptTuner.md
diff --git a/src/sdk/pynni/nni/medianstop_assessor/README.md b/docs/en_US/medianstopAssessor.md
similarity index 100%
rename from src/sdk/pynni/nni/medianstop_assessor/README.md
rename to docs/en_US/medianstopAssessor.md
diff --git a/src/sdk/pynni/nni/metis_tuner/README.md b/docs/en_US/metisTuner.md
similarity index 100%
rename from src/sdk/pynni/nni/metis_tuner/README.md
rename to docs/en_US/metisTuner.md
diff --git a/src/sdk/pynni/nni/networkmorphism_tuner/README.md b/docs/en_US/networkmorphismTuner.md
similarity index 98%
rename from src/sdk/pynni/nni/networkmorphism_tuner/README.md
rename to docs/en_US/networkmorphismTuner.md
index 98accf0adb..f311a2e8f7 100644
--- a/src/sdk/pynni/nni/networkmorphism_tuner/README.md
+++ b/docs/en_US/networkmorphismTuner.md
@@ -4,7 +4,7 @@
[Autokeras](https://arxiv.org/abs/1806.10282) is a popular automl tools using Network Morphism. The basic idea of Autokeras is to use Bayesian Regression to estimate the metric of the Neural Network Architecture. Each time, it generates several child networks from father networks. Then it uses a naïve Bayesian regression estimate its metric value from history trained results of network and metric value pair. Next, it chooses the the child which has best estimated performance and adds it to the training queue. Inspired by its work and referring to its [code](https://github.com/jhfjhfj1/autokeras), we implement our Network Morphism method in our NNI platform.
-If you want to know about network morphism trial usage, please check [Readme.md](../../../../../examples/trials/network_morphism/README.md) of the trial to get more detail.
+If you want to know about network morphism trial usage, please check [Readme.md](https://github.com/Microsoft/nni/blob/master/examples/trials/network_morphism/README.md) of the trial to get more detail.
## 2. Usage
diff --git a/src/sdk/pynni/nni/smac_tuner/README.md b/docs/en_US/smacTuner.md
similarity index 78%
rename from src/sdk/pynni/nni/smac_tuner/README.md
rename to docs/en_US/smacTuner.md
index e82d19b5a8..7a43deb306 100644
--- a/src/sdk/pynni/nni/smac_tuner/README.md
+++ b/docs/en_US/smacTuner.md
@@ -5,4 +5,4 @@ SMAC Tuner on NNI
[SMAC](https://www.cs.ubc.ca/~hutter/papers/10-TR-SMAC.pdf) is based on Sequential Model-Based Optimization (SMBO). It adapts the most prominent previously used model class (Gaussian stochastic process models) and introduces the model class of random forests to SMBO, in order to handle categorical parameters. The SMAC supported by nni is a wrapper on [the SMAC3 github repo](https://github.com/automl/SMAC3).
-Note that SMAC on nni only supports a subset of the types in [search space spec](../../../../../docs/en_US/SearchSpaceSpec.md), including `choice`, `randint`, `uniform`, `loguniform`, `quniform(q=1)`.
\ No newline at end of file
+Note that SMAC on nni only supports a subset of the types in [search space spec](SearchSpaceSpec.md), including `choice`, `randint`, `uniform`, `loguniform`, `quniform(q=1)`.
\ No newline at end of file
diff --git a/docs/img/dispatcher_error.jpg b/docs/img/dispatcher_error.jpg
new file mode 100644
index 0000000000..d955087d9b
Binary files /dev/null and b/docs/img/dispatcher_error.jpg differ
diff --git a/docs/img/trial_error.jpg b/docs/img/trial_error.jpg
new file mode 100644
index 0000000000..311900d3cc
Binary files /dev/null and b/docs/img/trial_error.jpg differ
diff --git a/docs/requirements.txt b/docs/requirements.txt
index e57099ebe3..2079b87621 100644
--- a/docs/requirements.txt
+++ b/docs/requirements.txt
@@ -8,6 +8,4 @@ hyperopt
json_tricks
numpy
scipy
-coverage
-git+https://github.com/QuanluZhang/ConfigSpace.git
-git+https://github.com/QuanluZhang/SMAC3.git
+coverage
\ No newline at end of file
diff --git a/setup.py b/setup.py
index d9329bd259..a543a09250 100644
--- a/setup.py
+++ b/setup.py
@@ -63,7 +63,7 @@ def run(self):
'requests',
'scipy',
'schema',
- 'pyhdfs'
+ 'PythonWebHDFS'
],
cmdclass={
diff --git a/src/nni_manager/common/trainingService.ts b/src/nni_manager/common/trainingService.ts
index 17e232be56..fd1be13e75 100644
--- a/src/nni_manager/common/trainingService.ts
+++ b/src/nni_manager/common/trainingService.ts
@@ -71,6 +71,7 @@ interface TrialJobDetail {
readonly workingDirectory: string;
readonly form: JobApplicationForm;
readonly sequenceId: number;
+ isEarlyStopped?: boolean;
}
interface HostJobDetail {
diff --git a/src/nni_manager/core/test/mockedDatastore.ts b/src/nni_manager/core/test/mockedDatastore.ts
index c5c35a33b0..d08b5b801b 100644
--- a/src/nni_manager/core/test/mockedDatastore.ts
+++ b/src/nni_manager/core/test/mockedDatastore.ts
@@ -99,7 +99,25 @@ class MockedDataStore implements DataStore {
private dbTrialJobs: SimpleDb = new SimpleDb('trial_jobs', './trial_jobs.json');
private dbMetrics: SimpleDb = new SimpleDb('metrics', './metrics.json');
+ trailJob1 = {
+ event: 'ADD_CUSTOMIZED',
+ timestamp: Date.now(),
+ trialJobId: "4321",
+ data: ''
+ }
+
+ metrics1 = {
+ timestamp: Date.now(),
+ trialJobId: '4321',
+ parameterId: 'param1',
+ type: 'CUSTOM',
+ sequence: 21,
+ data: ''
+ }
+
init(): Promise {
+ this.dbTrialJobs.saveData(this.trailJob1);
+ this.dbMetrics.saveData(this.metrics1);
return Promise.resolve();
}
diff --git a/src/nni_manager/core/test/nnimanager.test.ts b/src/nni_manager/core/test/nnimanager.test.ts
index 0a2074f2a1..ec98f8116e 100644
--- a/src/nni_manager/core/test/nnimanager.test.ts
+++ b/src/nni_manager/core/test/nnimanager.test.ts
@@ -19,25 +19,27 @@
'use strict';
+import * as os from 'os';
import { assert, expect } from 'chai';
import { Container, Scope } from 'typescript-ioc';
import * as component from '../../common/component';
import { Database, DataStore } from '../../common/datastore';
-import { Manager } from '../../common/manager';
+import { Manager, ExperimentProfile} from '../../common/manager';
import { TrainingService } from '../../common/trainingService';
import { cleanupUnitTest, prepareUnitTest } from '../../common/utils';
import { NNIDataStore } from '../nniDataStore';
import { NNIManager } from '../nnimanager';
import { SqlDB } from '../sqlDatabase';
import { MockedTrainingService } from './mockedTrainingService';
+import { MockedDataStore } from './mockedDatastore';
async function initContainer(): Promise {
prepareUnitTest();
Container.bind(TrainingService).to(MockedTrainingService).scope(Scope.Singleton);
Container.bind(Manager).to(NNIManager).scope(Scope.Singleton);
Container.bind(Database).to(SqlDB).scope(Scope.Singleton);
- Container.bind(DataStore).to(NNIDataStore).scope(Scope.Singleton);
+ Container.bind(DataStore).to(MockedDataStore).scope(Scope.Singleton);
await component.get(DataStore).init();
}
@@ -51,9 +53,9 @@ describe('Unit test for nnimanager', function () {
let experimentParams = {
authorName: 'zql',
experimentName: 'naive_experiment',
- trialConcurrency: 2,
+ trialConcurrency: 3,
maxExecDuration: 5,
- maxTrialNum: 2,
+ maxTrialNum: 3,
trainingServicePlatform: 'local',
searchSpace: '{"x":1}',
tuner: {
@@ -71,36 +73,74 @@ describe('Unit test for nnimanager', function () {
}
}
+ let updateExperimentParams = {
+ authorName: '',
+ experimentName: 'another_experiment',
+ trialConcurrency: 2,
+ maxExecDuration: 6,
+ maxTrialNum: 2,
+ trainingServicePlatform: 'local',
+ searchSpace: '{"y":2}',
+ tuner: {
+ className: 'TPE',
+ classArgs: {
+ optimize_mode: 'maximize'
+ },
+ checkpointDir: '',
+ gpuNum: 0
+ },
+ assessor: {
+ className: 'Medianstop',
+ checkpointDir: '',
+ gpuNum: 1
+ }
+ }
+
+ let experimentProfile = {
+ params: updateExperimentParams,
+ id: 'test',
+ execDuration: 0,
+ maxSequenceId: 0,
+ revision: 0
+ }
+
+
before(async () => {
await initContainer();
nniManager = component.get(Manager);
const expId: string = await nniManager.startExperiment(experimentParams);
- assert(expId);
- });
+ assert.strictEqual(expId, 'unittest');
+ })
after(async () => {
- await nniManager.stopExperiment();
+ await setTimeout(() => {nniManager.stopExperiment()},15000);
cleanupUnitTest();
})
- it('test resumeExperiment', () => {
- //TODO: add resume experiment unit test
+
+
+ it('test addCustomizedTrialJob', () => {
+ return nniManager.addCustomizedTrialJob('hyperParams').then(() => {
+
+ }).catch((error) => {
+ assert.fail(error);
+ })
})
+
it('test listTrialJobs', () => {
- //FIXME: not implemented
- //return nniManager.listTrialJobs().then(function (trialJobDetails) {
- // expect(trialJobDetails.length).to.be.equal(2);
- //}).catch(function (error) {
- // assert.fail(error);
- //})
+ return nniManager.listTrialJobs().then(function (trialjobdetails) {
+ expect(trialjobdetails.length).to.be.equal(2);
+ }).catch((error) => {
+ assert.fail(error);
+ })
})
it('test getTrialJob valid', () => {
//query a exist id
return nniManager.getTrialJob('1234').then(function (trialJobDetail) {
expect(trialJobDetail.id).to.be.equal('1234');
- }).catch(function (error) {
+ }).catch((error) => {
assert.fail(error);
})
})
@@ -132,7 +172,6 @@ describe('Unit test for nnimanager', function () {
})
})
- //TODO: complete ut
it('test cancelTrialJobByUser', () => {
return nniManager.cancelTrialJobByUser('1234').then(() => {
@@ -141,11 +180,112 @@ describe('Unit test for nnimanager', function () {
})
})
- it('test addCustomizedTrialJob', () => {
- return nniManager.addCustomizedTrialJob('hyperParams').then(() => {
+ it('test getExperimentProfile', () => {
+ return nniManager.getExperimentProfile().then((experimentProfile) => {
+ expect(experimentProfile.id).to.be.equal('unittest');
+ expect(experimentProfile.logDir).to.be.equal(os.homedir()+'/nni/experiments/unittest');
}).catch((error) => {
assert.fail(error);
})
})
+
+ it('test updateExperimentProfile TRIAL_CONCURRENCY', () => {
+ return nniManager.updateExperimentProfile(experimentProfile, 'TRIAL_CONCURRENCY').then(() => {
+ nniManager.getExperimentProfile().then((updateProfile) => {
+ expect(updateProfile.params.trialConcurrency).to.be.equal(2);
+ });
+ }).catch((error) => {
+ assert.fail(error);
+ })
+ })
+
+ it('test updateExperimentProfile MAX_EXEC_DURATION', () => {
+ return nniManager.updateExperimentProfile(experimentProfile, 'MAX_EXEC_DURATION').then(() => {
+ nniManager.getExperimentProfile().then((updateProfile) => {
+ expect(updateProfile.params.maxExecDuration).to.be.equal(6);
+ });
+ }).catch((error) => {
+ assert.fail(error);
+ })
+ })
+
+ it('test updateExperimentProfile SEARCH_SPACE', () => {
+ return nniManager.updateExperimentProfile(experimentProfile, 'SEARCH_SPACE').then(() => {
+ nniManager.getExperimentProfile().then((updateProfile) => {
+ expect(updateProfile.params.searchSpace).to.be.equal('{"y":2}');
+ });
+ }).catch((error) => {
+ assert.fail(error);
+ })
+ })
+
+ it('test updateExperimentProfile MAX_TRIAL_NUM', () => {
+ return nniManager.updateExperimentProfile(experimentProfile, 'MAX_TRIAL_NUM').then(() => {
+ nniManager.getExperimentProfile().then((updateProfile) => {
+ expect(updateProfile.params.maxTrialNum).to.be.equal(2);
+ });
+ }).catch((error) => {
+ assert.fail(error);
+ })
+ })
+
+ it('test getStatus', () => {
+ assert.strictEqual(nniManager.getStatus().status,'RUNNING');
+ })
+
+ it('test getMetricData with trialJobId', () => {
+ //query a exist trialJobId
+ return nniManager.getMetricData('4321', 'CUSTOM').then((metricData) => {
+ expect(metricData.length).to.be.equal(1);
+ expect(metricData[0].trialJobId).to.be.equal('4321');
+ expect(metricData[0].parameterId).to.be.equal('param1');
+ }).catch((error) => {
+ assert.fail(error);
+ })
+ })
+
+ it('test getMetricData with invalid trialJobId', () => {
+ //query an invalid trialJobId
+ return nniManager.getMetricData('43210', 'CUSTOM').then((metricData) => {
+ assert.fail();
+ }).catch((error) => {
+ })
+ })
+
+ it('test getTrialJobStatistics', () => {
+ // get 3 trial jobs (init, addCustomizedTrialJob, cancelTrialJobByUser)
+ return nniManager.getTrialJobStatistics().then(function (trialJobStatistics) {
+ expect(trialJobStatistics.length).to.be.equal(2);
+ if (trialJobStatistics[0].trialJobStatus === 'WAITING') {
+ expect(trialJobStatistics[0].trialJobNumber).to.be.equal(2);
+ expect(trialJobStatistics[1].trialJobNumber).to.be.equal(1);
+ }
+ else {
+ expect(trialJobStatistics[1].trialJobNumber).to.be.equal(2);
+ expect(trialJobStatistics[0].trialJobNumber).to.be.equal(1);
+ }
+ }).catch((error) => {
+ assert.fail(error);
+ })
+ })
+
+ it('test addCustomizedTrialJob reach maxTrialNum', () => {
+ // test currSubmittedTrialNum reach maxTrialNum
+ return nniManager.addCustomizedTrialJob('hyperParam').then(() => {
+ nniManager.getTrialJobStatistics().then(function (trialJobStatistics) {
+ if (trialJobStatistics[0].trialJobStatus === 'WAITING')
+ expect(trialJobStatistics[0].trialJobNumber).to.be.equal(2);
+ else
+ expect(trialJobStatistics[1].trialJobNumber).to.be.equal(2);
+ })
+ }).catch((error) => {
+ assert.fail(error);
+ })
+ })
+
+ it('test resumeExperiment', async () => {
+ //TODO: add resume experiment unit test
+ })
+
})
diff --git a/src/nni_manager/package.json b/src/nni_manager/package.json
index 757677211a..4d5c864d89 100644
--- a/src/nni_manager/package.json
+++ b/src/nni_manager/package.json
@@ -5,7 +5,7 @@
"scripts": {
"postbuild": "cp -rf config ./dist/",
"build": "tsc",
- "test": "nyc mocha -r ts-node/register -t 15000 --recursive **/*.test.ts --exclude node_modules/**/**/*.test.ts --exclude core/test/nnimanager.test.ts --colors",
+ "test": "nyc mocha -r ts-node/register -t 15000 --recursive **/*.test.ts --exclude node_modules/**/**/*.test.ts --colors",
"start": "node dist/main.js",
"tslint": "tslint -p ."
},
diff --git a/src/nni_manager/training_service/kubernetes/kubeflow/kubeflowJobInfoCollector.ts b/src/nni_manager/training_service/kubernetes/kubeflow/kubeflowJobInfoCollector.ts
index 84fd313001..be4468c455 100644
--- a/src/nni_manager/training_service/kubernetes/kubeflow/kubeflowJobInfoCollector.ts
+++ b/src/nni_manager/training_service/kubernetes/kubeflow/kubeflowJobInfoCollector.ts
@@ -46,6 +46,7 @@ export class KubeflowJobInfoCollector extends KubernetesJobInfoCollector{
try {
kubernetesJobInfo = await kubernetesCRDClient.getKubernetesJob(kubernetesTrialJob.kubernetesJobName);
} catch(error) {
+ // Notice: it maynot be a 'real' error since cancel trial job can also cause getKubernetesJob failed.
this.log.error(`Get job ${kubernetesTrialJob.kubernetesJobName} info failed, error is ${error}`);
//This is not treat as a error status
return Promise.resolve();
diff --git a/src/nni_manager/training_service/local/localTrainingService.ts b/src/nni_manager/training_service/local/localTrainingService.ts
index a194216f35..7cd34f0c8d 100644
--- a/src/nni_manager/training_service/local/localTrainingService.ts
+++ b/src/nni_manager/training_service/local/localTrainingService.ts
@@ -255,7 +255,7 @@ class LocalTrainingService implements TrainingService {
}
if (trialJob.pid === undefined){
this.setTrialJobStatus(trialJob, 'USER_CANCELED');
- return;
+ return Promise.resolve();
}
if (trialJob.form.jobType === 'TRIAL') {
await tkill(trialJob.pid, 'SIGKILL');
@@ -265,6 +265,7 @@ class LocalTrainingService implements TrainingService {
throw new Error(`Job type not supported: ${trialJob.form.jobType}`);
}
this.setTrialJobStatus(trialJob, getJobCancelStatus(isEarlyStopped));
+ return Promise.resolve();
}
public async setClusterMetadata(key: string, value: string): Promise {
diff --git a/src/nni_manager/training_service/pai/paiData.ts b/src/nni_manager/training_service/pai/paiData.ts
index 036c206c68..ed9fb8d235 100644
--- a/src/nni_manager/training_service/pai/paiData.ts
+++ b/src/nni_manager/training_service/pai/paiData.ts
@@ -34,6 +34,7 @@ export class PAITrialJobDetail implements TrialJobDetail {
public form: JobApplicationForm;
public sequenceId: number;
public hdfsLogPath: string;
+ public isEarlyStopped?: boolean;
constructor(id: string, status: TrialJobStatus, paiJobName : string,
submitTime: number, workingDirectory: string, form: JobApplicationForm, sequenceId: number, hdfsLogPath: string) {
@@ -63,7 +64,7 @@ export const PAI_TRIAL_COMMAND_FORMAT: string =
`export NNI_PLATFORM=pai NNI_SYS_DIR={0} NNI_OUTPUT_DIR={1} NNI_TRIAL_JOB_ID={2} NNI_EXP_ID={3} NNI_TRIAL_SEQ_ID={4}
&& cd $NNI_SYS_DIR && sh install_nni.sh
&& python3 -m nni_trial_tool.trial_keeper --trial_command '{5}' --nnimanager_ip '{6}' --nnimanager_port '{7}'
---pai_hdfs_output_dir '{8}' --pai_hdfs_host '{9}' --pai_user_name {10} --nni_hdfs_exp_dir '{11}'`;
+--pai_hdfs_output_dir '{8}' --pai_hdfs_host '{9}' --pai_user_name {10} --nni_hdfs_exp_dir '{11}' --webhdfs_path '/webhdfs/api/v1'`;
export const PAI_OUTPUT_DIR_FORMAT: string =
`hdfs://{0}:9000/`;
diff --git a/src/nni_manager/training_service/pai/paiJobInfoCollector.ts b/src/nni_manager/training_service/pai/paiJobInfoCollector.ts
index a4540809b8..5fbffcb9e9 100644
--- a/src/nni_manager/training_service/pai/paiJobInfoCollector.ts
+++ b/src/nni_manager/training_service/pai/paiJobInfoCollector.ts
@@ -103,8 +103,12 @@ export class PAIJobInfoCollector {
paiTrialJob.status = 'SUCCEEDED';
break;
case 'STOPPED':
- if (paiTrialJob.status !== 'EARLY_STOPPED') {
- paiTrialJob.status = 'USER_CANCELED';
+ if (paiTrialJob.isEarlyStopped !== undefined) {
+ paiTrialJob.status = paiTrialJob.isEarlyStopped === true ?
+ 'EARLY_STOPPED' : 'USER_CANCELED';
+ } else {
+ // if paiTrialJob's isEarlyStopped is undefined, that mean we didn't stop it via cancellation, mark it as SYS_CANCELLED by PAI
+ paiTrialJob.status = 'SYS_CANCELED';
}
break;
case 'FAILED':
diff --git a/src/nni_manager/training_service/pai/paiTrainingService.ts b/src/nni_manager/training_service/pai/paiTrainingService.ts
index edd6b68869..88264503e6 100644
--- a/src/nni_manager/training_service/pai/paiTrainingService.ts
+++ b/src/nni_manager/training_service/pai/paiTrainingService.ts
@@ -324,14 +324,15 @@ class PAITrainingService implements TrainingService {
"Authorization": 'Bearer ' + this.paiToken
}
};
+
+ // Set trialjobDetail's early stopped field, to mark the job's cancellation source
+ trialJobDetail.isEarlyStopped = isEarlyStopped;
+
request(stopJobRequest, (error: Error, response: request.Response, body: any) => {
if (error || response.statusCode >= 400) {
this.log.error(`PAI Training service: stop trial ${trialJobId} to PAI Cluster failed!`);
deferred.reject(error ? error.message : 'Stop trial failed, http code: ' + response.statusCode);
} else {
- if (isEarlyStopped) {
- trialJobDetail.status = 'EARLY_STOPPED';
- }
deferred.resolve();
}
});
diff --git a/src/nni_manager/training_service/remote_machine/remoteMachineData.ts b/src/nni_manager/training_service/remote_machine/remoteMachineData.ts
index fdedd78888..68d9a2fc36 100644
--- a/src/nni_manager/training_service/remote_machine/remoteMachineData.ts
+++ b/src/nni_manager/training_service/remote_machine/remoteMachineData.ts
@@ -80,6 +80,7 @@ export class RemoteMachineTrialJobDetail implements TrialJobDetail {
public form: JobApplicationForm;
public sequenceId: number;
public rmMeta?: RemoteMachineMeta;
+ public isEarlyStopped?: boolean;
constructor(id: string, status: TrialJobStatus, submitTime: number,
workingDirectory: string, form: JobApplicationForm, sequenceId: number) {
@@ -114,7 +115,7 @@ export NNI_PLATFORM=remote NNI_SYS_DIR={0} NNI_OUTPUT_DIR={1} NNI_TRIAL_JOB_ID={
cd $NNI_SYS_DIR
sh install_nni.sh
echo $$ >{6}
-python3 -m nni_trial_tool.trial_keeper --trial_command '{7}' --nnimanager_ip '{8}' --nnimanager_port '{9}'
+python3 -m nni_trial_tool.trial_keeper --trial_command '{7}' --nnimanager_ip '{8}' --nnimanager_port '{9}' 1>$NNI_OUTPUT_DIR/trialkeeper_stdout 2>$NNI_OUTPUT_DIR/trialkeeper_stderr
echo $? \`date +%s%3N\` >{10}`;
export const HOST_JOB_SHELL_FORMAT: string =
diff --git a/src/nni_manager/training_service/remote_machine/remoteMachineTrainingService.ts b/src/nni_manager/training_service/remote_machine/remoteMachineTrainingService.ts
index 50bb6ab4ef..794f667e77 100644
--- a/src/nni_manager/training_service/remote_machine/remoteMachineTrainingService.ts
+++ b/src/nni_manager/training_service/remote_machine/remoteMachineTrainingService.ts
@@ -48,7 +48,7 @@ import {
GPU_COLLECTOR_FORMAT
} from './remoteMachineData';
import { SSHClientUtility } from './sshClientUtility';
-import { validateCodeDir} from '../common/util';
+import { validateCodeDir } from '../common/util';
import { RemoteMachineJobRestServer } from './remoteMachineJobRestServer';
import { CONTAINER_INSTALL_NNI_SHELL_FORMAT } from '../common/containerJobData';
import { mkDirP } from '../../common/utils';
@@ -279,8 +279,9 @@ class RemoteMachineTrainingService implements TrainingService {
const jobpidPath: string = this.getJobPidPath(trialJob.id);
try {
+ // Mark the toEarlyStop tag here
+ trialJob.isEarlyStopped = isEarlyStopped;
await SSHClientUtility.remoteExeCommand(`pkill -P \`cat ${jobpidPath}\``, sshClient);
- trialJob.status = getJobCancelStatus(isEarlyStopped);
} catch (error) {
// Not handle the error since pkill failed will not impact trial job's current status
this.log.error(`remoteTrainingService.cancelTrialJob: ${error.message}`);
@@ -482,6 +483,11 @@ class RemoteMachineTrainingService implements TrainingService {
if (trialJobDetail === undefined) {
throw new NNIError(NNIErrorNames.INVALID_JOB_DETAIL, `Invalid job detail information for trial job ${trialJobId}`);
}
+ // If job is not WATIING, Don't prepare and resolve true immediately
+ if (trialJobDetail.status !== 'WAITING') {
+ deferred.resolve(true);
+ return deferred.promise;
+ }
// get an ssh client from scheduler
const rmScheduleResult: RemoteMachineScheduleResult = this.gpuScheduler.scheduleMachine(this.trialConfig.gpuNum, trialJobId);
if (rmScheduleResult.resultType === ScheduleResultType.REQUIRE_EXCEED_TOTAL) {
@@ -640,7 +646,12 @@ class RemoteMachineTrainingService implements TrainingService {
if (parseInt(code, 10) === 0) {
trialJob.status = 'SUCCEEDED';
} else {
- trialJob.status = 'FAILED';
+ // isEarlyStopped is never set, mean it's not cancelled by NNI, so if the process's exit code >0, mark it as FAILED
+ if (trialJob.isEarlyStopped === undefined) {
+ trialJob.status = 'FAILED';
+ } else {
+ trialJob.status = getJobCancelStatus(trialJob.isEarlyStopped);
+ }
}
trialJob.endTime = parseInt(timestamp, 10);
}
diff --git a/src/nni_manager/training_service/test/localTrainingService.test.ts b/src/nni_manager/training_service/test/localTrainingService.test.ts
index 13210082b1..c980df997a 100644
--- a/src/nni_manager/training_service/test/localTrainingService.test.ts
+++ b/src/nni_manager/training_service/test/localTrainingService.test.ts
@@ -19,14 +19,106 @@
'use strict';
-import { TrainingService } from '../../common/trainingService';
-import { LocalTrainingService } from '../local/localTrainingService';
+import * as assert from 'assert';
+import * as chai from 'chai';
+import * as chaiAsPromised from 'chai-as-promised';
+import * as fs from 'fs';
+import * as tmp from 'tmp';
import * as component from '../../common/component';
+import { TrialJobApplicationForm, TrialJobDetail, TrainingService } from '../../common/trainingService';
+import { cleanupUnitTest, delay, prepareUnitTest } from '../../common/utils';
+import { TrialConfigMetadataKey } from '../common/trialConfigMetadataKey';
+import { LocalTrainingServiceForGPU } from '../local/localTrainingServiceForGPU';
+
+// TODO: copy mockedTrail.py to local folder
+const localCodeDir: string = tmp.dirSync().name
+const mockedTrialPath: string = './training_service/test/mockedTrial.py'
+fs.copyFileSync(mockedTrialPath, localCodeDir + '/mockedTrial.py')
describe('Unit Test for LocalTrainingService', () => {
- let trainingService: TrainingService
+ let trialConfig: any = `{"command":"sleep 1h && echo hello","codeDir":"${localCodeDir}","gpuNum":1}`
+
+ let localTrainingService: LocalTrainingServiceForGPU;
+
+ before(() => {
+ chai.should();
+ chai.use(chaiAsPromised);
+ prepareUnitTest();
+ });
+
+ after(() => {
+ cleanupUnitTest();
+ });
+
+ beforeEach(() => {
+ localTrainingService = component.get(LocalTrainingServiceForGPU);
+ localTrainingService.run();
+ });
+
+ afterEach(() => {
+ localTrainingService.cleanUp();
+ });
+
+ it('List empty trial jobs', async () => {
+ //trial jobs should be empty, since there are no submitted jobs
+ chai.expect(await localTrainingService.listTrialJobs()).to.be.empty;
+ });
+
+ it('setClusterMetadata and getClusterMetadata', async () => {
+ await localTrainingService.setClusterMetadata(TrialConfigMetadataKey.TRIAL_CONFIG, trialConfig);
+ localTrainingService.getClusterMetadata(TrialConfigMetadataKey.TRIAL_CONFIG).then((data)=>{
+ chai.expect(data).to.be.equals(trialConfig);
+ });
+ });
+
+ it('Submit job and Cancel job', async () => {
+ await localTrainingService.setClusterMetadata(TrialConfigMetadataKey.TRIAL_CONFIG, trialConfig);
+
+ // submit job
+ const form: TrialJobApplicationForm = {
+ jobType: 'TRIAL',
+ hyperParameters: {
+ value: 'mock hyperparameters',
+ index: 0
+ }
+ };
+ const jobDetail: TrialJobDetail = await localTrainingService.submitTrialJob(form);
+ chai.expect(jobDetail.status).to.be.equals('WAITING');
+ await localTrainingService.cancelTrialJob(jobDetail.id);
+ chai.expect(jobDetail.status).to.be.equals('USER_CANCELED');
+ }).timeout(20000);
+
+ it('Read metrics, Add listener, and remove listener', async () => {
+ // set meta data
+ const trialConfig: string = `{\"command\":\"python3 mockedTrial.py\", \"codeDir\":\"${localCodeDir}\",\"gpuNum\":0}`
+ await localTrainingService.setClusterMetadata(TrialConfigMetadataKey.TRIAL_CONFIG, trialConfig);
+
+ // submit job
+ const form: TrialJobApplicationForm = {
+ jobType: 'TRIAL',
+ hyperParameters: {
+ value: 'mock hyperparameters',
+ index: 0
+ }
+ };
+ const jobDetail: TrialJobDetail = await localTrainingService.submitTrialJob(form);
+ chai.expect(jobDetail.status).to.be.equals('WAITING');
+ localTrainingService.listTrialJobs().then((jobList)=>{
+ chai.expect(jobList.length).to.be.equals(1);
+ });
+ // Add metrics listeners
+ const listener1 = function f1(metric: any) {
+ chai.expect(metric.id).to.be.equals(jobDetail.id);
+ }
+ localTrainingService.addTrialJobMetricListener(listener1);
+ // Wait to collect metric
+ await delay(1000);
+
+ await localTrainingService.cancelTrialJob(jobDetail.id);
+ localTrainingService.removeTrialJobMetricListener(listener1);
+ }).timeout(20000);
- beforeEach(async () => {
- trainingService = component.get(LocalTrainingService);
+ it('Test multiphaseSupported', () => {
+ chai.expect(localTrainingService.isMultiPhaseJobSupported).to.be.equals(true)
})
});
\ No newline at end of file
diff --git a/src/webui/src/components/SlideBar.tsx b/src/webui/src/components/SlideBar.tsx
index 7b758ebd27..a5e960b493 100644
--- a/src/webui/src/components/SlideBar.tsx
+++ b/src/webui/src/components/SlideBar.tsx
@@ -182,6 +182,7 @@ class SlideBar extends React.Component<{}, SliderState> {
render() {
const { version, menuVisible } = this.state;
+ const feed = `https://github.com/Microsoft/nni/issues/new?labels=${version}`;
const menu = (