From cfb0bcab2b8a9c65d1298fbfdd443061a9cd3f53 Mon Sep 17 00:00:00 2001 From: Zejun Lin <871886504@qq.com> Date: Tue, 12 Mar 2019 16:03:28 +0800 Subject: [PATCH 1/5] Fix the problem that part of the sdk's unit test do not block CI when they fail (#827) fix unittest err exit --- test/unittest.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 test/unittest.sh diff --git a/test/unittest.sh b/test/unittest.sh old mode 100644 new mode 100755 index e87dca2671..a94beb6017 --- a/test/unittest.sh +++ b/test/unittest.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -e CWD=${PWD} # -------------For python unittest------------- @@ -25,4 +26,4 @@ python3 -m unittest discover -v tests cd ${CWD}/../src/nni_manager echo "" echo "===========================Testing: nni_manager===========================" -npm run test \ No newline at end of file +npm run test From 8f71e99f86afc9a0e1e8fb6053a1c3f2c5dd64d1 Mon Sep 17 00:00:00 2001 From: SparkSnail Date: Tue, 12 Mar 2019 16:09:16 +0800 Subject: [PATCH 2/5] Update makefile (#831) In current version of makefile, if user use make dev-install, they will install two packages "nni-sdk" and "nnictl" in their environment. Now merge the two package to be one package "nni". --- Makefile | 11 +++-------- setup.py | 5 +++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 959f6cfc94..484c046b8a 100644 --- a/Makefile +++ b/Makefile @@ -168,18 +168,13 @@ install-dependencies: $(NNI_NODE_TARBALL) $(NNI_YARN_TARBALL) .PHONY: install-python-modules install-python-modules: #$(_INFO) Installing Python SDK $(_END) - cd src/sdk/pynni && sed -ie 's/$(NNI_VERSION_TEMPLATE)/$(NNI_VERSION_VALUE)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) . - - #$(_INFO) Installing nnictl $(_END) - cd tools && sed -ie 's/$(NNI_VERSION_TEMPLATE)/$(NNI_VERSION_VALUE)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) . + sed -ie 's/$(NNI_VERSION_TEMPLATE)/$(NNI_VERSION_VALUE)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) . .PHONY: dev-install-python-modules dev-install-python-modules: #$(_INFO) Installing Python SDK $(_END) - cd src/sdk/pynni && sed -ie 's/$(NNI_VERSION_TEMPLATE)/$(NNI_VERSION_VALUE)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) -e . - - #$(_INFO) Installing nnictl $(_END) - cd tools && sed -ie 's/$(NNI_VERSION_TEMPLATE)/$(NNI_VERSION_VALUE)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) -e . + sed -ie 's/$(NNI_VERSION_TEMPLATE)/$(NNI_VERSION_VALUE)/' setup.py && $(PIP_INSTALL) $(PIP_MODE) . + .PHONY: install-node-modules install-node-modules: diff --git a/setup.py b/setup.py index a543a09250..661eebfea0 100644 --- a/setup.py +++ b/setup.py @@ -68,5 +68,10 @@ def run(self): cmdclass={ 'install': CustomInstallCommand + }, + entry_points = { + 'console_scripts' : [ + 'nnictl = nni_cmd.nnictl:parse_args' + ] } ) From c6b7cc8931042f318693d5ddcd1cc430d7734144 Mon Sep 17 00:00:00 2001 From: Shufan Huang Date: Tue, 12 Mar 2019 16:10:40 +0800 Subject: [PATCH 3/5] Solve bug caused by scientific calculation errors (#828) * add epsilon * add epsilon for ceil --- src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py b/src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py index b2bfd29cd2..2b0eeac26d 100644 --- a/src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py +++ b/src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py @@ -38,6 +38,7 @@ _next_parameter_id = 0 _KEY = 'STEPS' +_epsilon = 1e-6 @unique class OptimizeMode(Enum): @@ -141,8 +142,8 @@ def __init__(self, s, s_max, eta, R, optimize_mode): self.bracket_id = s self.s_max = s_max self.eta = eta - self.n = math.ceil((s_max + 1) * (eta**s) / (s + 1)) # pylint: disable=invalid-name - self.r = math.ceil(R / eta**s) # pylint: disable=invalid-name + self.n = math.ceil((s_max + 1) * (eta**s) / (s + 1) - _epsilon) # pylint: disable=invalid-name + self.r = math.ceil(R / eta**s - _epsilon) # pylint: disable=invalid-name self.i = 0 self.hyper_configs = [] # [ {id: params}, {}, ... ] self.configs_perf = [] # [ {id: [seq, acc]}, {}, ... ] @@ -157,7 +158,7 @@ def is_completed(self): def get_n_r(self): """return the values of n and r for the next round""" - return math.floor(self.n / self.eta**self.i), self.r * self.eta**self.i + return math.floor(self.n / self.eta**self.i + _epsilon), self.r * self.eta**self.i def increase_i(self): """i means the ith round. Increase i by 1""" @@ -305,7 +306,7 @@ def __init__(self, R, eta=3, optimize_mode='maximize'): self.brackets = dict() # dict of Bracket self.generated_hyper_configs = [] # all the configs waiting for run self.completed_hyper_configs = [] # all the completed configs - self.s_max = math.floor(math.log(self.R, self.eta)) + self.s_max = math.floor(math.log(self.R, self.eta) + _epsilon) self.curr_s = self.s_max self.searchspace_json = None From 5296a5280850e81cd92d9c4e0a6e9603cac0c0c0 Mon Sep 17 00:00:00 2001 From: chicm-ms <38930155+chicm-ms@users.noreply.github.com> Date: Wed, 13 Mar 2019 09:56:47 +0800 Subject: [PATCH 4/5] Refactor pipeline (#833) * Refactoring test pipelines, move local integrate test from PR pipeline into a sepearate pipeline which is scheduled daily. --- azure-pipelines.yml | 28 ++++++++------------------- test/pipelines-it-local.yml | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 test/pipelines-it-local.yml diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7e99de3489..10e2f21138 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,10 +1,11 @@ -trigger: -- master -- dev-remote-ci - jobs: -- job: 'Ubuntu_16_04' - pool: 'NNI CI GPU' +- job: 'basic_test_pr_ubuntu' + pool: + vmImage: 'Ubuntu 16.04' + strategy: + matrix: + Python36: + PYTHON_VERSION: '3.6' steps: - script: python3 -m pip install --upgrade pip setuptools --user @@ -12,15 +13,6 @@ jobs: - script: | source install.sh displayName: 'Install nni toolkit via source code' - - script: | - python3 -m pip install scikit-learn==0.20.0 --user - python3 -m pip install torch==0.4.1 --user - python3 -m pip install torchvision==0.2.1 --user - python3 -m pip install keras==2.1.6 --user - python3 -m pip install tensorflow-gpu==1.10.0 --user - sudo apt-get install swig -y - nnictl package install --name=SMAC - displayName: 'Install dependencies for integration tests' - script: | cd test source unittest.sh @@ -33,16 +25,12 @@ jobs: cd test PATH=$HOME/.local/bin:$PATH python3 tuner_test.py displayName: 'Built-in tuners / assessors tests' - - script: | - cd test - PATH=$HOME/.local/bin:$PATH python3 config_test.py --ts local --local_gpu - displayName: 'Examples and advanced features tests on local machine' - script: | cd test PATH=$HOME/.local/bin:$PATH python3 metrics_test.py displayName: 'Trial job metrics test' -- job: 'macOS_10_13' +- job: 'basic_test_pr_macOS' pool: vmImage: 'macOS 10.13' strategy: diff --git a/test/pipelines-it-local.yml b/test/pipelines-it-local.yml new file mode 100644 index 0000000000..e10dd014bd --- /dev/null +++ b/test/pipelines-it-local.yml @@ -0,0 +1,38 @@ +jobs: +- job: 'integration_test_local_ubuntu' + + steps: + - script: python3 -m pip install --upgrade pip setuptools --user + displayName: 'Install python tools' + - script: | + source install.sh + displayName: 'Install nni toolkit via source code' + - script: | + python3 -m pip install scikit-learn==0.20.0 --user + python3 -m pip install torch==0.4.1 --user + python3 -m pip install torchvision==0.2.1 --user + python3 -m pip install keras==2.1.6 --user + python3 -m pip install tensorflow-gpu==1.10.0 --user + sudo apt-get install swig -y + nnictl package install --name=SMAC + displayName: 'Install dependencies for integration tests' + - script: | + cd test + source unittest.sh + displayName: 'Unit test' + - script: | + cd test + PATH=$HOME/.local/bin:$PATH python3 naive_test.py + displayName: 'Naive test' + - script: | + cd test + PATH=$HOME/.local/bin:$PATH python3 tuner_test.py + displayName: 'Built-in tuners / assessors tests' + - script: | + cd test + PATH=$HOME/.local/bin:$PATH python3 config_test.py --ts local --local_gpu + displayName: 'Examples and advanced features tests on local machine' + - script: | + cd test + PATH=$HOME/.local/bin:$PATH python3 metrics_test.py + displayName: 'Trial job metrics test' From 7d91796c3032da8ca8a82ca95757841d454a29ac Mon Sep 17 00:00:00 2001 From: SparkSnail Date: Wed, 13 Mar 2019 13:08:19 +0800 Subject: [PATCH 5/5] Fix inconsistent time format in nnimanager and dispatcher (#819) * fix remote bug * add document * add document * fix remote issue * fix forEach * update doc according to comments * remove 'any more' * set nniManager.log and dispatcher.log time format to local time --- src/nni_manager/common/log.ts | 2 +- src/sdk/pynni/nni/common.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/nni_manager/common/log.ts b/src/nni_manager/common/log.ts index 3df2fad901..d12e235836 100644 --- a/src/nni_manager/common/log.ts +++ b/src/nni_manager/common/log.ts @@ -137,7 +137,7 @@ class Logger { private log(level: string, param: any[]): void { const buffer: WritableStreamBuffer = new WritableStreamBuffer(); - buffer.write(`[${(new Date()).toISOString()}] ${level} `); + buffer.write(`[${(new Date()).toLocaleString()}] ${level} `); buffer.write(format(param)); buffer.write('\n'); buffer.end(); diff --git a/src/sdk/pynni/nni/common.py b/src/sdk/pynni/nni/common.py index 03fd870c31..3c8a9a1f51 100644 --- a/src/sdk/pynni/nni/common.py +++ b/src/sdk/pynni/nni/common.py @@ -25,6 +25,7 @@ import logging import os import sys +import time def _load_env_args(): @@ -40,7 +41,7 @@ def _load_env_args(): '''Arguments passed from environment''' -_time_format = '%Y-%m-%d %H:%M:%S' +_time_format = '%m/%d/%Y, %I:%M:%S %P' class _LoggerFileWrapper(TextIOBase): def __init__(self, logger_file): self.file = logger_file @@ -64,8 +65,8 @@ def init_logger(logger_file_path): logger_file_path = os.path.join(env_args.log_dir, logger_file_path) logger_file = open(logger_file_path, 'w') fmt = '[%(asctime)s] %(levelname)s (%(name)s/%(threadName)s) %(message)s' + logging.Formatter.converter = time.localtime formatter = logging.Formatter(fmt, _time_format) - handler = logging.StreamHandler(logger_file) handler.setFormatter(formatter)