Skip to content

Commit

Permalink
Merge pull request #149 from Microsoft/master
Browse files Browse the repository at this point in the history
Fix remote integration test pipeline (microsoft#914)
  • Loading branch information
SparkSnail authored Mar 26, 2019
2 parents ec41d56 + c29a0cc commit 080ae00
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
19 changes: 9 additions & 10 deletions test/pipelines-it-remote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ jobs:
steps:
- script: python3 -m pip install --upgrade pip setuptools --user
displayName: 'Install python tools'
- script: |
cd deployment/pypi
echo 'building prerelease package...'
make build
ls $(Build.SourcesDirectory)/deployment/pypi/dist/
displayName: 'build nni bdsit_wheel'
- script: |
source install.sh
displayName: 'Install nni toolkit via source code'
Expand All @@ -14,17 +20,10 @@ jobs:
- task: CopyFilesOverSSH@0
inputs:
sshEndpoint: remote_nni-ci-gpu-01
sourceFolder: src/sdk/pynni
targetFolder: /tmp/nnitest/$(Build.BuildId)/pynni
overwrite: true
displayName: 'Copy sdk files to remote machine'
- task: CopyFilesOverSSH@0
inputs:
sshEndpoint: remote_nni-ci-gpu-01
sourceFolder: tools
targetFolder: /tmp/nnitest/$(Build.BuildId)/tools
sourceFolder: deployment/pypi/dist/
targetFolder: /tmp/nnitest/$(Build.BuildId)/dist
overwrite: true
displayName: 'Copy tool files to remote machine'
displayName: 'Copy dist files to remote machine'
- task: CopyFilesOverSSH@0
inputs:
sshEndpoint: remote_nni-ci-gpu-01
Expand Down
17 changes: 14 additions & 3 deletions test/remote_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from subprocess import check_output, check_call
import socket
import random
import re

def detect_port(port):
'''Detect if the port is used, return True if the port is used'''
Expand All @@ -21,17 +22,27 @@ def find_port():
port = random.randint(10000, 20000)
return port

def find_wheel_package(dir):
'''Find the wheel package uploaded to this machine'''
regular = re.compile('^nni-.*\.whl$')
for file_name in os.listdir(dir):
if regular.search(file_name):
return file_name
return None

def start_container(image, name):
'''Start docker container, generate a port in /tmp/nnitest/{name}/port file'''
port = find_port()
source_dir = '/tmp/nnitest/' + name
run_cmds = ['docker', 'run', '-d', '-p', str(port) + ':22', '--name', name, '--mount', 'type=bind,source=' + source_dir + ',target=/tmp/nni', image]
output = check_output(run_cmds)
commit_id = output.decode('utf-8')
sdk_cmds = ['docker', 'exec', name, 'python3', '-m', 'pip', 'install', '--user', '--no-cache-dir', '/tmp/nni/pynni/']
wheel_name = find_wheel_package(os.path.join(source_dir, 'dist'))
if not wheel_name:
print('Error: could not find wheel package in {0}'.format(source_dir))
exit(1)
sdk_cmds = ['docker', 'exec', name, 'python3', '-m', 'pip', 'install', '/tmp/nni/dist/{0}'.format(wheel_name)]
check_call(sdk_cmds)
tools_cmds = ['docker', 'exec', name, 'python3', '-m', 'pip', 'install', '--user', '--no-cache-dir', '/tmp/nni/tools']
check_call(tools_cmds)
with open(source_dir + '/port', 'w') as file:
file.write(str(port))

Expand Down

0 comments on commit 080ae00

Please sign in to comment.