This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update ci with new built-in tuner and assessor (#359)
* fix sdk's unittest and add medianstop, batchtuner to ci * fix sdk's unittest and add medianstop, batchtuner to ci * remove debug info * update azure-pipelines * remove useless code * add some checks * fix pylint * update ci test * update ci
- Loading branch information
1 parent
76277db
commit 7035f3e
Showing
10 changed files
with
156 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
# Copyright (c) Microsoft Corporation | ||
# All rights reserved. | ||
# | ||
# MIT License | ||
# | ||
# Permission is hereby granted, free of charge, | ||
# to any person obtaining a copy of this software and associated | ||
# documentation files (the "Software"), to deal in the Software without restriction, | ||
# including without limitation the rights to use, copy, modify, merge, publish, | ||
# distribute, sublicense, and/or sell copies of the Software, and | ||
# to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
# The above copyright notice and this permission notice shall be included | ||
# in all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING | ||
# BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
import subprocess | ||
import sys | ||
import time | ||
import traceback | ||
|
||
from utils import get_yml_content, dump_yml_content, setup_experiment, fetch_nni_log_path, check_experiment_status | ||
|
||
GREEN = '\33[32m' | ||
RED = '\33[31m' | ||
CLEAR = '\33[0m' | ||
|
||
TUNER_LIST = ['BatchTuner', 'TPE', 'Random', 'Anneal', 'Evolution'] | ||
ASSESSOR_LIST = ['Medianstop'] | ||
EXPERIMENT_URL = 'http://localhost:8080/api/v1/nni/experiment' | ||
|
||
|
||
def switch(dispatch_type, dispatch_name): | ||
'''Change dispatch in config.yml''' | ||
config_path = 'sdk_test/local.yml' | ||
experiment_config = get_yml_content(config_path) | ||
experiment_config[dispatch_type.lower()] = { | ||
'builtin' + dispatch_type + 'Name': dispatch_name, | ||
'classArgs': { | ||
'optimize_mode': 'maximize' | ||
} | ||
} | ||
dump_yml_content(config_path, experiment_config) | ||
|
||
def test_builtin_dispatcher(dispatch_type, dispatch_name): | ||
'''test a dispatcher whose type is dispatch_type and name is dispatch_name''' | ||
switch(dispatch_type, dispatch_name) | ||
|
||
print('Testing %s...' % dispatch_name) | ||
proc = subprocess.run(['nnictl', 'create', '--config', 'sdk_test/local.yml']) | ||
assert proc.returncode == 0, '`nnictl create` failed with code %d' % proc.returncode | ||
|
||
nnimanager_log_path = fetch_nni_log_path(EXPERIMENT_URL) | ||
|
||
for _ in range(10): | ||
time.sleep(3) | ||
# check if experiment is done | ||
experiment_status = check_experiment_status(nnimanager_log_path) | ||
if experiment_status: | ||
break | ||
|
||
assert experiment_status, 'Failed to finish in 30 sec' | ||
|
||
def run(dispatch_type): | ||
'''test all dispatchers whose type is dispatch_type''' | ||
assert dispatch_type in ['Tuner', 'Assessor'], 'Unsupported dispatcher type: %s' % (dispatch_type) | ||
dipsatcher_list = TUNER_LIST if dispatch_type == 'Tuner' else ASSESSOR_LIST | ||
for dispatcher_name in dipsatcher_list: | ||
try: | ||
test_builtin_dispatcher(dispatch_type, dispatcher_name) | ||
print(GREEN + 'Test %s %s: TEST PASS' % (dispatcher_name, dispatch_type) + CLEAR) | ||
except Exception as error: | ||
print(RED + 'Test %s %s: TEST FAIL' % (dispatcher_name, dispatch_type) + CLEAR) | ||
print('%r' % error) | ||
traceback.print_exc() | ||
raise error | ||
finally: | ||
subprocess.run(['nnictl', 'stop']) | ||
|
||
|
||
if __name__ == '__main__': | ||
installed = (sys.argv[-1] != '--preinstall') | ||
setup_experiment(installed) | ||
|
||
run('Tuner') | ||
run('Assessor') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters