Skip to content

Commit

Permalink
Merge pull request microsoft#141 from Microsoft/master
Browse files Browse the repository at this point in the history
merge master
  • Loading branch information
SparkSnail authored Mar 13, 2019
2 parents 17e719e + 7d91796 commit e25ffbd
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 36 deletions.
11 changes: 3 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
28 changes: 8 additions & 20 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
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
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
Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,10 @@ def run(self):

cmdclass={
'install': CustomInstallCommand
},
entry_points = {
'console_scripts' : [
'nnictl = nni_cmd.nnictl:parse_args'
]
}
)
2 changes: 1 addition & 1 deletion src/nni_manager/common/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions src/sdk/pynni/nni/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import logging
import os
import sys
import time


def _load_env_args():
Expand All @@ -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
Expand All @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions src/sdk/pynni/nni/hyperband_advisor/hyperband_advisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

_next_parameter_id = 0
_KEY = 'STEPS'
_epsilon = 1e-6

@unique
class OptimizeMode(Enum):
Expand Down Expand Up @@ -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]}, {}, ... ]
Expand All @@ -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"""
Expand Down Expand Up @@ -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
Expand Down
38 changes: 38 additions & 0 deletions test/pipelines-it-local.yml
Original file line number Diff line number Diff line change
@@ -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'
3 changes: 2 additions & 1 deletion test/unittest.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
set -e
CWD=${PWD}

# -------------For python unittest-------------
Expand All @@ -25,4 +26,4 @@ python3 -m unittest discover -v tests
cd ${CWD}/../src/nni_manager
echo ""
echo "===========================Testing: nni_manager==========================="
npm run test
npm run test

0 comments on commit e25ffbd

Please sign in to comment.