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/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/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' + ] } ) 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) 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 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' 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